WPF - Use static resource in multiple windows

Viewed 21

I have an application with many Windows, and I want to use the same templates and styles in all of these windows.

Warning: This is NOT a "WPF Application", it's a "class library" using WPF windows. I do not have an "App.xaml" file!!!

What is the easiest way to do that in WPF?

Currently, I have this in a Window, working fine:

<Window.Resources>
    <ControlTemplate x:Key="ErrorTemplate">
        <Grid  ToolTip="{Binding Path=/ErrorContent}">
            ....
        </Grid>
    </ControlTemplate>

    <Style TargetType="Control" x:Key="ErrorStyle">
        <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
        <Style.Triggers>
            ... 
        </Style.Triggers>
    </Style>
</Window.Resources>

And I use it as

<TextBox Style="{StaticResource ErrorStyle}" .../>

But this is clearly declared in a single Window. How do I declare it in a way that it could be used by many windows (considering I do not have an App.xaml file)

1 Answers
Related