1

現在、このXAMLコードを使用して、WPFアプリにlunaテーマを使用するように強制しています

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Styles.xaml" />
            <ResourceDictionary Source="NavigationCommands.xaml" />
            <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Blue.xaml"/>
            <ResourceDictionary Source="/PresentationFramework.Luna, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;;component/Themes/luna.normalcolor.xaml" /> 
            </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

そして今、この検証トリガーですべてのテキストボックスのスタイルを拡張したい

<Style TargetType="TextBox">
    <Style.Triggers>
        <Trigger Property="Validation.HasError" Value="true">
            <Setter Property="Background" Value="#d3e1f3"></Setter>
            <Setter Property="ToolTip"
            Value="{Binding RelativeSource={RelativeSource Self}, 
                   Path=(Validation.Errors)[0].ErrorContent}"/>
        </Trigger>
    </Style.Triggers>
</Style>

しかし、ルナのテーマを強制したため、このトリガーは機能しません。(強制されたテーマがなければ、すべてが正常に機能しますが、本来のように見えません:( )ルナのテーマを強制してそのスタイルを拡張する方法はありますか?おそらくBasedOnプロパティを介して?

問題のスタイルのキーを定義し、それをすべてのテキストボックスに手動で追加しました。これは機能しますが、最も美しい方法ではありません。

ティア

4

4 に答える 4

1

タイプスタイルのBasedOn構文は次のとおりです。

<Style TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">

HTH

于 2008-11-28T09:02:36.273 に答える
1

試す

<Style x:Key="{x:Type TextBox}" TargetType="{x:Type TextBox}">
于 2008-11-27T16:30:06.107 に答える
0

lune resourcedictionary を最初に設定し、独自の resourcedictionary を最後に設定しようとしましたか? ルナのテーマがあなたのスタイルを上書きすることは想像できます。

<Application.Resources>
   <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/PresentationFramework.Luna, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;;component/Themes/luna.normalcolor.xaml" />
            <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Blue.xaml"/> 
            <ResourceDictionary Source="Styles.xaml" />
            <ResourceDictionary Source="NavigationCommands.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>
于 2011-01-11T21:08:06.793 に答える