c# - WPF: Custom routed event with extra information -


I have a normal WPF window, let's call it TopLevel , in which one The bunch is, among other things, in a simple ListView , some events should be logged in various elements in the application.

It looks like I have a group of user controls called grid in TopLevel which contains work each , there is an object with them, let's call it a order , as well as a standard checkbox.

Now whenever a user checks a checkbox in work , but command objects in the event also top level Should be included, so I can work from TopLevel to keep it in the event log.

How can I do this? I'm guessing that I want to use the rooted event for this, but I did not know how to get the "code" to order the "code" in the check box, call it TopLevel < / Code>.

How to do something like this ...

  Private Zero checkbox Checked (Object Sender, Routing Avent ARG E) {Sendbox as Checkbox = Checkbox; Job Task = FindPartTkS (Checkboxes); Order order = task.order; }  

Because you need to cross the visual tree to work, so you can try some recurring ...

  public framework Element FindParentTask (framework element element) {if (element.Parent.GetType () == Type (Task)) return element. Parents as FrameworkElement; And again FindParentTask (FrameworkElement as element.Parent); }  

I have tested this method to retrieve the parent extension to the check box on one of my user controls, it has several levels of visual tree, the stack Nested dock panels in a pile of pans, grids and stacks, have a cure.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -