私はアプリケーションで使用されるコントロールのスタイル定義を含むResourceDictionaryを持っています。WPFウィンドウスタイルが適用されていません
すべてのスタイルがウィンドウのコントロールに正しく適用されますが、ウィンドウ自体のResourceDictionaryのスタイルは適用されません。
これは私が私の窓に適用するスタイルが含まれていることに私のResourceDictionaryでXAMLです:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:primatives="clr-namespace:System.Windows.Controls.Primitives;assembly=PresentationFramework"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type Window}">
<Setter Property="Background" Value="#FF121212"></Setter>
<Setter Property="Height" Value="768"></Setter>
<Setter Property="Width" Value="1024"></Setter>
</Style>
<!-- .... -->
</ResourceDictionary>
これは私が(にこのスタイルを取得しようとして働いているウィンドウのXAMLです)適用:
<Window x:Class="TryingStyles"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="TryingStyles">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/StylesDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Label" Height="28" HorizontalAlignment="Left" Margin="12,12,0,0" Name="Label1" VerticalAlignment="Top" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="56,14,0,0" Name="TextBox1" VerticalAlignment="Top" Width="120" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TabControl Height="206" HorizontalAlignment="Left" Margin="12,43,0,0" Name="TabControl1" VerticalAlignment="Top" Width="250">
<TabItem Header="TabItem1" Name="TabItem1">
<Grid></Grid>
</TabItem>
</TabControl>
<GroupBox Header="GroupBox1" Margin="268,43,12,12" Width="396"></GroupBox>
</StackPanel>
</StackPanel>
</Window>
私がIDEの「デザインビュー」ウィンドウを表示したときが、私はスタイルが適用されていないアプリケーションを実行すると、ウィンドウのスタイルが適用されることが表示されます。
誰かが間違っていることを知っていますか?
ご協力いただきありがとうございますNicolas :) – Frinavale
また、このソリューションをチェックする必要があります:http://stackoverflow.com/questions/431940/how-to-set-default-wpf-window-style-in-app-xaml –