0
目前,我爲樹的每個父標籤添加一個特定的圖標。我多次評估父節點的相同值。這是非常耗時的。有沒有簡化的方法可以在XAML中實現?可能是一個枚舉被聲明爲窗口資源?WPF替代DataTriggers序列
<!-- custom icons for the root nodes -->
<DataTrigger Binding="{Binding Path=Header.NodeTitle, RelativeSource={RelativeSource AncestorType=TreeViewItem, AncestorLevel=2}}"
Value="Sequences">
<Setter Property="Source"
TargetName="Folder"
Value="/Images/sequence.png" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=Header.NodeTitle, RelativeSource={RelativeSource AncestorType=TreeViewItem, AncestorLevel=2}}"
Value="Triggers">
<Setter Property="Source"
TargetName="Folder"
Value="/Images/trigger.png" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=Header.NodeTitle, RelativeSource={RelativeSource AncestorType=TreeViewItem, AncestorLevel=2}}"
Value="Views">
<Setter Property="Source"
TargetName="Folder"
Value="/Images/view.png" />
</DataTrigger>