Show a SortedList<decimal,KeyValuePair<string,string>> on datagrid wpf
i have the next list:
SortedList<Decimal, KeyValuePair<string,string>> datos;
And i need display this in datagrid. But i have one problem. In a sorted list exists KEY and VALUE. This is it. But as a show within a SortedList KeyValuePair not. I suggest that you can put it in the XAML to specify the key and value into the SortedList KeyValuePair? My datagrid code is :
<my:WpfDataGrid AutoGenerateColumns="False" Estilo="StlWpfDataGridAlternatingRows" Estilo_Head开发者_如何学编程er="WpfDataGridColumnHeaderAzul" IsReadOnly="False" ItemsSource="{Binding}" Margin="12,12,12,354" Name="dataGridPresentacionPrincipal" SelectionChanged="dataGridPresentacionPrincipal_SelectionChanged">
<my:WpfDataGrid.Columns>
<mic:DataGridTextColumn Binding="{Binding Key,Mode=OneWay}" Header="Codigo" SortDirection="Ascending" Width="80">
<mic:DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextAlignment" Value="Right" />
</Style>
</mic:DataGridTextColumn.ElementStyle>
</mic:DataGridTextColumn>
<mic:DataGridTextColumn Binding="{Binding Value,Mode=OneWay}" Header="Descripcion" SortDirection="Ascending" Width="920" />
<!--<mic:DataGridTextColumn Binding="{Binding Value,Mode=OneWay}" Header="Producto" SortDirection="Ascending" Width="920" />-->
</my:WpfDataGrid.Columns>
</my:WpfDataGrid>
On second column, need a key KeyValuePair. And de third column need a value KeyValuePair. Thank you!
I think that you're asking to bind to the child properties of the value (i.e. the KeyValuePair), right? The binding will follow child properties through a dot-notation. Something like
<mic:DataGridTextColumn Binding="{Binding Value.Key,Mode=OneWay}" Header="Descripcion" SortDirection="Ascending" Width="920" />
<mic:DataGridTextColumn Binding="{Binding Value.Value,Mode=OneWay}" Header="Producto" SortDirection="Ascending" Width="920" />
精彩评论