我使用Infragistics XamDataGrid
在网格上显示数据。在此网格中,有一个复选框列(列名:" IsSelected")。我在此列的标题中添加了CheckBox
以选择全部'选项。
如何根据属性' IsCheckboxHeaderEnabled'启用/禁用此标头CheckBox
在ViewModel?
<igDP:XamDataGrid x:Name="ItemSource" DataSource="{Binding ItemSource,Mode=TwoWay}" Grid.Row="0" Margin="10" AutoFit="true">
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:FieldLayout.Fields>
<igDP:Field Name="IsSelected" Label=" " HorizontalContentAlignment="Left" Width="Auto" VerticalContentAlignment="Center">
<igDP:Field.Settings>
<igDP:FieldSettings DataItemUpdateTrigger="OnCellValueChange">
<igDP:FieldSettings.LabelPresenterStyle>
<Style TargetType="{x:Type igDP:LabelPresenter}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<CheckBox Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" Content="" IsEnabled="{Binding IsCheckboxHeaderEnabled}"/>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</igDP:FieldSettings.LabelPresenterStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
<igDP:Field Label="Projects" Name="ModelFileName" AllowEdit="False" HorizontalContentAlignment="Left" Width="*"/>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
答案 0 :(得分:2)
只要IsCheckboxHeaderEnabled
属性与ItemSource
属性在同一个类中定义,这应该可以工作:
<CheckBox ... IsEnabled="{Binding DataContext.IsCheckboxHeaderEnabled, RelativeSource={RelativeSource AncestorType=igDP:XamDataGrid}}"/>