I have a physician object, and one of its properties is an ObservableList
of clinics. It is being used in a window to show the details of a physician. I can get individual properties to bind to TextBox
and ComboBox
controls, but I can't get the list of clinics to bind to my ListBox
.
Here is the xaml for my ListBox
:
<ListBox Height="318"
HorizontalAlignment="Left"
Margin="422,0,0,0"
Name="lbClinic"
VerticalAlignment="Top"
Width="158"
SelectedValue="{Binding ClinicID, Path=Clinics, Mode=TwoWay,
UpdateSourceTrigger = PropertyChanged}"
SelectedValuePath="ClinicID"
DisplayMemberPath="Name"
ItemsSource="{Binding DataContext.ClinicList,
ElementName = PhysicianInfoLookup, Mode = OneWay}"
SelectionMode="Multiple" />
The Listbox populates properly with items from the ClinicList which is a list of all possible clinics. However, I cannot get the Clinics list from the physician object to bind so that it's items are selected in the Listbox. I also want to go the other way and if an item is deselected, the ObservableList in the physician object will change accordingly.
How do I two-way bind the ObservableList of Clinics in my physician object to the list of Clinics (ObservableList of clinic objects) in my Listbox?
Thank you.