Shobha M Shobha M - 1 month ago 5x
C# Question

Edited template of TreeView

I am working on WPF application. I have edited template of

control and added a button to the template.

Adding this control to the window works fine and displays the button, but how to trigger button click event or command in my window?


Here is the answer assuming that you are trying to run a command in the WindowVM from inside the DataTemplate of TreeView in view.

Command="{Binding DataContext.MyCommand, RelativeSource={RelativeSource AncestorType={x:Type local:MyWindow}}}"