2

特定のコントロール タイプにグローバル アプリケーション スタイルを適用しようとしていますが、これらのスタイルを Application.Resources に追加しても、ビューの要素にスタイルが適用されません。

例:

<Application x:Class="GUI.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Application.Resources>
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="Background" Value="AliceBlue"></Setter>
            <Setter Property="Margin" Value="20,20,20,20"></Setter>
            <Setter Property="FontStyle" Value="Italic"></Setter>
        </Style>
    </Application.Resources>
</Application>

アプリケーション全体のスタイルを適用するために私が見つけたすべての例で、これは彼らが言う方法でしたが、私にとってはうまくいきません。私は何を間違っていますか?

ありがとう、アレックス。

4

2 に答える 2

2

問題はStartUpUri、最初のアプリケーション ビューを開くためにプロパティを使用していなかったことです。起動プロセスを変更して、このプロパティを使用するようにしました。これで問題が解決しました。

私の App.xaml は次のようになります。

<Application x:Class="GUI.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="/Views/Application/SplashView.xaml">
    <Application.Resources>
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="Background" Value="Aqua"></Setter>
        </Style>
    </Application.Resources>
</Application>

ありがとう、アレックス。

于 2012-06-08T05:20:38.647 に答える