我的binded树视图使用字符串属性工作正常,但没有“另一个属性的属性”。
我的代码:
Public class A
Public data as string
End Class
Public Class T
Public o As A
Public ReadOnly Property desc As String
Get
Return o.data
End Get
End Property
Property children As New ObservableCollection(Of T)()
End Class
xaml工作:
<sdk:HierarchicalDataTemplate x:Key="NameTemplate"
ItemsSource="{Binding Path=children}" >
<TextBlock Text="{Binding Path=desc}" FontWeight="Bold" />
</sdk:HierarchicalDataTemplate>
xaml不起作用:
<sdk:HierarchicalDataTemplate x:Key="NameTemplate"
ItemsSource="{Binding Path=children}" >
<TextBlock Text="{Binding Path=o.data}" FontWeight="Bold" />
</sdk:HierarchicalDataTemplate>
错误是什么? 感谢。
答案 0 :(得分:1)
您只能绑定到silverlight中的属性。您的o目前不是属性,您需要定义setter和getter。
我不熟悉vb所以我不确定正确的语法是什么。将其定义为属性或定义集合并获取o。