Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to get tree view node's name in parent page -Routed bubble event.

$
0
0

In our application we are having a user control that has tree view and this user control has been called in the main page.

Code is mentioned below.How can i get the tree view clicked node name in the main page. please help me. i am new to WPF.

I got the code how to write in user control but i don't know how to handle the user control routed event in main page.

Code in User control:

=============================

public static readonly RoutedEvent NavigateEvent = EventManager.RegisterRoutedEvent("CustomClick", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ucMainMenu));

        public ucMainMenu()
        {
            InitializeComponent();
            this.MenuTreeView.AddHandler(TreeView.MouseDoubleClickEvent, new RoutedEventHandler(CustomClick_RaiseEvent));


        }

public event RoutedEventHandler CustomClick
        {

            add
            {
                this.AddHandler(NavigateEvent, value);
            }

            remove
            {
                this.RemoveHandler(NavigateEvent, value);
            }
        }

public void CustomClick_RaiseEvent(object sender, RoutedEventArgs e)
        {

            RoutedEventArgs newEventArgs = new RoutedEventArgs(ucMainMenu.NavigateEvent);
            this.RaiseEvent(newEventArgs);

        }

        private void MenuTreeView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            
            CustomClick_RaiseEvent(item  , e);
        }


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>