Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to load TreeViewITem style from Resource Dictionary in wpf mvvm

$
0
0

In my TreeViewDictionary.xaml i have defined the style as below. Its a Resource Dictionary file for reuse. How do i refer this treeviewitem in view . When i refer it using ItemCcontainerStyle of TreeView, it throws below error :

<Treeview ItemContainerStyle="{StaticResource treeViewDictionary}"/>

An unhandled exception of type 'System.InvalidOperationException' occurred in WindowsBase.dll

Additional information: '{DependencyProperty.UnsetValue}' is not a valid value for property 'Margin'.

<converters:ContextMenuConverter x:Key="contextMenuConverter"/><Style TargetType="{x:Type TreeViewItem}" x:Key="treeViewDictionary"><Setter Property="ContextMenu" Value="{Binding Converter={StaticResource contextMenuConverter}}"/><Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" /><Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" /><Setter Property="FontWeight" Value="Normal" /><Style.Triggers><Trigger Property="IsSelected" Value="True"><Setter Property="FontWeight" Value="Bold" /></Trigger></Style.Triggers></Style>


Krrishna





Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>