Hi:
I'm trying to implement what seems like it would be a common scenario, but I can't find a straightforward example. If such an animal exists, feel free to point me to it.
I need to bind a XamDataGrid with some of its cells containing a XamComboEditor with the XamComboEditor's ItemFilter set to Contains.
My window's datacontext is set to my viewmodel. My viewmodel exposes properties for:
IEnumerable<Thing> ThingList
IEnumerable<Model> ModelList
Model CurrentModel
Thing -- the items to which the grid will be bound -- has properties for:
string Name
string ModelId
DateTime ShippedDate
Model has properties for:
string Id
So... I need to bind the grid to ThingList. I've set DataSource="{Binding Path=ThingList}" in the grid's definition in XAML and that binds like I'd expect. The auto-generated columns (which I'll need to get rid of) display fine and show Thing's ModelId as a string.
I need the Thing's ModelId column to display a XamComboEditor bound to ModelList with the appropriate settings (or the equivalents) for DisplayMemberPath, SelectedValuePath, SelectedItem, and SelectedValue.
I have this working in a single record scenario with a XamComboEditor defined as:
<ig:XamComboEditor x:Name="myThingList" Grid.Column="1" Grid.Row="1" Height="20" ItemsSource="{Binding Path=ModelList}" DisplayMemberPath="Name" SelectedValuePath="Id" SelectedItem="{Binding CurrentModel}" Padding="4,0" SelectedValue="{Binding Path=CurrentModel.Id}" />
(Also, I had to define the Contains filter in the code behind. I think I can move that into the XAML by adding xmlns:igDm="http://infragistics.com/DataManager" since the code behind told me I was missing that reference when I used the code from another example. We'll see.)
Any help would be appreciated.
Thanks,
Mark
Hello Mark,
In order to have XamComboEditor displayed in a XamDataGrid field you can set the EditorType of that field to be XamComboEditor. Krasimir has provided a sample application in the following forum thread that illustrates how it could be achieved: http://www.infragistics.com/community/forums/t/63525.aspx.
I have made a couple of changes to that sample to make sure it is up to date with the latest version. - The assemblies were updated to version 15.2.- The UnboundField is actually modified to Field with BindingType set to Unbound. This change was made because the UnboundField has been marked as obsolete since version 14.2 - http://help.infragistics.com/Help/Doc/WPF/2015.2/CLR4.0/html/xamDataPresenter_Add_Unbound_Fields_to_a_DataPresenter_Control.html
Please feel free to let me know if you have any questions or need further assistance on the same.
That's the one I tried initially.
When I add the line:
<igDP:FieldLayout Key="Expanded">
the markup is invalid and I get the error message: FieldLayout is not supported in a Windows Presentation Foundation (WPF) Project.
Am I missing a namespace? I have:
xmlns:igEditors="http://infragistics.com/Editors" xmlns:igDp="http://infragistics.com/DataPresenter"
Am I missing a reference? I have (some are obviously unrelated):
InfragisticsWPF4.Controls.Editors.XamColorPicker.v15.2
InfragisticsWPF4.Controls.Editors.XamComboEditor.v15.2
InfragisticsWPF4.Controls.Editors.XamSlider.v15.2
InfragisticsWPF4.DataManager.v15.2
InfragisticsWPF4.DataPresenter.v15.2
InfragisticsWPF4.Editors.v15.2
InfragisticsWPF4.v15.2
Obviously, I'm doing something wrong or missing something, but it's not exactly clear to me what that might be. There certainly aren't any namespaces or references in the example project that I am not also using, so I'm baffled and more than a little frustrated that the example code is showing errors for me on something that seems like it should just work.
-- Mark
Hi again:
OK, I removed all of the Infragistics namespaces from my XAML. I removed all of the Infragistics assemblies from my references. I restarted VS2015. I added back the Infragistics namespaces and assemblies and the markup errors are gone. Not sure why it was broken like that, but that issue is gone. So, progress.
I looked at the project from the link you gave me. After messing around with the Binding Path to get at the DataContext for my window, I am able to populate the combo. That was nice. More progress.
The issue I am left with at this point is trying to get the SelectedItem worked out so that the current value for each record is selected (obviously). When I was working with individual records, my viewmodel had a CurrentRecord property so that SelectedItem="{Binding CurrentItem}" was cake. How do I get at the SelectedItem in the context of the grid?
My viewmodel has ObservableCollection<Item> ItemList property, and that's what I'm binding to the combo. Obviously I need something like SelectedItem="{Binding ItemList.Item}", but I'm not sure how to get to that while binding in a grid.
Thanks for your help so far. This should probably be the easiest question of the bunch.
Hi Mark,
The SelectedItem can be set using index as the item is in the ItemList collection. In the sample I have attached to select “Clinic 2” it should be like this for the Clinics field <Setter Property="SelectedItem" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type igDP:CellValuePresenter}}, Path=Record.DataItem.Clinics[2]}" /> Here is a modified version of the sample as well.
Hi again,
I just noticed that you have added on more update to the thread just before my last answer.The WPF XamComboEditor does not provide functionality auto-complete. The cross-platform XamComboEditor and XamMultiColumnComboEditor (located in the InfragisticsWPF4.Controls.Editors.XamComboEditor assembly) have that functionality. The auto-complete is allowed when AutoComplete="True". You may refer to the following forum thread where a sample with XamDataGrid was provided: http://www.infragistics.com/community/forums/t/64041.aspx
Perhaps I should have been more specific when I wrote in the original post that I need the functionality to include "the XamComboEditor's ItemFilter set to Contains" and put "filtering" in the post title.
I thought since the ComparisonCondition was a child of ComboItemFilter I was describing it correctly. My apologies. I'm not sure what a better way to indicate which XamComboEditor I meant.
I am using the InfragisticsWPF4.Controls.Editors.XamComboEditor assembly in my single-record pages. I suppose I should be more aware of which control is getting placed on the page when I drag from the toolbox.
I'll take a closer look at the link you provided, butt seems like adding an autocomplete combo to a grid would be a pretty common scenario that would have easier to find documentation and fewer hoops to jump through. I've been wrong a time or two in the past, though. :)
Thanks again for your help.
You are welcome. Please feel free to let me know if you need further assistance on the same.