在 C# 中使用字典填充 WPF DataGrid <String,String> [英] Filling WPF DataGrid in C# with a Dictionary <String,String>

查看:20
本文介绍了在 C# 中使用字典填充 WPF DataGrid <String,String>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 Dictonary 在 C# 中填充我的 DataGrid.我已经将我的字典设置为 DataGrid 的 ItemsSource.但是没有显示数据...我还将 AutoGenerateColumns 设置为 true.错误在哪里?提前致谢

I want to fill my DataGrid in C# with a Dictonary. I already set my Dictionary as the ItemsSource of the DataGrid. But no data is displayed... I also set AutoGenerateColumns to true. Where is the mistake? Thanks in advance

推荐答案

尝试明确指定列:

<DataGrid.Columns>
    <DataGridTextColumn Header="Key" Binding="{Binding Key}" />
    <DataGridTextColumn Header="Value" Binding="{Binding Value}" />
</DataGrid.Columns>

这篇关于在 C# 中使用字典填充 WPF DataGrid &lt;String,String&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆