【问题标题】:binding path in silverlight treeviewSilverlight 树视图中的绑定路径
【发布时间】:2011-10-04 14:22:46
【问题描述】:

我的绑定树视图适用于字符串属性,但不适用于“另一个属性的属性”。

我的代码:

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>

什么是错误? 谢谢。

【问题讨论】:

  • A.data 不是属性,如果我正确理解 vb 语法的话。

标签: silverlight binding treeview


【解决方案1】:

您只能绑定到 silverlight 中的属性。您的 o 目前不是属性,您需要定义 setter 和 getter。

我不熟悉 vb,所以我不确定正确的语法是什么。要么将其定义为属性,要么为 o 定义 set 和 get。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-29
    • 2012-02-20
    • 1970-01-01
    相关资源
    最近更新 更多