Hi All,

I have got one scenario here in which I need to bind a DataGrid to a collection (array, ObservableCollection etc.).
My Collection name is "WarningList" and the code is as follows :-

ViewModel :-

WarningList = {({result.WarningMsgCode, result.WarningColor})}

xaml :-

<data:DataGrid x:Name="gridSystemWarnings" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Grid.RowSpan="2" DataContext="{Binding}" 
                                       IsReadOnly="True" CanUserSortColumns="True" ItemsSource="{Binding WarningList[0][0]}" AutoGenerateColumns="False" Margin="1" 
                                       ScrollViewer.CanContentScroll="True" Height="50" ScrollViewer.VerticalScrollBarVisibility="Auto" 
                                       ScrollViewer.HorizontalScrollBarVisibility="Auto" IsSynchronizedWithCurrentItem="True" HeadersVisibility="None">

                            <data:DataGrid.Columns>
                                <DataGridTextColumn Width="*" Binding="{Binding ., Converter={ssv:DataDecode SYSTEMMSG}, Mode=OneWay}">
                                    <DataGridTextColumn.CellStyle>
                                        <Style TargetType="DataGridCell">
                                            <Setter Property="Background" Value="{Binding Converter={ssv:ColourTranslate {Binding WarningList[0][1]}}}" />
                                        </Style>
                                    </DataGridTextColumn.CellStyle>
                                </DataGridTextColumn>
                            </data:DataGrid.Columns>

                        </data:DataGrid>

The "result.WarningMsgCode" is of type String() array while the "result.WarningColor" is of type Integer() array.
For now, I am getting the message code value but not getting the background color of each cell and also I'm not sure about the code

<Setter Property="Background" Value="{Binding Converter={ssv:ColourTranslate {Binding WarningList[0][1]}}}" />

Please help me as early as possible.

Hey, I did this one by creating a class and 2 properties in the same...Thanks anyways :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.