I've bound the DataContext
of the following Window to the code behind to give me a MVVM style
to demonstrate this behaviour:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<StackPanel>
<RadioButton GroupName="test" Content="Monkey" IsChecked="{Binding IsMonkey}"/>
<RadioButton GroupName="test" Content="Turtle" IsChecked="{Binding IsTurtle}" />
</StackPanel>
</Window>
Heres the code behind:
public partial class Window1
{
public Window1()
{
InitializeComponent();
}
private bool _isMonkey;
public bool IsMonkey
{
get { return _isMonkey; }
set
{
_isMonkey = value;
}
}
private bool _isTurtle;
public bool IsTurtle
{
get { return _isTurtle; }
set
{
_isTurtle = value;
}
}
}
Putting a breakpoint on the set of IsMonkey
and IsTurtle
and then running the application and selecting IsMonkey
and IsTurtle
after each other I found that it works for the first selection of each control, on the second selection the binding breaks and the breakpoints are no longer triggered?
Can anyone point me in the right direction, please?