C
C#9mo ago
stigzler

WPF - Resource Dictionary - "the resource could not be resolved"

I'm working on a VS extension. This is a WPF UserControl, thus no app.xaml. I'm trying to move my styles out of the main control's body to seprarte resource dictionaries. I've followed guides, but getting an error on any elements whic previously worked when they were in <UserControl.Resources> In the user control:
<UserControl.Resources>

<converters:InverseBoolToVisibilityConverter x:Key="inverseBoolToVisibilityConverter" />
<converters:EmptyStringToVisibilityConverter x:Key="emptyStringToVisibilityConverter" />

<styleSelectors:TreeViewItemStyleSelector x:Key="treeViewItemStyleSelector" />

<ResourceDictionary x:Key="MainDictionary">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/GistManager;component/Styles/ToolbarStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

<CollectionViewSource x:Key="privateGistsSource"
Source="{Binding Gists}"
behaviors:CollectionViewSourceFilterBehavior.FilterCommand="{Binding PrivateFilterCommand}"
behaviors:CollectionViewSourceFilterBehavior.FilterTextBox="{Binding ElementName=searchBox}" />
</UserControl.Resources>
<UserControl.Resources>

<converters:InverseBoolToVisibilityConverter x:Key="inverseBoolToVisibilityConverter" />
<converters:EmptyStringToVisibilityConverter x:Key="emptyStringToVisibilityConverter" />

<styleSelectors:TreeViewItemStyleSelector x:Key="treeViewItemStyleSelector" />

<ResourceDictionary x:Key="MainDictionary">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/GistManager;component/Styles/ToolbarStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

<CollectionViewSource x:Key="privateGistsSource"
Source="{Binding Gists}"
behaviors:CollectionViewSourceFilterBehavior.FilterCommand="{Binding PrivateFilterCommand}"
behaviors:CollectionViewSourceFilterBehavior.FilterTextBox="{Binding ElementName=searchBox}" />
</UserControl.Resources>
and:
<Separator Style="{StaticResource toolBarSeparatorStyle}"/>
<Separator Style="{StaticResource toolBarSeparatorStyle}"/>
(this throws the error - working before removal). And the resource dict:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="toolBarSeparatorStyle" TargetType="Separator" >
<Setter Property="Background" Value="gray"></Setter>
<Setter Property="Margin" Value="4"></Setter>
</Style>
</ResourceDictionary>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="toolBarSeparatorStyle" TargetType="Separator" >
<Setter Property="Background" Value="gray"></Setter>
<Setter Property="Margin" Value="4"></Setter>
</Style>
</ResourceDictionary>
What am I doing wrong?
1 Reply
stigzler
stigzlerOP9mo ago
Also tried <ResourceDictionary Source="Styles/ToolbarStyles.xaml"/> - the path's not showing as the issue in designer view
Want results from more Discord servers?
Add your server