現在、いくつかの WPF ウィンドウを持ついくつかの WPF クラス ライブラリを開発しており、これらのウィンドウのより優れたデザインを作成するために、これらのウィンドウ用に独自のウィンドウ ControlTemplate を作成しようとしています (この記事に触発されました: Reusing Control Templates in Resource Dictionaries )。
問題は、アプリケーション アセンブリではなく WPF クラス ライブラリであり、app.xaml を使用してリソース ディクショナリ参照などを定義できることです。
以下のコードを使用すると、エラーが発生します: StaticResource 参照 'MyWindowStyle' が見つかりませんでした
<Window x:Class="SomeERP.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300"
Style="{StaticResource MyWindowStyle}">
<Window.Resources>
<!-- My Window Style -->
<Style x:Key="MyWindowStyle" TargetType="Window">
<Setter Property="Background" Value="Transparent" />
<Setter Property="WindowStyle" Value="None" />
<Setter Property="AllowsTransparency" Value="True" />
<Setter Property="Opacity" Value="0.95" />
<Setter Property="Template" Value="{StaticResource MyWindowTemplate}" />
</Style>
<!-- Window Template -->
<ControlTemplate x:Key="MyWindowTemplate" TargetType="{x:Type Window}">
<Grid>
</Grid>
</ControlTemplate>
</Window.Resources>
</Window>
私の場合、クラスライブラリにないapp.xamlのアプリケーションの場合のように、ウィンドウ宣言の前に事前宣言されていないため、このエラーが発生すると思われます。私は WPF の初心者で、WPF の設計の可能性を使い始めたばかりです。