Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
622
Bind some columns to a dynamic collection.
posted

Hello,

I have a XamDataGrid with a list of equipments, and I need to set a range of columns with DateTime in header (based on a period set by user filter) and a mark on equipment row below the date when the equipment broke down.  In my ViewModel I have a collection with the selected dates, and a list of equipments, each one contains a list of string (blanck or 'x') of same size than my list of dates.


I would like to do like this: Sample with datagrid , but I have not yet found how to implement that with XamDataGrid.  I prefer not to use code behind.

Any ideas ?

Patrick

current XamDataGrid:

 

 <igDP:XamDataGrid x:Name="DefectSynthesisDataGrid" Grid.Row="0" DataSource="{Binding MatchedDefectsSynthesis}" Margin="2,0,2,2">
                       
                        <igDP:XamDataGrid.FieldSettings>
                            <igDP:FieldSettings Width="Auto" AllowEdit="False" AllowRecordFiltering="True" CellClickAction="SelectRecord"
                                    SummaryDisplayArea="BottomFixed" />
                        </igDP:XamDataGrid.FieldSettings>
                        <igDP:XamDataGrid.FieldLayoutSettings>
                            <igDP:FieldLayoutSettings CopyFieldLabelsToClipboard="True" AllowAddNew="False" AllowDelete="False" AllowFieldMoving="Yes" AllowRecordFixing="No" AutoGenerateFields="False" AllowClipboardOperations="Copy" HeaderPrefixAreaDisplayMode="FieldChooserButton" SelectionTypeRecord="Extended" ExpansionIndicatorDisplayMode="Default" />
                        </igDP:XamDataGrid.FieldLayoutSettings>
                        <igDP:XamDataGrid.FieldLayouts>
                            <igDP:FieldLayout>

                                <igDP:UnboundField Name="MeterId" Column="3" Width="Auto" BindingPath="Meter.MeterId.DataValue" Label="N° de l'équipement"  FixedLocation="FixedToNearEdge"/>
                                <igDP:UnboundField Name="MeterName" Column="4" Width="Auto" BindingPath="Meter.MeterName.DataValue" Label="Libellé de l'équipement"  FixedLocation="FixedToNearEdge"/>

                                <igDP:UnboundField Name="MeterType" Column="5" Width="Auto" BindingPath="Meter.MeterType.DisplayLabel" Label="Type"  FixedLocation="FixedToNearEdge"/>

                                <igDP:UnboundField Name="EmergencyLevel" Column="6" Width="Auto" BindingPath="UserDefectMeter.EmergencyLevel.DataValue" Label="Urgence" Converter="{StaticResource EmergencyTypeToDisplayNameConverter}"   FixedLocation="FixedToNearEdge"/>
                                <igDP:UnboundField Name="DefectCode" Column="7" Width="Auto" BindingPath="UserDefectMeter.DefectMeter.DefectCode" Label="Code défaut"  FixedLocation="FixedToNearEdge"/>
                                <igDP:UnboundField Name="DefectName" Column="8" Width="Auto" BindingPath="UserDefectMeter.DefectMeter.DefectLabel" Label="Libellé du défaut" FixedLocation="FixedToNearEdge"/>

                                <igDP:UnboundField>
                                    <igDP:UnboundField.Settings>
                                        <igDP:FieldSettings>
                                            <igDP:FieldSettings.CellValuePresenterStyle>

                                                <Style TargetType="{x:Type igDP:CellValuePresenter}">
                                                    <Setter Property="Template">
                                                        <Setter.Value>
                                                            <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

                                                                <ItemsControl ItemsSource="{Binding DefectMeterByDay}">
                                                                    <ItemsControl.ItemTemplate>
                                                                        <DataTemplate>
                                                                            <TextBlock Text="{Binding }" />
                                                                        </DataTemplate>
                                                                    </ItemsControl.ItemTemplate>
                                                                </ItemsControl>
                                                            </ControlTemplate>
                                                        </Setter.Value>
                                                          
                                                    </Setter>
                                                </Style>
                                            </igDP:FieldSettings.CellValuePresenterStyle>
                                            <igDP:FieldSettings.LabelPresenterStyle>
                                                <Style TargetType="{x:Type igDP:LabelPresenter}" BasedOn="{x:Static igThemes:DataPresenterOnyx.LabelPresenter}">
                                                    <Setter Property="Template">
                                                        <Setter.Value>
                                                            <ControlTemplate TargetType="{x:Type igDP:LabelPresenter}">
                                                                <ItemsControl ItemsSource="{Binding MatchedDefectsSynthesis, Path=DaysInPeriod}">

                                                                    <ItemsControl.ItemTemplate>
                                                                        <DataTemplate>
                                                                            <TextBlock Text="{Binding self, Path=Day}"
                                              TextAlignment="Center"/>
                                                                        </DataTemplate>
                                                                    </ItemsControl.ItemTemplate>
                                                                </ItemsControl>
                                                            </ControlTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </igDP:FieldSettings.LabelPresenterStyle>
                                        </igDP:FieldSettings>
                                    </igDP:UnboundField.Settings>
                                </igDP:UnboundField>


                                <igDP:UnboundField Name="DefectMeterNbOccurences" Width="Auto" BindingPath="DefectMeterNbOccurences" Label="Total"  FixedLocation="FixedToFarEdge"/>
                            </igDP:FieldLayout>
                        </igDP:XamDataGrid.FieldLayouts>
                    </igDP:XamDataGrid>