Before displaying the UI, data will be retrieved from database and these data to be displayed on screen.
Now I have a screen with 2 fields. One textbox
and one combobox
.
Value of textbox
being bind as below:
<TextBox Text="{Binding [someViewModel].person.name, Mode=TwoWay,
ValidatesOnDataErrors=True, ValidatesOnExceptions=True,
ValidatesOnNotifyDataErrors=True}"
Now I have a ComboBox that get the list of value from database, says Yellow, Green, Blue
Below is the way I bind ComboBox
:
<ComboBox IsSynchronizedWithCurrentItem="True"
ItemSource="{Binding [someViewModel].ColorList}"
DisplayMemberPath="ColorName" SelectedValuePath="ColorID"
SelectedValue="{Binding [someViewModel].person.ColorID}"
My problem now is when I load the page, the default selected value will be based on [someViewModel].person.ColorID
but it's showing empty instead. There are values in the ComboBox. When I debug it, there are value in [someViewModel].person.ColorID
but it just wouldn't show?
When I change the value from Yellow to Green, the value will be reflected to [someViewModel].person.ColorID
as well which fits what I need