Sag*_*gio 1 c# data-binding wpf treeview textblock
我有一个绑定的树视图,它显示了treeviewitem的一个属性(即displayname)(它们是一个对象的自定义视图模型).
这是相关的xaml:
<local:ExtendedTreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding SubOrganLocations}">
<TextBlock Text="{Binding OrganDisplayName}" >
</TextBlock>
</HierarchicalDataTemplate>
</local:ExtendedTreeView.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)
我想要的是能够在括号中显示显示名称旁边的另一个属性.
所以不是看起来像这样的树视图:
Root
-sub node1
--subsub node1
-sub node2
Run Code Online (Sandbox Code Playgroud)
我希望它看起来像这样:
Root (Type1)
-sub node1 (Type2)
--subsub node1 (Type 3)
-sub node2 (Type 1)
Run Code Online (Sandbox Code Playgroud)
我怎么能做到这一点?使用多重绑定?
试试这个:
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} ({1})">
<Binding Path="{YourBindingHere}" />
<Binding Path="{YourBindingHere}" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1806 次 |
| 最近记录: |