RadioButton设置反转值

时间:2016-09-12 12:09:36

标签: c# wpf xaml

我的视图中有以下单选按钮(XAML):

<RadioButton Content="Single bill" IsChecked="{Binding AccountingCreationData.IsSingleBill, Converter={StaticResource BoolToVis}}" />

<RadioButton Content="Collective bill" IsChecked="{Binding AccountingCreationData.IsCollectiveBill, Converter={StaticResource BoolToVis}}" HorizontalAlignment="Left" Width="179"/>

我的viewmodel中的属性是这样实现的(C#):

public bool IsSingleBill
{
    get { return _singleBill; }
    set
    {
        if (_singleBill != value)
        {
            _singleBill = value;
            IsCollectiveBill = !value;
            RaisePropertyChanged("IsSingleBill");
        }
    }
}

public bool IsCollectiveBill
{
    get { return _collectiveBill; }
    set
    {
        if (_collectiveBill != value)
        {
            _collectiveBill = value;
            IsSingleBill = !value;
            RaisePropertyChanged("IsCollectiveBill");
        }
    }
}

但是,一旦我“检查”“单一帐单”选项,该值为false(但它应为true)。

加载视图后,没有选中的单选按钮(虽然我在构造函数中设置了IsSingleBill = true)。

0 个答案:

没有答案