在视图,即XAML,我已在全选布尔值绑定到CheckBox控件在WPF/MVVM,如何实现以完美的方式
<CheckBox Grid.Row="5" Content="Select All" HorizontalAlignment="Left" Margin="0,5, 0, 0" IsChecked="{Binding Path=SelectAll, Mode=TwoWay}" Width="206"></CheckBox>
“全选”功能和fullfill的全选作为
public bool SelectAll
{
get { return this.Get<bool>("SelectAll"); }
set
{
this.Set<bool>("SelectAll", value);
if (this.SelectAllCommand.CanExecute(null))
this.SelectAllCommand.Execute(value);
}
}
是的,它看起来不错,但我有一个问题...
当所有的复选框被手动选择,在全选复选框应自动选择......在那个时候,我们不不想要SelectAllCommand要执行的命令......
我该怎么办呢.....我知道也许这是一件容易的事,但如何完美地做到这一点....
谢谢你给我一些提前
你一定希望SelectedAll属性是可空 –
Aron
2013-04-08 07:15:36
BTW是什么this.Set/this.Get? – Aron 2013-04-08 07:21:46
他只是想“当所有的复选框手动选择,...”,所以这是一个很好的问题+1。确定它可以在ObservableCollection Source.CollectionChanged事件上实现。但这个问题寻找最佳做法。 –
2013-04-08 07:22:51