我遇到了数据绑定问题。我正在使用 MVVM Light。
当我在视图模型中的一个布尔值的设置器上设置断点并选择相应的单选按钮时,调试器停止并且一切看起来都很好。
然后当我继续时,选择另一个单选按钮并再次选择第一个单选按钮,调试器不会停止。出了什么问题?
我有两个两个单选按钮:
<RadioButton Margin="5" Grid.Row="1" Content="Browser cookies" GroupName="loginmethod" IsChecked="{Binding IsBrowserCookiesChecked}"/>
<RadioButton Margin="5" Grid.Row="2" Content="Username + password" GroupName="loginmethod" IsChecked="{Binding IsUsernamePasswordChecked}"/>
我在我的视图模型中将它们限制为两个单独的布尔值,如下所示:
public const string IsUsernamePasswordCheckedPropertyName = "IsUsernamePasswordChecked";
private bool _isUsernamePasswordChecked = false;
public bool IsUsernamePasswordChecked
{
get
{
return _isUsernamePasswordChecked;
}
set
{
if (_isUsernamePasswordChecked == value)
{
return;
}
RaisePropertyChanging(IsUsernamePasswordCheckedPropertyName);
_isUsernamePasswordChecked = value;
RaisePropertyChanged(IsUsernamePasswordCheckedPropertyName);
}
}
public const string IsBrowserCookiesCheckedPropertyName = "IsBrowserCookiesChecked";
private bool _isBrowserCookiesChecked = true;
public bool IsBrowserCookiesChecked
{
get
{
return _isBrowserCookiesChecked;
}
set
{
if (_isBrowserCookiesChecked == value)
{
return;
}
RaisePropertyChanging(IsBrowserCookiesCheckedPropertyName);
_isBrowserCookiesChecked = value;
RaisePropertyChanged(IsBrowserCookiesCheckedPropertyName);
}
}