I'm using the following XAML to create a simple list of DayOfMonth values:
<ComboBox SelectedValue="{Binding DayOfMonth}" SelectedValuePath="/">
<ComboBoxItem>
<sys:Int32>1</sys:Int32>
</ComboBoxItem>
<ComboBoxItem>
<sys:Int32>2</sys:Int32>
</ComboBoxItem>
...
...
</ComboBox>
The problem is that it doesn't select correct item (in fact it doesn't select any) in the ComboBox when the underlying ViewModel has one assigned to DayOfMonth
property (property type is Int32
). I have tried it without <sys:Int32>
as well, i.e. directly using <ComboBoxItem>1</ComboBoxItem>
syntax, that doesn't work either.
Note: I'm looking for XAML-only solution.
Edit
Though it is not of much value, here is the property I'm binding my ComboBox to:
private int mDayOfMonth;
public int DayOfMonth
{
get { return mDayOfMonth; }
set
{
if (mDayOfMonth != value)
{
mDayOfMonth = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("DayOfMonth"));
}
}
}