我在 WPF 应用程序中有一个带有 4 个单选按钮(2 个组)的向导内的页面。我正在使用 .Net4 和 Caliburn Micro。
单击并设置值时,它会正确绑定到相应的属性。当我离开页面并返回时,我需要在代码中设置属性并期望它们通过 NotifyPropertyChanged 在页面上更新。但是即使设置了相应的属性,也不会检查任何 RadioButtons...
有谁知道这应该如何与 caliburn.micro 一起使用?!
这是xml:
<RadioButton Name="NewInstallChecked" GroupName="InstallType" Content="New Installation (default)" Margin="75,10,0,0" />
<RadioButton Name="UpdateInstallChecked" GroupName="InstallType" Content="Update of existing Installation" Margin="75,10,0,0" />
<Label Content="Please select which version of Siseco you want to install:" Height="28" HorizontalAlignment="Left" Margin="20,20,0,0" Name="label2" VerticalAlignment="Top" />
<RadioButton Name="ServerChecked" GroupName="Version" Content="Server version (default)" Margin="75,10,0,0" />
<RadioButton Name="ClientChecked" GroupName="Version" Content="Client version" Margin="75,10,0,0" />
这里是我的视图模型中的代码:
public bool ClientChecked
{
get { return _clientChecked; }
set { _clientChecked = value; NotifyOfPropertyChange(() => ClientChecked); }
}
public bool ServerChecked
{
get { return _serverChecked; }
set { _serverChecked = value; NotifyOfPropertyChange(() => ServerChecked); }
}
public bool NewInstallChecked
{
get { return _newInstallChecked; }
set { _newInstallChecked = value; NotifyOfPropertyChange(() => NewInstallChecked); }
}
public bool UpdateInstallChecked
{
get { return _updateInstallChecked; }
set { _updateInstallChecked = value; NotifyOfPropertyChange(() => UpdateInstallChecked);}
}
...
protected override void OnActivate()
{
NewInstallChecked = _options.NewInstall;
UpdateInstallChecked = _options.UpdateInstall;
ServerChecked = _options.ServerInstall;
ClientChecked = _options.ClientInstall;
base.OnActivate();
}