日期:2014-05-17  浏览次数:20837 次

WPF 如何在DataGrid中根据一个单元格的值去禁用掉另一个单元格的button
      <DataGrid  AutoGenerateColumns="False" Height="195" Name="dataGrid1" Width="496">
            <DataGrid.Columns>
                <DataGridTextColumn Header="ID" x:Name="id" Width="*" Binding="{Binding ID}" >
                   
                </DataGridTextColumn>
                <DataGridTextColumn Header="Name" Width="*"  Binding="{Binding Name}"/>
                <DataGridTextColumn Header="Age" Width="*" />

                <DataGridTemplateColumn Header=" Action" Width="*" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" >
                                <Button Content="Delete"  />
                                <Button Content="Edit"/>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
例如上面的例子,通过判断Name是不是等于xxxxx而是所在行的Delete按钮disable
WPF?DataGrid? DataGrid?DataTrigger

------解决方案--------------------
在数据绑定时,根据一个单元格的内容去判断Button的值应该是true或false<