WPF context menu data-bound icon only appears when inspected
问题 Within a TreeView 's resources, I have a HierarchicalDataTemplate that also defines the context menu style. The aim is to be able to have programmatically defined MenuItem s specify an icon name as their Tag and then have the front-end display the right icon. <StackPanel.ContextMenu> <ContextMenu ItemsSource="{Binding MenuItems}"> <ContextMenu.Resources> <Style TargetType="{x:Type MenuItem}"> <Setter Property="Icon"> <Setter.Value> <local:StringToIcon IconName="{Binding Tag, RelativeSource=