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-
I will be glad to explain you. Since the CellValuePresenter’s Value Property is bound to the Editor’s Value of the Cell and the XamComboEditor’s Value is determined by its ValuePath this Property should be set, so everything could work as expected. You can read more about ValuePath here:
http://help.infragistics.com/NetAdvantage/WPF/2011.2/CLR4.0/?page=InfragisticsWPF4.Editors.v11.2~Infragistics.Windows.Editors.XamComboEditor~ValuePath.html
Hope this helps you.
Ahhh I understand, thank you! I'm sorry I had to bug you about this, but I had no idea I needed to set that property. I'm even more frustrated that I spent so many hours trying to fix this haha. Its always something small... oh well. Thanks again!
Hello Ryan,
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.
Hey,
So I hate to dig this up again, but I've noticed a problem with the proposed solution. This actually came up when I was using this same XamComboEditor idea with a different GUI, only this time with a lot of combo boxes (fills the screen top to bottom). At first I forgot to set the ValuePath, but instead of the disappearing values as in the previously posted example, I instead was seeing values just not loading when scrolled into view. I could scroll up and down and different combo boxes would be filled with the appropriate value each time - some would have them and some would not, and every time I scrolled up and down which ones had the value in it would change!
I thought this was strange, but noticed that I didn't set the ValuePath. So I set it, and just like before now all of the values are displayed as expected! However, my program is now running as slow as a snail. I took a look at the output and I see this:
System.Windows.Data Error: 40 : BindingExpression path error: 'CurrentSelectedConversionOption' property not found on 'object' ''String' (HashCode=-2122594931)'. BindingExpression:Path=CurrentSelectedConversionOption; DataItem='String' (HashCode=-2122594931); target element is 'ComboBox' (Name='PART_FocusSite'); target property is 'NoTarget' (type 'Object')
I went back to my previous program and it also has this error! I remember ignoring the error before because it didn't seem to affect my program at all, and the disappearing values were fixed, so I didn't care. In this new program, though, I can't accept this as the solution, because the errors are slowing my program down.
What seems to be happening is that for some reason, the bindings for the combo box editor aren't always updated when you scroll through a large list of them (or when you click off the value like in the previous program's example). When you set the ValuePath, however, it forces the bindings to try and update, which they do (hence why it fixes the problem), but because ValuePath isn't set to a correct value (after reading more on ValuePath, 'CurrentSelectedConversionOption' should not be correct because it's not a property of 'string') we get the error.
Is there an appropriate value to set ValuePath to that won't cause this error? I've tried wrapping up 'string' into a class, but not only is that hacky it also didn't work haha... I could have been doing something wrong though. In general though, it seems like the control should work as expected without having to set ValuePath, so something else is probably wrong...
Any ideas? Much appreciated,
I have modified the sample you attached before, so it works as you want. Basically I set the BindingPath of the UnboundField to CurrentSelectedOption and set the SelectedItem’s Binding to be TwoWay.
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.
Hey Stefan,
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,
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>
: