Hello,
my XamComboEditor is created using a Binding for it's ItemsSource Property and it's SelectedItem Property. When initializing the XamComboEditor the default SelectedIndex, which is -1, is set and my bound property is set to null.
When interacting with the XamComboEditor the value is set absolutely as expected. The problem just occurs on initialization.
I fixed the problem by setting the the correct item again, using Dispactcher.Invoke, but I really do not like to do this.
Is this a bug or did I incorrectly instantiate the XamComboEditor?
Thanks in advance,
Stef
Hi
Is there some update available for this issue, because I have the same problem?
Thanks
Daniel
Actually I was able to reproduce the issue so we can look into this. For now, it seems that if you add the tool before initializing the SelectedItem, it should work.
Sorry for the delay. So just to make sure I'm on the same page. Basically you have set the SelectedItem of the datacontext to an item in the list and the control is not starting off with that item being displayed as selected?
Hello Andrew,
here's my code:
ComboEditorTool comboBox = new ComboEditorTool();comboBox.DataContext = dataContext;Binding itemsSourceBinding = new Binding();itemsSourceBinding.Path = new PropertyPath(itemsSourcePath);comboBox.SetBinding(ComboEditorTool.ItemsSourceProperty, itemsSourceBinding);Binding selectedItemBinding = new Binding();selectedItemBinding.Path = new PropertyPath(selectedItemPath);comboBox.SetBinding(ComboEditorTool.SelectedItemProperty, selectedItemBinding);comboBox.Caption = label;// ... Then the comboeditor is put to the ribbon ...
The tool is bound to an object containing a list and a selected item out of this list.
This works fine, when setting the currently selected item by clicking the combobox. The problem is, that my selected item has a value when setting up the ComboEditorTool and I want the control to display this. The getter of the data bound objects selectedItem property is requested, but then it is set to null. I think this is, because the SelectedIndex of the ComboEditorTool is -1 by default.
I subscribed for the selectedItemChanged Event of the ComboEditorTool. The event is fired once on startup and sets the correct initial value to null.
I hope I could make it more clearly now :-)
Thanks in advance,Stef
I'm not sure I follow the issue you are encountering. Do you have a sample that demonstrates the problem you are having?