<DataGrid.Columns> <DataGridTextColumn Binding="{Binding Property1}" Header="Property1"/> <DataGridCheckBoxColumn Binding="{Binding Property2}" Header="Property2"/> <DataGridTemplateColumn Header="功能" CellTemplate="{DynamicResource DataTemplate1}"/> </DataGrid.Columns>
Header为功能的那一列是我要添加的按钮,用的CellTemplate模板,事实上,正如我标题中所写,CellTemplate不是依赖属性,不能绑定DynamicResource,最后的代码是这个样子的:
<DataGrid.Columns> <DataGridTextColumn Binding="{Binding Property1}" Header="Property1"/> <DataGridCheckBoxColumn Binding="{Binding Property2}" Header="Property2"/> <DataGridTemplateColumn Header="功能" CellTemplate="{StaticResource DataTemplate1}"/> </DataGrid.Columns>原文链接:https://www.f2er.com/javaschema/287077.html