I cannot get binding to work when the controls that define them initially load. I have a couple RadioButton
s that bind IsChecked
to an enum the following way:
<RadioButton Content="My Enum Field">
<RadioButton.IsChecked>
<Binding
Path="ViewModel.MyProperty"
Converter="{StaticResource ValueEqualsParameterConverter}"
Mode="TwoWay"
UpdateSourceTrigger="PropertyChanged">
<Binding.ConverterParameter>
<local:MyEnum>MyEnumField</local:MyEnum>
</Binding.ConverterParameter>
</Binding>
</RadioButton.IsChecked>
</RadioButton>
The converter I use is:
public class ValueEqualsParameterConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return value == parameter;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return parameter;
}
}
When you load the Page
that displays these RadioButton
s, the initial value is not checking the appropriate RadioButton
. I have confirmed the value is changing when you manually check the RadioButton
s by printing to the console from the view model.
I am new to UWP and I’ve never had this issue with regular WPF so any help is appreciated!
Note: I cannot tag UWP
, WPF
, XAML
, or C#
, but these are the relevant technologies I am using.