0
我有我的XamDataGrid內的複選框,如下所示: -綁定命令到複選框的onclick一個xamdatagrid裏面WPF不工作
<igDp:UnboundField Width="1*" Label="{LocText props:Resources.GROUPLIST_SYNC}" BindingMode="TwoWay" BindingPath="IsSynchronise.Value" Converter="{StaticResource BoolToUMDirectoryFilter}" ConverterParameter="Enabled" ToolTip="{LocText props:Resources.GROUPLIST_SYNC}">
<igDp:UnboundField.Settings>
<igDp:FieldSettings AllowEdit="True">
<igDp:FieldSettings.LabelPresenterStyle >
<Style TargetType="igDp:LabelPresenter" BasedOn="{StaticResource GmsLabelStyle }">
<Setter Property="AutomationProperties.AutomationId" Value="Group_SYNC"></Setter>
</Style>
</igDp:FieldSettings.LabelPresenterStyle>
<igDp:FieldSettings.CellValuePresenterStyle>
<Style TargetType="{x:Type igDp:CellValuePresenter}">
<Setter Property="Margin" Value="2"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="igDp:CellValuePresenter">
<CheckBox Name="chkSynchronise" IsChecked="{Binding Path=DataContext.DataItem.IsSynchronise.Value, RelativeSource={ RelativeSource Mode=TemplatedParent}}"
HorizontalAlignment="Center" Command="{Binding SynchroniseGroups,RelativeSource={RelativeSource Mode=Self}}" HorizontalContentAlignment="Left" >
</CheckBox>
<!--<CheckBox IsChecked="{Binding Path=DataContext.DataItem.IsSynchronise.Value, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, RelativeSource={ RelativeSource Mode=TemplatedParent}}"
Command="{Binding SynchroniseGroups,RelativeSource={RelativeSource Mode=Self}}"
HorizontalAlignment="Center" HorizontalContentAlignment="Left" >
</CheckBox>-->
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</igDp:FieldSettings.CellValuePresenterStyle>
</igDp:FieldSettings>
</igDp:UnboundField.Settings>
</igDp:UnboundField>
所以,我應該怎麼綁定命令,以複選框點擊工作,並獲得ViewModel中選中和取消選中的行爲?任何幫助將非常感激。提前致謝。
爲什麼你需要使用命令?您已經將IsChecked屬性綁定到某個東西,可以使用它的值更改來處理單擊事件邏輯 – Bijington
基本複選框沒有此命令...更改self relativSource – GCamel