Skip to content

Commit 4d0469f

Browse files
ES-975464 - Changes committed
1 parent 1c8e1bc commit 4d0469f

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed
118 KB
Loading

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
# how-to-bind-button-command-to-view-model-in-wpf-and-uwp-treegrid-in-mvvm
1+
# How to Bind Button Command to ViewModel in WPF / UWP TreeGrid in MVVM?
22

3-
This example illustrates to bind the `Button` command to ViewModel in [WPF TreeGrid](https://www.syncfusion.com/wpf-controls/treegrid) and [UWP TreeGrid](https://www.syncfusion.com/uwp-ui-controls/treegrid).
3+
This example illustrates to bind the Button command to ViewModel in [WPF TreeGrid](https://www.syncfusion.com/wpf-controls/treegrid) and [UWP TreeGrid](https://www.syncfusion.com/uwp-ui-controls/treegrid) (SfTreeGrid).
44

5-
You can load a `button` for the columns in treegrid using [TreeGridTemplateColumn](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeGridTemplateColumn.html). When loading the buttons, you can bind a command in ViewModel using `ElementName` binding.
5+
You can load a button for the columns in TreeGrid using [TreeGridTemplateColumn](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeGridTemplateColumn.html). When loading the buttons, you can bind a command in ViewModel using ElementName binding.
66

7-
## XAML code:
7+
### XAML:
88
``` xml
9-
<syncfusion:TreeGridTemplateColumn MappingName="Title" syncfusion:FocusManagerHelper.WantsKeyInput="True">
9+
<syncfusion:TreeGridTemplateColumn MappingName="Title"
10+
syncfusion:FocusManagerHelper.WantsKeyInput="True">
1011
<syncfusion:TreeGridTemplateColumn.CellTemplate>
1112
<DataTemplate>
1213
<Button Content="Click" syncfusion:FocusManagerHelper.FocusedElement="True"
13-
Command="{Binding Path=DataContext.RowDataCommand,ElementName=treeGrid}" CommandParameter="{Binding}"/>
14+
Command="{Binding Path=DataContext.RowDataCommand,ElementName=treeGrid}"
15+
CommandParameter="{Binding}"/>
1416
</DataTemplate>
1517
</syncfusion:TreeGridTemplateColumn.CellTemplate>
1618
</syncfusion:TreeGridTemplateColumn>
17-
```
19+
```
20+
21+
![How to Bind Button Command to ViewModel in WPF / UWP TreeGrid in MVVM](Bind_button_command_to_viewmodel.png)

0 commit comments

Comments
 (0)