Reputation: 5375
I have a WPF application with Caliburn.Micro. I have a style defined in ResourceDictionary/Styles.xaml:
<Style x:Key="DisplayNameTextBlockStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="#FF414462" />
<Setter Property="Margin" Value="4,4,4,0" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontSize" Value="13.333" />
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
I am trying to apply it to my control like this:
<ScrollViewer HorizontalScrollBarVisibility="Auto">
<telerik:RadBusyIndicator IsBusy="{Binding IsBusy}">
<StackPanel x:Name="LayoutRoot">
<StackPanel Margin="0 0 0 0" Orientation="Horizontal">
<TextBlock VerticalAlignment="Center"
Style="{StaticResource DisplayNameTextBlockStyle}"
Text="Data Entry" />
But because of some reason, on loading this view I am getting an exception:
Cannot find resource named 'DisplayNameTextBlockStyle'. Resource names are case sensitive."
Could you please help? Thanks.
Upvotes: 2
Views: 2228
Reputation: 34200
Typically this happens because your resource dictionary hasn't been loaded. You can manage this in many ways; the simplest is to include the following in your app.xaml
file:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ResourceDictionary/styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Upvotes: 2