Hi,
how can i embed the xamcomboeditor multiselect in xamDataGrid, with the SelectedItemChange event of the combobox in place.
We are using Infragistics.Controls.Editors this control.
Regards,
Rajiv
Can sombody from infragistics plese reply, i am in Midway, and this delivery is very urgent.
You can always use a template column and in the data template include the Combo Editor.
Hi I have tried to put an template column, but not able to get the selected items in each of the grid row.
My code
<Window x:Class="XamDataGridMultiSelectCombo.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" xmlns:igDP="http://infragistics.com/DataPresenter" xmlns:ig="http://schemas.infragistics.com/xaml" xmlns:local="clr-namespace:XamDataGridMultiSelectCombo" xmlns:igEditors="http://infragistics.com/Editors"> <Grid> <Grid.Resources> <Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="cvp"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <ig:XamComboEditor Loaded="XamComboEditor_Loaded" DropDownOpening="XamComboEditor_DropDownOpening" CheckBoxVisibility="Visible" ItemsSource="{Binding}" AllowMultipleSelection="True" ></ig:XamComboEditor> <!--<igEditors:XamComboEditor Name="xamComboEditor" ItemsSource="{Binding Path=items}" > <igEditors:XamComboEditor.Resources> <DataTemplate DataType="{x:Type local:Flag}"> <StackPanel Orientation="Horizontal"> <CheckBox IsChecked="{Binding Path=IsChecked}" VerticalAlignment="Center" /> <TextBox Margin="4" Text="{Binding Path=Name}" VerticalAlignment="Center" /> </StackPanel> </DataTemplate> </igEditors:XamComboEditor.Resources> </igEditors:XamComboEditor>--> </ControlTemplate> </Setter.Value> </Setter> </Style> </Grid.Resources> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <igDP:XamDataGrid DataSource="{Binding}" Name="xamDataGrid1" VerticalAlignment="Top" > <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:Field Name="LastName"> <igDP:Field.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource cvp}"/> </igDP:Field.Settings> </igDP:Field> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid> <Button Grid.Row="1" Click="Button_Click"/> </Grid></Window>
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using System.ComponentModel;using System.Collections.ObjectModel;using Infragistics.Windows.DataPresenter;using Infragistics.Controls.Editors;
namespace XamDataGridMultiSelectCombo{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public ObservableCollection<Person> coll { get; set; } ObservableCollection<Flag> items = new ObservableCollection<Flag>(); public MainWindow() { InitializeComponent();
coll = new ObservableCollection<Person>();
coll.Add(new Person() { Id = 1, LastName = "Doe", IsSelected = true }); coll.Add(new Person() { Id = 2, LastName = "Doe", IsSelected = true }); coll.Add(new Person() { Id = 3, LastName = "Doe", IsSelected = true }); coll.Add(new Person() { Id = 4, LastName = "Smith", IsSelected = true }); this.DataContext = coll; items.Add(new Flag { Name = "item1", Value = true, IsChecked = false }); items.Add(new Flag { Name = "item2", Value = true, IsChecked = false }); items.Add(new Flag { Name = "item3", Value = false, IsChecked = true }); items.Add(new Flag { Name = "item4", Value = true, IsChecked = false }); }
void CVPLoaded(object sender, RoutedEventArgs e) { List<ComboData> data = new List<ComboData>(); data.Add(new ComboData() { Data = "Item1" }); data.Add(new ComboData() { Data = "Item2" }); data.Add(new ComboData() { Data = "Item3" });
DataTemplate dt = new DataTemplate(); FrameworkElementFactory spFactory = new FrameworkElementFactory(typeof(XamComboEditor)); spFactory.Name = "myComboFactory"; spFactory.SetValue(XamComboEditor.ItemsSourceProperty, data); spFactory.SetValue(XamComboEditor.DisplayMemberPathProperty, "Data"); //spFactory.SetValue(XamComboEditor.CheckBoxVisibilityProperty, System.Windows.Visibility.Visible); //spFactory.SetValue(XamComboEditor.AllowMultipleSelectionProperty, true);
dt.VisualTree = spFactory; (sender as CellValuePresenter).ContentTemplate = dt; } private void XamComboEditor_Loaded(object sender, RoutedEventArgs e) { List<ComboData> data = new List<ComboData>(); data.Add(new ComboData() { Data = "Item1",IsSelected=true }); data.Add(new ComboData() { Data = "Item2", IsSelected = false }); data.Add(new ComboData() { Data = "Item3", IsSelected = true }); ((XamComboEditor)sender).ItemsSource = data;
}
private void XamComboEditor_DropDownOpening(object sender, CancelEventArgs e) { //int a = ((XamComboEditor)sender).di;
private void Button_Click(object sender, RoutedEventArgs e) {
// XamComboEditor val =(XamComboEditor) xamDataGrid1.FieldLayouts[0].Fields[0].Settings.EditorType;// typeof(XamComboEditor); //(xamDataGrid1.Records[0] as DataRecord).Cells[0].Value.ToString(); // (xamDataGrid1.DataItems[0] as DataRecord).Cells[0].ToString(); //val. foreach (var item in xamDataGrid1.FieldLayouts) { } }
public class Flag { public string Name { get; set; } public bool Value { get; set; } private bool isChecked; public bool IsChecked { get { return isChecked; } set { isChecked = value; } }
public Flag() { } } public class Person : INotifyPropertyChanged { private int id;
public int Id { get { return id; } set { id = value; NotifyPropertyChanged("Id"); } }
private bool isSelected;
public bool IsSelected { get { return isSelected; } set { isSelected = value; NotifyPropertyChanged("IsSelected"); } }
private String lastName;
public String LastName { get { return lastName; } set { lastName = value; NotifyPropertyChanged("LastName"); } }
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(info)); } }
public class ComboData : INotifyPropertyChanged { public String Data { get; set; } private bool isSelected;
public bool IsSelected { get { return isSelected; } set { isSelected = value; NotifyPropertyChanged("IsSelected"); } } public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(info)); } } }}
I have tried every thing, but still not able to get the value.
And also How would i show the default selected values in xammultiselect combobox in grid for each rows.
Please reply, if It can be done or not or should we remove the infragistics controls and suggest some other 3rd party controls to client, its a urgent requirement, and nobosy from your team is able to help me....!
Hello Rajiv,
I have been looking into your question and I am attaching a sample application for you, that shows how you can create custom class that derives from ValueEditor and uses XamComboEditor that allows multiple selection. The property for the Field in the XamDataGrid should be a Collection and should have its IsExpandable property set to False. Selecting/deselecting item from the ComboEditor, it is adding/removing the item from the value of the cell which the editor is editing. This approach is discussed also in the following forum thread: http://www.infragistics.com/community/forums/p/86076/430939.aspx.
Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir, MCPD
Developer Support Supervisor - XAML
Infragistics
www.infragistics.com/support
I am just checking if you require any further assistance on the matter.