Hi, you bind all CheckBoxes in GroupBox to the same property and use Click event. That can create unpredictable effects. Bind only one Checkbox (in GroupBox) and use setter in binded property instead of click event. Try following demo:
XAML:
<Window x:Class="Window005"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1.WpfApp005"
mc:Ignorable="d"
Title="Window005" Height="450" Width="800">
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
<Window.Resources>
<local:DisplayUnitConverter x:Key="DisplayUnitConverter" />
</Window.Resources>
<StackPanel>
<GroupBox Header="Display Units"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
FontSize="16" Margin="0,39,10,0">
<StackPanel HorizontalAlignment="Left"
VerticalAlignment="Center"
Orientation="Vertical"
Width="349" >
<Label Content="Max Hatch Speed:" />
<RadioButton Content="Millimeters"
GroupName="DisplayUnits"
IsChecked="{Binding Path=MaxHatchSpeed, Converter={StaticResource DisplayUnitConverter}, Mode=TwoWay}"/>
<RadioButton Content="Inches"
GroupName="DisplayUnits"/>
</StackPanel>
</GroupBox>
<StackPanel Orientation="Horizontal" Margin="5">
<Label Content="MaxHatchSpeed: "/>
<TextBlock Text="{Binding MaxHatchSpeed}" Margin="3"/>
</StackPanel>
</StackPanel>
</Window>
Code:
Imports System.ComponentModel
Imports System.Globalization
Imports System.Runtime.CompilerServices
Public Class Window005
End Class
Namespace WpfApp005
Public Class ViewModel
Implements INotifyPropertyChanged
Private _maxHatchSpeed As Double = 1
Public Property MaxHatchSpeed As Double
Get
Return Me._maxHatchSpeed
End Get
Set(value As Double)
If value >= 0 AndAlso value <= 100 Then
Me._maxHatchSpeed = value
OnPropertyChanged()
End If
End Set
End Property
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Private Sub OnPropertyChanged(<CallerMemberName> Optional propName As String = "")
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
End Sub
End Class
Public Class DisplayUnitConverter
Implements IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
If CType(value, Double) = 1 Then Return True
Return False
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
If CType(value, Boolean) Then Return 1
Return 25.4
End Function
End Class
End Namespace