Click here to Skip to main content
15,795,581 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In Wpf ListView can have several "view classes" to show items.
Those classes derived from "BaseView" class.

When you create custom views, you can't create RoutedEvents because "BaseView" has not a "AddHandle" static method.

I had created a GridViewSort view. (With column sorting feature) and I want to add a "DoSort" routed event with column and sortdirection as parameters.

BUT when I try to use AddHandler and DeleteHandler. Those methods are not available into "baseview" class.

Can I provide an alternative to those methods?

What I have tried:

public class GridViewSort:GridView
        private static readonly string SortUpIcon = "M 2,5 L 4,3 L 6,5 L 2,5";
        private static readonly string SortDownIcon = "M 2,3 L 4,5 L 6,3 L 2,3";

        public static readonly RoutedEvent DoSortEvent = EventManager.RegisterRoutedEvent("DoSort",
            RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(GridViewSort));

        public event RoutedEventHandler DoSort
            add { AddHandler(DoSortEvent, value); }
            remove { RemoveHandler(DoSortEvent, value); }
Gerry Schmitz 28-Apr-21 15:04pm    
Add sorting, as a default, to the base; then enable / disable it in the views if it's such a big deal.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900