I have a XamComboEditor in my XamDataGrid that I've successfully put different options into, and you can change options via the dropdown box, etc etc etc bottom line is that it works.
Unfortunately there is one problem that is really annoying, and I have not been able to find an answer scouring these forums. I have a default value that shows up, "Auto". You can change from this option, and the change stays. Switching back, "auto" then stays.
HOWEVER, from the initial default value "Auto", if you select the combo box as if to change it, but don't select anything... you can then click twice outside the box (one to cancel selection and then again to do something else such as select a record in the grid), "Auto" disappears!!!
In my code, I do not change the value of the currently selected item if the selection is "null", which is what happens in this situation. I'm calling the appropriate RaisePropertyChanged() method, yet the visual combobox still changes :(
Is there any way to stop this from happening? Even repeated calls to RaisePropertyChanged() do not fix this. And as I said, this is only on the very first initial value. Once you've changed the selection everything works as expected. Any thoughts?
Hello,
Thank you for your post. I have been looking into it but it seems like I am missing something about your scenario, so if this is still an issue for you, could you please send me an isolated sample project, where this is reproduced, so I can investigate it further for you.
Looking forward for your reply.
Hi Stefan,
Thanks for looking into this for me. I don't really have time to create a sample app (would require a couple hours worth just to set up a similar MVVM project) since we're on a tight schedule here. Really, if this isn't a common combo box behavior I'm probably going to just try again to debug into it.
Cheers,
-Ryan-
Hey Stefan,
I'm sorry for not responding, I have this bookmarked as "todo"... I just haven't gotten the time to go back and look at this yet.
I'll let you know when I do!
Thanks,
Hello Ryan,
I am just wondering did you manage to achieve your goal or you need further assistance on this matter.
Hello again,
I took the couple hours today to whip up a sample of what I'm talking about. This is pretty close to what I have in my actual project, minus a couple layers of views haha.
In any case, I uploaded the sample program. Open this up and run it. The defaults for the combo boxes should be "One". Click the combo box as if you were going to change it, but instead of selecting anything click twice elsewhere, such as the value column. This will deselect the combo box and leave the combo box blank!
Try changing the values and then doing this. You will notice that the combo box now stays to whatever you last selected. Weird right?
Thanks for keeping on me about this. Just had to take the time to do it! Sorry to keep this issue open so long!
I have been looking into you sample project and I suggest you add the following Setter in your XamComboEditor’s Style in the “SampleView.xaml” file:
<Setter Property="ValuePath" Value="CurrentSelectedOption"/>
Please let me know if this helps you or you need further assistance on this matter.
Works like a charm, thank you! Do you have a minute to explain to me what this does and why it fixes the problem?
That looks like the winner! Thank you!
I can suggest you set the UnbondField's BindingMode to TwoWay and remove the setter for the SelectedItems. This way everything will work as you want. Please let me know if this helps you or you need further assistance on this matter.
I'm really sorry... I didn't spend enough time looking at this yesterday. Today though, I found that while this fixes the blank boxes (even while scrolling), this starts to set the value of every combo box to the first value of the options list!
Attached is a modified example. Run it and change the first couple options to "two" or "three" instead of one. Now, scroll down, and then scroll back up. The options have been reset to "one"!
When I debugged into it, there was nothing in the call stack, so I have no idea what could be causing this...
Thanks for keeping up with this problem,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Yes! That did it. Thank you Stefan, you are awesome!
If anyone else stumbles upon this, the answer is to set the unbound field's "BindingPath" property
<igDP:UnboundField Label="Type" Row="0" Column="2" Width="80" BindingPath="Type"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding DataItem.TypeList}"/> <Setter Property="SelectedItem" Value="{Binding DataItem.Type, Mode=TwoWay}"/> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:UnboundField>
: