【发布时间】:2014-11-11 22:50:20
【问题描述】:
我是新手,无法退出获取正确的语法。这可以正确捕获树视图中文本框上的Left Mouse click:
<HierarchicalDataTemplate
DataType="{x:Type r:NetworkViewModel}"
ItemsSource="{Binding Children}"
>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding NetworkIP}" Width="110" >
<TextBlock.InputBindings>
<MouseBinding MouseAction="LeftClick"
Command="{Binding DataContext.SelectItem, RelativeSource={RelativeSource FindAncestor, AncestorType=TreeView}}"
CommandParameter="{Binding}" />
</TextBlock.InputBindings>
</TextBlock>
</StackPanel>
</HierarchicalDataTemplate>
如何使用Resources 中的Style 块来完成此操作?
目标是对TreeView 中的所有TextBoxes 使用相同的样式。可以放在Usercontrol.Resources 中并被HierarchicalDataTemplate 引用的东西。
【问题讨论】: