3
私が取り組むアプリケーションは、2つのResourceDictionary、DefaultStyles.xamlおよびCustomStyles.xamlを持っています。別の辞書で定義されたStyleでBasedOnプロパティを使用する
CustomStyles辞書のスタイルは、他の辞書に定義されている基本スタイルを使用している可能性はありますか?
DefaultStyles.xaml:
<Style x:Key="TextBlockDefaultStyle" TargetType="TextBlock">
<Setter Property="Margin" Value="4" />
</Style>
CustomStyles.xaml:
<Style x:Key="SectionTitleStyle" TargetType="TextBlock" BasedOn="{StaticResource TextBlockDefaultStyle}">
<Setter Property="FontSize" Value="16" />
</Style>
App.xaml:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Assets/Styles/DefaultStyles.xaml"/>
<ResourceDictionary Source="Assets/Styles/CustomStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
C odeが実行されると、次の例外がスローされます。
名前/キーTextBlockDefaultStyleでリソースを見つけることができません。
両方のスタイルが同じファイルにある場合はうまく動作します。
この動作は、私は別の問題を抱えていたreasonable.Butです:BASEDON = "{StaticResource {X:Typeボタン}}" 私はそれを変更するまで働いていませんでした型の代わりにキーで参照します。これはWPFランタイムのバグのようです。 – alehro
@ alehroさんのコメントでは、私はウィンドウ内のパネルのリソースに '