Is there a way to set a ComboBox's default selected item?
In my round about away of trying to achieve this, I tried to use the Clear Selection Button, and overrode the Setter in my bound property (if value == null, use set value to default value). So in my model, it works fine, however, in the UI layer it doesn't, as the selected item is null (even thou the bound value is correct)
i.e. The control doesn't update correctly
e.g. If I have it bound to a collection of strings
{ bill, john, maxine }
And John is currently selected, but Maxine is the default.
In my properties setter I would so something like this
newValue = value;
if (newValue == null) newValue = default; (where default is Maxine)
...
RaisePropertyChanged...etc.
Now if I call from codebehind, property = null
It will correctly set the property to the default value, and the Combo box will properly select Maxine
However, if I click the clear selection button, it will set the value to null, which thus causes the value to be set to Maxine, BUT, the control still has it's currently selected item to null
i.e. I suspect your control does this when you clear selection
*set binded property to null
*privately set selected item to null - and do not persist changes to binding
Is it possible that you could rectify this in a future version?
(e.g. privately set selected item to null, then set binded property to null)
In my round about away of trying to achieve this, I tried to use the Clear Selection Button, and overrode the Setter in my bound property (if value == null, use set value to default value). So in my model, it works fine, however, in the UI layer it doesn't, as the selected item is null (even thou the bound value is correct)
i.e. The control doesn't update correctly
e.g. If I have it bound to a collection of strings
{ bill, john, maxine }
And John is currently selected, but Maxine is the default.
In my properties setter I would so something like this
newValue = value;
if (newValue == null) newValue = default; (where default is Maxine)
...
RaisePropertyChanged...etc.
Now if I call from codebehind, property = null
It will correctly set the property to the default value, and the Combo box will properly select Maxine
However, if I click the clear selection button, it will set the value to null, which thus causes the value to be set to Maxine, BUT, the control still has it's currently selected item to null
i.e. I suspect your control does this when you clear selection
*set binded property to null
*privately set selected item to null - and do not persist changes to binding
Is it possible that you could rectify this in a future version?
(e.g. privately set selected item to null, then set binded property to null)