大佬教程收集整理的这篇文章主要介绍了WPF DataGrid绑定到string.Length而不是字符串文本,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经创建了我的第一个DataGrid控件,我试图用一个字符串列表填充它,如下所示:
<UserControl x:Class="DataGridTest" xmlns="http://@R_450_10906@mas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://@R_450_10906@mas.microsoft.com/winfx/2006/xaml"> <Grid Style="{Staticresource ContentRoot}"> <DataGrid Name="MyDataGrid" Itemssource="{Binding}" HorizontalAlignment="Stretch" Height="500"/> </Grid> </UserControl> Private Sub DataGridtest_Loaded(sender As Object,e As RoutedEventArgs) Handles Me.Loaded Dim StringCollection As List(Of String) = New List(Of String) StringCollection.Add("Test") StringCollection.Add("Test1") StringCollection.Add("Test2") StringCollection.Add("Test3") StringCollection.Add("Test4") MyDataGrid.DataContext = StringCollection End Sub
但是,它实际上填充了标题“长度”,值为字符串的长度.为什么它本身没有填充字符串值?
很明显,我在这里缺少一些基本的东西,但我不能为我的生活弄清楚它是什么.
提前致谢!
<DataGrid Name="MyDataGrid" Itemssource="{Binding}" ... AutoGeneratecolumns="false"> <DataGrid.columns> <DataGridTextcolumn Binding="{Binding}" Header="Something"/> </DataGrid.columns> </DataGrid>
以上是大佬教程为你收集整理的WPF DataGrid绑定到string.Length而不是字符串文本全部内容,希望文章能够帮你解决WPF DataGrid绑定到string.Length而不是字符串文本所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。