Hi there,I need in my XamDataGrid some XamComboBoxes with AllowMultipleSelection=true and I've found in your forum a topic with an uncompleted solution that could offers a way to solve my issue. In http://www.infragistics.com/community/forums/t/87945.aspx Andrew Goldenbaum describe need of custom style and template for the CellValuePresenter and add the XamComboEditor from the Shared XAML reference. But this is for XamDataCard. I want to insert this in my usercontrol.resource part. Here my XAML:<Style x:Key="MultiSelectorFieldSwitches" TargetType="{x:Type igWPF:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <ig:XamComboEditor AllowMultipleSelection="True" CheckBoxVisibility="Visible" DisplayMemberPath="@text" SelectedValuePath="@value" ItemsSource="{Binding Source={StaticResource SwitchesXml}}"/> </ControlTemplate> </Setter.Value> </Setter></Style>and in XamDataGrids FieldLayout<igDP:Field Name="Switch" Label="Schalter"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource MultiSelectorFieldSwitches}" /> </igDP:Field.Settings></igDP:Field>But there is the error "FieldSettings.EditorStyle's TargeType setting can only be null or a type that derives from ValueEditor or is a BaseClass of ValueEditor, CellValuePresenter is invalid.".I've read in the styling points for XamDataGrid in your online documentation 2014.2 that CellValuePresenter is the target of custom styles for XamDataGrid. What do I have to reference as target or is it false in general?If I try following XAML-Code <igDP:TemplateField Name="Switch" Label="Schalter"> <igDP:TemplateField.DisplayTemplate> <DataTemplate> <ig:XamComboEditor SelectedItems="{igEditors:TemplateEditorValueBinding}"/> </DataTemplate> </igDP:TemplateField.DisplayTemplate> <igDP:TemplateField.EditTemplate> <DataTemplate> <ig:XamComboEditor AllowMultipleSelection="True" CheckBoxVisibility="Visible" ItemsSource="{Binding Source={StaticResource SwitchesXml}, XPath=/Switches/Switch}" /> </DataTemplate> </igDP:TemplateField.EditTemplate></igDP:TemplateField>MultiSection and CheckboxVisibility works for me, but only the visibility, not the realy items. I can only see the word "Switch" for each of all items, is this a binding issue? And also XAML for DisplayTemplate is bad because change focus on another field text of that field disappear.I hope on you, thank you in advanceAndreas
Hello Andreas,
Thank you for your post.
The style that you have above that targets the CellValuePresenter is not working because you are trying to apply it to the EditorStyle property on the Field's FieldSettings. You should try applying the style to the CellValuePresenterStyle property instead.
Regarding the TemplateField, this way should work as well, but from simply looking at the code you have provided I cannot tell why the item visibility is not working correctly. I believe it is likely due to the SelectedItems binding to TemplateEditorValueBinding. This is more meant for the XamComboEditor in the Editors namespace, which derives from ValueEditor.
For the time being, I would recommend using the CellValuePresenterStyle. In the meantime, I will be investigating into what the issue is with the TemplateField. Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Hi Andrew,
thank you for reply. Yes, your tip with CellValuePresenterStyle for first variant works, but probably databinding isn't right. There is a ComboEditor with one empty item, Checkbox is shown. In my XAML Code is following XMLDataProvider and that works for me in a previous version as I use igEditors:XamComboEditor but without MultipleSelection.
<XmlDataProvider x:Key="SwitchesXml">
<x:XData>
<Switches xmlns="">
<Switch text="S0" value="S0" />
<Switch text="S1" value="S1" />
</Switches>
</x:XData>
</XmlDataProvider>
But now it isn't so. Sure, now I use another object. Properties false? Binding false? I don't no.
For second variant: From previous Versions in my MVVM is Switch (you know <igDP:TemplateField Name="Switch" Label="Schalter"> ) from datatype string. Could it be that now there have to be another datatype, for instance ObservableCollection?
Thank you for your efforts!
Andreas
I've forgotten right setting of itemssource for variant one. XAML Code now
<Style x:Key="MultiSelectorFieldSwitches" TargetType="{x:Type igWPF:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <ig:XamComboEditor AllowMultipleSelection="True" CheckBoxVisibility="Visible" DisplayMemberPath="@text" SelectedValuePath="@value" ItemsSource="{Binding Source={StaticResource SwitchesXml}, XPath=/Switches/Switch}"/> </ControlTemplate> </Setter.Value> </Setter></Style>
And now I can see exactly that number of items that realy in my XML, unfortunately not @text (means Content of) but the text "Switch". Also with this variant now text "Switch,Switch,Switch" will be shown if I check three checkboxes and field lost focus, thats absolutly great, MultipleSelection is working now! But what is the failure in Binding? Would it work better if I create an IEnumerable object and bind it in XAML in following manner
ItemsSource="{Binding Source={StaticResource mylocal:enumSwitches}} ???
My question regarding MVVM and selecteditems of XamComboEditor is relevant.
Best regards
I apologize for the delay in my response, but I believe I have some information for you now.
There is nothing wrong with the binding that you are setting up here, but it is currently binding to an XmlNode object for each of the XamComboEditor objects. These XmlNodes expose an Attributes collection, which will contain your text and value properties on your Switch. The index of these properties appears to be proportionate to the order that the properties are added. So, if you were to set the DisplayMemberPath on your XamComboEditor to Attributes[0].Value, it would be pointing to the text property's value, and it would display that in the drop-down.
Please let me know if you have any other questions or concerns on this matter.
simply great! It works, I can see s0, s1 and so on! Sure, in meantime I've spended more time on other Projects, some on this, but without Progress. And now after awaiting your replay that success! Thank you.
Sorry, but there is next issue. I've thought in past Field "Switch" was type string and simply I Change type on ObservableCollection(Of String). You know, in my View are XamDataGrids, in ViewModel ObservableCollections(Of <object>), also observableCollections(Of object>) in Model. Previous in the object in Model Switch was a string. Now I've changed that type I described, because infragistics documentation say SelectedValues gets result of users choise in an object array. But in debug mode field has value nothing. And now I need your howto! In XAML now
DisplayMemberPath="Attributes[0].Value"
SelectedValuePath="Attributes[1].Value"
SelectedValues="{Binding}"
ItemsSource="{Binding Source={StaticResource SwitchesXml}, XPath=/Switches/Switch}">
I thought, implizit binding will be made on field Name "Switch" from type ObservableCollection, because object is bound on DataContext of XamDataGrid and within Switch. But if I start application there is no record in DataGrid, not even line for add record. And now I have to state I need a tip for next step.
There is another way, I would mean: If I try a setter of CellValuePresenter for property "Content" and convert list of values to string? I don't know, what do you say?
But I would prefer first solution, I think ist the better one.
Please let me know your advice, many thanks!
Best regards, Andreas
I've another offer for my issue and I want to ask you. I think regarding Content of CellValuePresenter there have to be changing. My XAML:
<Setter Property="Content">
<Setter.Value>
<ig:XamComboEditor SelectedValues="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Switch}" />
</Setter.Value>
</Setter>
Could this be a way for binding CellValuePresenters Content to the field of XamDataGrid? I hope, thats a deeper technical understanding at this point?
Thanks for reply.
Kind regards.
I would not so much recommend setting the Content property of the CellValuePresenter as I would the ContentTemplate property, since setting Content will make the XamComboEditor the actual content of the cell, whereas the ContentTemplate will make the XamComboEditor the displayer of the content of that cell.
Regarding your other post, the SelectedValues binding will not work unless you are setting the DataContext of the XamComboEditor to an array. The SelectedValues property on the XamComboEditor expects an object array, which is why you are likely seeing an error when trying to make this binding. I have to admit, I'm a bit unsure what you are referring to about the implicit bindings on the field and why your XamDataGrid is not showing anything. Generally, this means that the fields are not set up correctly in the grid, as the field names need to correspond with a property on the dataItem in your bound collection to the XamDataGrid. If a field's name does not, you will not see any fields in the grid.
As a bit of an aside, I have come across another forum thread where a very similar issue to this one has been discussed. I recommend that you take a look at it: http://www.infragistics.com/community/forums/t/64926.aspx.
Just checking in, did you have any other questions or concerns on this matter?
thanks for your concern. Well, in Germany last days was Easter, some days without programs, but now it's going on.
Your last suggestion was working with contenttemplate, because property Content of cellvaluepresenter, right? I mean I've understood difference of presentation and data processing, but it's difficult for me to identify objects to work with (provided that I'm right, possible thats wrong) Here my XAML
<Setter Property="ContentTemplate">
<DataTemplate>
<ContentPresenter Content="{Binding Path=???}" />
</DataTemplate>
Could it be that I have to make binding in datatemplate in following manner:
<ig:XamComboEditor SelectedValues="{Binding RelativeSource={RelativeSource TemplatedParent},Converter={StaticRecource conv}}" /> with implementing of IValueConverter or IMultiValueConverter because Switch is of data type string in my Model?
I think selectedValues has data of the user selection.
I've tried to find similar example in infragistics forum and in infragistics sample browser and also I check your url but at the moment I see solution far away.... I've also used WPFInspector but its tricky ...
I think there is the possibility to going on with your help. Thank you in advance.
Best regards.