Silverlight - 单击复选框时不执行命令

时间:2013-06-05 10:04:12

标签: .net vb.net silverlight-4.0

我的xaml中有一个复选框

<CheckBox Grid.Row="1" Command="{Binding ShowCancelledPropertiesCommand}" HorizontalAlignment="Right" Margin="0,6,160,0"/>

及以下是视图模型中命令的设置

Me.ShowCancelledPropertiesCommand = New DelegateCommand(AddressOf ShowCancelledPropertiesClicked, AddressOf ShowCancelledPropertiesCanExecute)

我不明白为什么命令没有被解雇?

1 个答案:

答案 0 :(得分:0)

我会对复选框的IsChecked属性进行双向绑定。

IsChecked="{Binding somePropertyInViewModel, Mode=TwoWay}

在viewmodel中,将一些逻辑放入属性中。

public bool somePropertyInViewModel
    {
        get { ... }
        set { ... }
    }