I make a sample based on my understanding, please check if it meets your needs, if it doesn't, let me know:
XAML code is:
<Window.Resources>
<local:BooleanToInt x:Key="conBooleanToInt" />
</Window.Resources>
<StackPanel Orientation="Horizontal">
<Label Name="lb" Width="40" Height="30" Content="{Binding TypeID,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Background="Azure" VerticalAlignment="Top" ></Label>
<RadioButton Content="Credit" IsChecked="True" ></RadioButton>
<RadioButton Content="Debit" IsChecked="{Binding Path=TypeID, Converter={StaticResource conBooleanToInt},UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Margin="30 0 0 0"/>
</StackPanel>
vb code is:
Imports System.ComponentModel
Partial Public Class MainWindow
Inherits Window
Private Property model As Model = New Model()
Public Sub New()
InitializeComponent()
model.TypeID = 5
Me.DataContext = model
End Sub
End Class
Public Class Model
Implements INotifyPropertyChanged
Public _typeID As Integer
Public Property TypeID As Integer
Get
Return _typeID
End Get
Set(ByVal value As Integer)
_typeID = value
OnPropertyChanged("TypeID")
End Set
End Property
Private Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Protected Sub OnPropertyChanged(ByVal proName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(proName))
End Sub
End Class
Public Class BooleanToInt
Implements IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.Convert
Dim x As Integer = Integer.Parse(value.ToString())
If x = 5 Then
Return True
Else
Return False
End If
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Dim x As Boolean = System.Convert.ToBoolean(value)
If x = False Then
Return 209
Else
Return 5
End If
End Function
End Class
Result picture is:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.