显示 SortedList>>在数据网格wpf上

发布于 2024-11-24 20:10:07 字数 1609 浏览 1 评论 0 原文

我有下一个列表:

SortedList<Decimal, KeyValuePair<string,string>> datos;

我需要在数据网格中显示它。但我有一个问题。在排序列表中存在 KEY 和 VALUE。就是这样。 但作为一个 SortedList KeyValuePair 内的显示则不然。我建议你可以把它放在XAML中指定键和值到SortedList KeyValuePair中? 我的数据网格代码是:

  <my:WpfDataGrid AutoGenerateColumns="False" Estilo="StlWpfDataGridAlternatingRows" Estilo_Header="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>

在第二列,需要一个键 KeyValuePair。第三列需要一个值 KeyValuePair。谢谢你!

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_Header="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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆依然 2024-12-01 20:10:08

我认为您要求绑定到值的子属性(即 KeyValuePair),对吧?绑定将通过点符号跟随子属性。像这样的东西

<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" />

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" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文