I am creating the ComboBoxItemsProvider in XAML:
<igDP:XamDataGrid.Resources> <igEditors:ComboBoxItemsProvider x:Key="PhoneTypes" /> </igDP:XamDataGrid.Resources>
I am getting a reference to the items provider:
ComboBoxItemsProvider ItemsProvider = this.PhoneGrid.FindResource("PhoneTypes") as ComboBoxItemsProvider;
I am filling a ComboBoxItemsProvider with a sorted data view (from a data table):
ItemsProvider.ItemsSource = dt.DefaultView;
I am setting the display and value paths:
ItemsProvider.DisplayMemberPath = 'Name'; ItemsProvider.ValuePath = 'PhoneTypeKey';
The problem is that the value (PhoneTypeKey) is being displayed instead of the Name field as designated by the DisplayMemberPath property. If I click into the cell, the value property is correctly replace (visually) by the display property. How do I get the DisplayMember to display when the cell does not have the focus?
Thx,Tom
This stuff is not easy to learn. There seems to be several ways to do anything and I constantly seem to be attempting to implement 1/3 of each at any given time.
Maybe some day we'll laugh at how we floundered with such simple concepts.
Wow, thanks for replying to another one of my posts :-)
I apologize for not coming back here sooner and updating this one, but I have something very similar to what you have now. It was not working, but then I started working on the popup control I mentioned in the other forum post you replied to. For whatever reason, when I created new ComboBoxes in the popup form bound to the same ObjectDataProvider as my xamComboBoxes in the grid everything magically started to work with no further code changes to the grid xaml.
So I'm not sure why it works now and did not work before, but I'm certainly not complaining!
I struggled with this issue several weeks back. I even contacted support. I can't remember the details, but I ended up with this:
<igDP:Field Name="MultumRoute" Label="Route" > <igDP:Field.Settings> <igDP:FieldSettings EditAsType="{x:Type Domain:MultumRoute}" EditorType="{x:Type igDE:XamComboEditor}" > <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igDE:XamComboEditor}"> <Setter Property="DisplayMemberPath" Value="Name" /> <Setter Property="ItemsSource" Value="{Binding Source={StaticResource multumRouteDropDownDataSource}, Mode=OneWay}" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings></igDP:Field>
As an additional side effect of this behavior, I've noticed that the AddRecord functionality becomes broken- From my example above, when I select a Location from the xamComboEditor, I'd expect it to attempt to put the ID value (an integer) into the underlying object, based on the ValuePath setting. However, when I use the AddRecord and attempt to tab out of the Location column after selecting a choice from the xamComboEditor, I receive an error trying to convert a string to an integer.
Edit:
This comment is inaccurate- I discovered that I had the EditAsType setting wrong- should have been sys:Int32 instead of sys:String. This actually refocuses my problem/question quite well. The add record works as you'd expect now, and any added records work correctly. The xamComboEditor will also display correctly if I CHANGE the selected value in the Location column. The problem seems to be that the xamComboEditor is not selecting the appropriate item when the grid is initially databound. Sorry for the confusion and multiple posts.
I'm experiencing the same issue with xamComboEditor inside a xamDataGrid. I've set the DisplayMemberPath and ValuePaths, but they only seem to be used when that particular cell has focus.
I've got this as a resource for the window:
<igEditors:ComboBoxItemsProvider x:Key="locationItems" DisplayMemberPath="Name" ValuePath="ID" ItemsSource="{Binding Source={StaticResource Locations}}" />
Where Locations is an ObjectDataProvider, and this as my field declaration in the xamDataGrid:
<igDP:Field Name="LocationID" Label="Location"> <igDP:Field.Settings> <igDP:FieldSettings EditAsType="{x:Type sys:String}" EditorType="{x:Type igEditors:XamComboEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource locationItems}"/> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings></igDP:Field>
I believe I've followed all of the examples, but I must be missing something. Has anyone overcome this issue?
Thanks for feedback
Mike