在C#中使用字典填充WPF DataGrid< String,String> [英] Filling WPF DataGrid in C# with a Dictionary <String,String>
本文介绍了在C#中使用字典填充WPF DataGrid< String,String>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经将我的字典设置为DataGrid的ItemsSource。
但是没有显示数据...
我还将AutoGenerateColumns设置为true。
错误在哪里?
提前感谢
解决方案
尝试明确指定列:
< DataGrid.Columns>
< DataGridTextColumn Header =KeyBinding ={Binding Key}/>
< DataGridTextColumn Header =ValueBinding ={Binding Value}/>
< /DataGrid.Columns>
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
解决方案
Try to specify the columns explicitly:
<DataGrid.Columns>
<DataGridTextColumn Header="Key" Binding="{Binding Key}" />
<DataGridTextColumn Header="Value" Binding="{Binding Value}" />
</DataGrid.Columns>
这篇关于在C#中使用字典填充WPF DataGrid< String,String>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文