Hi,@RogerSchlueter-7899 . Welcome to Microsoft Q&A. You could update the code ItemsSource="{binding source=route}"
to ItemsSource="{Bind Route}"
and change the code-behind.
<Grid>
<ListBox
x:Name="lbxRoutes"
DisplayMemberPath="Name"
ItemsSource="{Binding Routes}"
Margin="10,13,10,0"
SelectedValue="{Binding RouteID}"
SelectedValuePath="ElementID"
SelectionMode="Single">
</ListBox>
</Grid>
Codebehind:
Class MainWindow
Public Sub New()
InitializeComponent()
DataContext = Me
End Sub
Private clsRoutes As List(Of GeoElement) = New List(Of GeoElement) From {
New GeoElement With {.ElementID = 0, .Name = "abc"},
New GeoElement With {.ElementID = 1, .Name = "def"},
New GeoElement With {.ElementID = 2, .Name = "ghi"}
}
Public Property Routes As List(Of GeoElement)
Get
Return clsRoutes
End Get
Set(value As List(Of GeoElement))
clsRoutes = value
End Set
End Property
Private _routeID As Integer
Public Property RouteID As Integer
Get
Return _routeID
End Get
Set(ByVal value As Integer)
If value <> _routeID Then
_routeID = value
End If
End Set
End Property
End Class
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.