我有数据网格,其中一列是按钮列,我想将此单击绑定到视图模型,但它没有到达视图模型功能。
<DataGrid CanUserAddRows="False" AutoGenerateColumns="False" ItemsSource="{Binding TableComments}" SelectedItem="{Binding SelectedRow}" x:Name="dataGrid" >
<DataGrid.Columns >
<DataGridTemplateColumn Header="Delete">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Command="{Binding DeleteCommentCommand}" >Delete</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
在视图模型中:
public ICommand DeleteCommentCommand { get; private set; }
public MyViewModel()
{
DeleteCommentCommand = new RelayCommand(Delete);
}
void Delete()
{
}
我感觉问题出在这一行:
<Button Command="{Binding DeleteCommentCommand}" >Delete</Button>
qq_花开花谢_0
相关分类