Hey, I am in a merge of a windows project to silverlight, and I had a combobox usercontrol that displays a datagrid:
So, I have now a combobox with a SL datagrid like this:
and the code is:
public class MyComboBox : ComboBox { public MyComboBox() { DefaultStyleKey = typeof(MyComboBox); } Popup popup; DataGrid g; public override void OnApplyTemplate() { base.OnApplyTemplate(); popup = ((Grid) VisualTreeHelper.GetChild(this, 0)).FindName("Popup") as Popup; if (popup != null) g = ((Border)((Canvas)popup.Child).Children[1]).Child as DataGrid; g.SelectionChanged += g_SelectionChanged; g.MouseLeftButtonUp += g_MouseLeftButtonUp; }
void g_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { IsDropDownOpen = false; }
void g_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count == 0) SelectedIndex = 0; else SelectedItem = e.AddedItems[0]; } }
-----
So, I want to know if there is any way to do this with a XamWebGrid instead of DataGrid because I need to use the filtering feature, and then if it's possible use a infragistics combobox editor instead of a generic combobox.
Thanks in advance,
Paul.
Hi Paul,
What kind of problems are you having when you try to use the XamWebGrid?
As for using our ComboEditor, thats not going to be possible. As you're looking ore for a DropDown control, where as our XamWebComboEditor was made only for handling bound collections of data, specifically for type ahead, and filtering capabilities that the ms combobox lacked.
-SteveZ
Hi Stephen, well first I tried with the code I posted here, it works with the DataGrid because somehow the combobox has a DataGrid inside, but when I put there a xamwebgrid it doesn't work, so i was working with xaml templates without succed. Any ideas to achieve this?
Well, first, you don't need to create your own ComboBox.
You can simply add the Grid as an Item of the Comobox, like so:
<ComboBox. <ig:XamGrid ItemsSource={Binding Data}/></ComboBox>
For filtering, we need to create an instance of the object to allow for you to specify a value to filter on.
If your object doesn't have an empty ctor, you can use the DataObjectRequested to pass in an empty instance of your object.
Hi Stephen, so... I put the xamwebgrid in the combobox with a style, but now I have this problem: when I set the collection (of interfaces, obviously without empty constructor) for the ItemsSource property and with filtering options enabled, I got this error: "The object doesn't have an empty constructor" ... so why I do need an empty constructor if my grid is readonly??
I send you the sample project, it's using the 10.1 xamwebgrid.
Paúl