Hi
I have a GridDataControl in WPF In which I have added button inside the Grid's Column But I am not able to fire the Button's Click event in ViewModel . The CoDE TO ADD button is given below But its not firing SelectAllCommand method .
<syncfusion:GridDataVisibleColumn UpdateMode="PropertyChanged" HeaderText="Rig Button" MappingName="Btntext" > <syncfusion:GridDataVisibleColumn.CellItemTemplate > <DataTemplate> <Button Width="100" Height="30" Command="{Binding Record.Data.SelectAllCommand }" Content="{Binding Record.Data.Btntext }" HorizontalAlignment="Left" Margin="3,0,0,0" VerticalAlignment="Center"> </Button> </DataTemplate> </syncfusion:GridDataVisibleColumn.CellItemTemplate> </syncfusion:GridDataVisibleColumn>
Hi Ayush,
We regret for the delay caused.
While binding a command written in ViewModel, we should set binding using its DataContext like DataContext.SelectAllCommand. We cannot bind using Record property, as it will hold only the properties of the current record.
|
Code Snippet:
<syncfusion:GridDataVisibleColumn UpdateMode="PropertyChanged" HeaderText="Rig Button" MappingName="Btntext"> <syncfusion:GridDataVisibleColumn.CellItemTemplate > <DataTemplate> <Button Width="100" Height="30" Command="{Binding DataContext.SelectAllCommand, ElementName=_grid }" Content="{Binding Record.Data.Btntext }" HorizontalAlignment="Left" Margin="3,0,0,0" VerticalAlignment="Center"> </Button> </DataTemplate> </syncfusion:GridDataVisibleColumn.CellItemTemplate> </syncfusion:GridDataVisibleColumn>
|
Regards,
Divya.