列表视图绑定不起作用,但列表已满 [英] list view Binding not working but list full
本文介绍了列表视图绑定不起作用,但列表已满的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是代码:
this is the code:
<ListView ItemsSource="{Binding UsageProfilesList}" Grid.Row="1" HorizontalAlignment="Stretch" x:Name="usageProfileLists" >
<ListView.ItemTemplate>
<DataTemplate>
<Border Margin="0,10,0,10" PreviewMouseLeftButtonDown="Start" PreviewMouseMove="Drag" HorizontalAlignment="Stretch"
MouseLeftButtonDown="AddItemToTimeline" Tag="{Binding}" Background="Transparent">
<TextBlock Text="{Binding Name}" FontSize="18" HorizontalAlignment="Center" />
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
列表的绑定不起作用,但是我正在显示一个消息列表,其中显示了列表详细信息,并且列表正在被填充.
我怎么了?我花了几个小时尝试调试它,但是一切正常.绑定似乎只是被忽略.
请帮助
the binding of the list is not working, but i am showing a message box showing the list details and the list is getting filled.
what do i have wrong? I''ve spent hours trying to debug it but everything is working. the binding just seem to be ignored.
please help
推荐答案
添加
Hi,
Add
DisplayMemberBinding="{Binding UserName}" />
标签.
您需要像这样指定DataTemplate
的TargetType
:
Hi,
You need to specify theTargetType
of yourDataTemplate
like so:
<DataTemplate DataType="{x:Type UsageProfilesList}">
否则,编译器不知道名称"是"UsageProfilesList"的属性.
希望对您有所帮助:)
The compiler doesn''t know that "Name" is a property of "UsageProfilesList" otherwise.
Hope that helps :)
这篇关于列表视图绑定不起作用,但列表已满的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文