I tried XamComboEditorStyle, but it binds combobox to entire field. Whereas I want to bind Combobox only to currently selected cell.
Please help.
Thanks.
Priya
Hello Priya,
I am somewhat unsure of what you are asking here to be honest. Do you mean that you want the XamComboEditor to be in the cell that you click? Or do you want the value that is in the cell to show up in the xamComboEditor?
Sincerely,AndrewDeveloper Support IInfragistics Inc.www.infragistics.com/support
Hello Andrew,
Thanks for reply.
I want XamComboEditor to be applied to the Cell which I clickeda and not the column.
Whenever I click on another cell, this cell should look as Text field and that other cell should have Combobox.
Currently, It gets applied to entire field i.e. all the cells in clicked cell's column.
Thanks,
To get a XamComboEditor into a field on cell click, I would recommend going into the field settings and writing a Style for the EditorStyle of the field. The style would be TargetType XamComboEditor.
After that, you will need two setters. One for Template and the other for EditTemplate. The Template in my attached sample is a textblock and the EditTemplate is the XamComboEditor.
I have attached a sample to demonstrate this.
Please let me know if you have any other questions or concerns.
Thank you for the quick reply.
This is exact the same thing I want. But I want to set the style from code behind as I am auto-generating all the fields.
I create a style:
Im xaml:
<igDP:XamDataGrid.Resources>
<Style TargetType="{x:Type igEditors:XamComboEditor}" BasedOn="{StaticResource {x:Type igEditors:XamComboEditor}}"> <Setter Property="ItemsProvider" Value="{StaticResource SymbolsItemsProvider}" /> <Setter Property="DropDownButtonDisplayMode" Value="MouseOver"/> </Style> </igDP:XamDataGrid.Resources>
In code behind:
Style xamComboEditorStyle = new Style(typeof(XamComboEditor)); Setter itemsProviderSetter = new Setter(XamComboEditor.ItemsProviderProperty, SymbolsItemsProvider); xamComboEditorStyle.Setters.Add(itemsProviderSetter);
and bind it to cell when cell on _EditModeStarting event so that on cell click it is shown as combobox.
Can you please tell me how to set Template and EditTemplate properties from code behind?
I have attached a sample that demonstrates how to set a XamComboEditor’s Template and EditTemplate from code-behind. The option that I have chosen to demonstrate this is to use var type variables and set them to a new FrameworkElementFactory(typeof(depending on which template, type here)); The Template and EditTemplate are both ControlTemplates.
Then you set that var to the visual tree property of the corresponding ControlTemplate.
Hi Andrew,
Thank you again.
But it did not resolve my problem because As mentioned earlier, I have blank cells (from DataTable row which I bound to my XamDataGrid ) whose style I change to XamComboEditor in editModeStarting.
Is there any way to create a XamComboEditor style using Template and EditTemplate properties from code behind? Or is there any way in which I can use your code in edit mode starting to apply it to my selected cell?
I would not recommend setting the Editor in the Cell’s EditModeStarting event as it may be difficult getting the XamComboEditor to open, and you would have to handle the even EditModeEnding to get the XamComboEditor back to a TextEditor. Instead, I would recommend handling the CellValuePresenter’s PreviewMouseDown event, and set it there using a Style with a Trigger for IsInEditMode = true.
I have attached a sample demonstrating this being done in code-behind.
Please let me know if you have any other questions or concerns on this matter.
Thanks for help. It is working as expected now.
Thanks a ton!!
In the constructor for the binding, you want the property name that you are binding to rather than the list’s name.
In the sample I had sent you, the binding was new Binding(“FoodType”){ } . In my data source, FoodType was a property in it, not the name of the collection.
If your data source itself is a List of chars, then the Binding will look like the following:
Binding B = new Binding(“Value”);B.RelativeSource = RelativeSource.TemplatedParent;
How do I set Binding for 'C' if I am using List of chars?
It is not recognizing anything if mention ListName in Binding like:
Binding C = new Binding("micrSymbols"); C.Source = CVP.Record.DataItem;
Here is an article about binding event handlers to FrameworkElementFactory elements : http://social.msdn.microsoft.com/Forums/vstudio/en-US/a79b62ce-ce36-4234-93d9-f2ed570176ff/frameworkelementfactory-addhandler.
However, I have found a better way to stop the reversion than handling the SelectedItemChanged event. Instead, I made a binding to the XamComboEditor.SelectedItemProperty. In the binding, it binds to the property name, and then the source is set to ((DataType)CellValuePresenter1.Record.DataItem).
I have attached a sample application demonstrating this.
How do I add SelectedItemsChanged event to Event Handler when I create XamComboBox like:
var XCE = new FrameworkElementFactory(typeof(XamComboEditor));
XCE.SetBinding(XamComboEditor.ItemsSourceProperty, new Binding() { Source = micrSymbols}); XCE.SetBinding(XamComboEditor.DisplayMemberPathProperty, new Binding("Value"));
Sorry to have so many questions as I am new to this technology.
Thanks in advance!
-Priya