RadioButton を使用する場合は、RadioButton のデフォルトの動作を回避するためにいくつかの微調整を行うだけで済みます。
回避する必要がある最初の問題は、共通の直接の親コンテナーに基づく RadioButton の自動グループ化です。「GroupName」ハックが気に入らないので、他のオプションは、各 RadioButton を独自のグリッドまたは他のコンテナー内に配置することです。これにより、各ボタンが独自のグループのメンバーになり、IsChecked バインディングに基づいて動作するようになります。
<StackPanel Orientation="Horizontal">
<Grid>
<RadioButton IsChecked="{Binding Path=CurrentMode, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Idle}">Idle</RadioButton>
</Grid>
<Grid>
<RadioButton IsChecked="{Binding Path=CurrentMode, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Active}">Active</RadioButton>
</Grid>
<Grid>
<RadioButton IsChecked="{Binding Path=CurrentMode, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Disabled}">Disabled</RadioButton>
</Grid>
<Grid>
<RadioButton IsChecked="{Binding Path=CurrentMode, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Running}">Running</RadioButton>
</Grid>
</StackPanel>
これは、 IsChecked プロパティにバインドしているため、 set 呼び出しをトリガーするために必要だったボタンをクリックした後、クリックされたボタンが Checked 状態にとどまらないようにする次の回避策につながります。追加の NotifyPropertyChanged を送信する必要がありますが、それを Dispatch スレッドのキューにプッシュして、ボタンが通知を受け取り、視覚的な IsChecked バインディングを更新できるようにする必要があります。これを ViewModel クラスに追加します。これはおそらく既存の NotifyPropertyChanged 実装を置き換えるものであり、クラスが質問のコードにない INotifyPropertyChanged を実装していると想定しています。
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
Dispatcher uiDispatcher = Application.Current != null ? Application.Current.Dispatcher : null;
if (uiDispatcher != null)
{
uiDispatcher.BeginInvoke(DispatcherPriority.DataBind,
(ThreadStart)delegate()
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
});
}
}
}
次に、CurrentMode のセッターで NotifyPropertyChanged("CurrentMode") を呼び出します。サーバーの ModeChanged 呼び出しはおそらく Dispatcher スレッドではないスレッドで行われるため、おそらくすでにこのようなものが必要でした。
最後に、異なる Checked/Unchecked の外観を持たせたい場合は、RadioButton に Style を適用する必要があります。WPF RadioButton ControlTemplate を Google ですばやく検索すると、最終的にhttp://madprops.org/blog/wpf-killed-the-radiobutton-star/というサイトが見つかりました。