Hi. In the winforms version of your combobox there is a nice feature to be able to bind a dataset to the combobox to show a grid in the drop down. Is this available in the XamComboEditor. If not any ideas how to set this up?
Hello,
Basically, the XamComboEditor does not support this, but you could retemplate the ComboBoxDataItem's template and put a XamDataGrid inside, so that you can bind to a Collection,DataTable,etc.
<igEditors:XamComboEditor Name="xamComboEditor1">
<igEditors:XamComboEditor.Resources>
<DataTemplate DataType="{x:Type igEditors:ComboBoxDataItem}" >
<Grid>
<igDP:XamDataGrid x:Name="TextBlock" DataSource="{Binding Path=Value}" />
</Grid>
</DataTemplate>
</igEditors:XamComboEditor.Resources>
</igEditors:XamComboEditor>
Then create ComboBoxItemsProvider and add a ComboBoxDataItem, which Value property you can set to a DataTable,Collection,etc. Add the ComboBoxDataItem in the ComboBoxItemsProvider and set the ItemsProvider property of the XamComboEditor.
string[] values = new string[] { "value1", "value2", "value3" };ComboBoxDataItem cb = new ComboBoxDataItem();cb.Value = values;ComboBoxItemsProvider c = new ComboBoxItemsProvider();c.Items.Add(cb); xamComboEditor1.ItemsProvider = c;
Hope this helps.
Hey Alex. This is what I needed, thanks. Question. When I click the drop down it takes a second or two to actually drop down the grid. Does rendering the grid take that long? Do you have that problem? Thanks for your help on this..
Hi Alex. Couple more questions.
1. When I bind to a long list the combobox doesn't put a vertical scrollbar in. How can I do this?
2. How do I setup a template so that when I click a row lets say with 3 columns I then show the one value of a specific cell in the closed combobox?
Sorry for all the questions but I'm stimped.. Thanks again for the help...
@ 1) I have the scrollbar, I am not sure why you do not see it. If you have a sample application, please attach it to your next post.
@ 2) Using this approach, this would not be possible, because we retemplated the ComboBoxDataItem, and this would be the selected item (a XamDataGrid).
I suggest using the Default styles for the XamComboEditor, that we ship in the DefaultStyles directory in the Infragistics folder on your computer and retemplating the XamComboEditor's template.
Hi Alex. If I can't template the closed drop down to show a specific column then I'll have to take your suggestion and write a template for Combobox. I'm not sure what you mean by use the default style from XamComboEditor? Can you provide a sample? This is what I need to figure out. I guess I should have said in my first post. It doesn't need to be a grid in the combobox it just should "look" like a grid if possible.
Ideally what I would like is a combobox with say 3 columns in each comboboxitem. When I click one "row" it shows perhaps column 2. And when loading when I set the value from say column 1 it selects the correct row. Ideally it would have an aero theme/style to it. Then the last thing would be to somehow create or show a header "row" for each column at the top. I'm guessing that it isn't easy to put in the header column so for that I may need a workaround.
Thanks again for all your help..
So, as I promised.
Having in mind that you want to keep functionality such as theming, styling, I think it is best to stick with the XamDataGrid inside the XamComboEditor. Looking again at the scenario, one grid would suffice - this means one ComboBoxDataItem inside the ComboBoxItemsProvider, which Value would be the DataSource of the XamDataGrid.
The XamComboEditor has one XamDataGrid with several records. The CellClickAction is set to SelectRecord and when a record is selected, SelectedItemChanging event of the grid fires, and we set the Value of the XamComboEditor to this record's cell of choice (in my example index: [0]) and end its edit mode.
We have to use a converter(IValueConverter) for the DisplayText property, because we have retemplated the ComboBoxDataItem and we do not want the whole grid to appear as SelectedItem.
Regarding the headers, I suppose the labels of the grid is what you want to achieve.
I am attaching the sample and please do not hesitate to let me know if you have questions on this.
Hi Alex,
I am following your example how to solve XamComboEditor with dropdown grid. I have one question? How can I programatically say to Comb dropdown open?
I found IsDropDownOpen property, but it does not work. :(
Michal
It seems I have solved it.
It works in PreviewKeyUp handler. Can anybody explain why it does not work in PreviewKeyDown?
Sorry, It also works in the Alex´s example.
But not, where I am calling it.
I am setting property IsDropDownOpen = true in PreviewKeyDown handler and here it does not work.
I must correct and explain previous messages.
IsDropDownOpen Usually It works.
But not in this case, when is used DataTemplate for ComboBoxDataItem - ComboBoxDataItem is overwritten and includes XamDataGrid as is described in Alex´s example.
10.3.20103.2065 CLR4
Hi,
Which is the version of our product that you are using?
Thanks,
Anastas