I have a XamDatagrid that is filled from codebehind:
List<TiempoGridDTO> listaTiem = new List<TiempoGridDTO>();
dgvListadoTiempos.DataSource = listaTiem;
'TiempoGridDTO' is:
public class TiempoGridDTO { public int IdArea { get; set; } public string NombreArea { get; set; } public int IdAsunto { get; set; } public string NombreAsunto { get; set; } public int IdSubAsunto { get; set; } public string NombreSubAsunto { get; set; } public int? Minutos { get; set; } public DateTime? Fecha { get; set; } public string Glosa { get; set; } }
I want that the fields Area, IdAsunto, IdSubAsunto depend of each other.
If I select one Area, there´s n Idasunto´s. I made the xamDataGrid field layout like this:
<igDP:XamDataGrid x:Name="dgvListadoTiempos" IsUndoEnabled="True" GroupByAreaMode="MultipleFieldLayoutsFull" IsGroupByAreaExpanded="True" GroupByAreaMulti="{DynamicResource GroupByAreaMulti1}" ScrollViewer.HorizontalScrollBarVisibility="Visible" Margin="3,3,0,3" Background="#DDDEE3" Theme="Onyx"> <igDP:XamDataGrid.Resources> <!--Proveedores de items a los combos--> <igEditors:ComboBoxItemsProvider x:Key="StatusItemsProvider"/> <igEditors:ComboBoxItemsProvider x:Key="SubAsuntoItemsProvider"/> <igEditors:ComboBoxItemsProvider x:Key="AreaItemsProvider"/> <igEditors:ComboBoxItemsProvider x:Key="AjusteItemsProvider"/> <!--Estilos que aplican a una celda el combobox--> <!--Asuntos--> <Style x:Key="StatusFieldStyle" TargetType="{x:Type igEditors:XamComboEditor}"> <!--<Setter Property="ItemsProvider" Value="{StaticResource StatusItemsProvider}"/>--> <Setter Property="ItemsSource" Value="{Binding Source={StaticResource StatusItemsProvider}, Path=item1}"/> <EventSetter Event="igEditors:XamComboEditor.SelectedItemChanged" Handler="Asunto_SelectedItemChanged"/> </Style> <!--SubAsuntos--> <Style x:Key="EstiloSubAsunto" TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource SubAsuntoItemsProvider}"/> </Style> <!--Area--> <Style x:Key="EstiloArea" TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource AreaItemsProvider}"/> </Style> <!--Ajuste--> <Style x:Key="EstiloAjuste" TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource AjusteItemsProvider}"/> </Style> <!--CheckBox--> <Style x:Key="EstiloCheck" TargetType="{x:Type igEditors:XamCheckEditor}"/> </igDP:XamDataGrid.Resources> <!--Edicion de Campos--> <igDP:XamDataGrid.FieldLayouts> <!--inicio--> <igDP:FieldLayout> <igDP:UnboundField Name="Chekeador" Label="" Width="40"> <igDP:UnboundField.Settings> <igDP:FieldSettings EditorStyle="{StaticResource EstiloCheck}" CellWidth="50" /> </igDP:UnboundField.Settings> </igDP:UnboundField> <!--fin--> <igDP:UnboundField Name="Cliente" Label="Cliente" Width="250"/> <igDP:Field Name="NombreAsunto" Label="Asunto"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource StatusFieldStyle}" CellWidth="150" LabelWidth="200" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="NombreSubAsunto" Label="Sub Asunto"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource EstiloSubAsunto}" CellWidth="200"/> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="NombreArea" Label="Area"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource EstiloArea}" CellWidth="100"/> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Minutos" Label="Minutos" Width="75"/> <igDP:Field Name="Glosa" Label="Glosa"> <igDP:Field.Settings> <igDP:FieldSettings CellWidth="300"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:ValueEditor}"> <Setter Property="ValueConstraint"> <Setter.Value> <igEditors:ValueConstraint MaxExclusive="50" MaxLength="50" MaxInclusive="50" /> </Setter.Value> </Setter> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:UnboundField Name="Idioma" Label="Idioma" Width="75"/> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> <!--Settings del Datagrid--> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False" AddNewRecordLocation="OnTopFixed" AllowAddNew="True" HighlightAlternateRecords="True"/> </igDP:XamDataGrid.FieldLayoutSettings> </igDP:XamDataGrid>
The combos actually are filled through ComboItems Providers, but I cant find the way to do what I wrote before. Also I want to use the ItemsSource Propertie, but I cant find a way to do it...
Please help
Hello,
It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. So I have been looking through you post and I created a sample project for you, where there are two XamComboEditors and the items in the second one depends on the selection of the first one. Basically I handled the SelectedItemChanged event of the first Editor and set the ItemsSource of the second one dynamically.
Feel free to write me if you have further questions.