2016-07-08 7 views
0

私は単純なWPF GUIを作成しています。私は暗黙のスタイルをすべてのUserControlsに適用して、デフォルトの外観(背景色とフォント)を与えようとしています。これはユーザーコントロールそのもので動作するようです。ただし、ユーザーコントロールがウィンドウに埋め込まれている場合、スタイルはリストになります。例えばUserControlスタイルはウィンドウに埋め込まれているときに適用されませんか?

は、ここでユーザーコントロールです:

UserControl

コード:

Window

<UserControl x:Class="NtpClient.Gui.Components.MainPanel.MainPanelView" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:serverSelector="clr-namespace:NtpClient.Gui.Components.ServerSelector" 
     xmlns:detailsPanel="clr-namespace:NtpClient.Gui.Components.DetailsPanel" 

     Height="350" Width="400"> 
    <Grid> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="Auto" /> 
      <ColumnDefinition Width="*" /> 
     </Grid.ColumnDefinitions> 
     <serverSelector:ServerSelectorView Grid.Column="0" Padding="6" /> 
     <detailsPanel:DetailsPanelView Grid.Column="1" Padding="6" /> 
    </Grid> 
</UserControl> 

そして、ここでは、ユーザーコントロールとウィンドウですコード:

<Window x:Class="NtpClient.Gui.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:mainPanel="clr-namespace:NtpClient.Gui.Components.MainPanel" 
     Title="Network Time Servers" Height="350" Width="400"> 
    <mainPanel:MainPanelView Width="auto" Height="auto"/> 
</Window> 

テーマファイルはapp.xamlに設定し、次のようになりますされています

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
    <ResourceDictionary.MergedDictionaries> 
     <ResourceDictionary Source="/Themes_CoreThemes;component/ControlStyles.xaml" /> 
     <ResourceDictionary Source="/Themes_CoreThemes;component/BrushResources.xaml" /> 
    </ResourceDictionary.MergedDictionaries>  

    <!-- Implicit Styles --> 
    <Style BasedOn="{StaticResource DeepBlueButtonStyle}" TargetType="Button" /> 
    <Style BasedOn="{StaticResource ControlStyle}" TargetType="UserControl" /> 
</ResourceDictionary> 

App.xaml:

<Application x:Class="NtpClient.Gui.App" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
    <Application.Resources> 
     <ResourceDictionary> 
      <ResourceDictionary.MergedDictionaries> 
       <ResourceDictionary Source="/Themes_CoreThemes;component/ControlStyles.xaml" /> 
       <ResourceDictionary Source="/Themes_CoreThemes;component/BrushResources.xaml" /> 
       <ResourceDictionary Source="Themes/Local/Local.MSControls.Core.Implicit.xaml" /> 
      </ResourceDictionary.MergedDictionaries> 
     </ResourceDictionary> 
    </Application.Resources> 
</Application> 

誰もがこれを引き起こしているものを任意のアイデアを持っていて、どのようにIそれを解決する?

+0

App.xamlコードを投稿できますか? –

+0

@HenkaProgrammerこれを行ったことがあります。 – Oliver

+1

この投稿をご覧ください:http://stackoverflow.com/questions/7470621/issue-with-applying-style-on-wpf-usercontrol –

答えて

-1

私は数か月前にその問題に直面しました。
xamlファイルが他のDLLにあるためです。
なぜか分かりませんが、デザイナーはそれを正しく処理していません。
それはデザイナーの外的な問題のように見えます。
私はちょうどdllからメインプロジェクトにスタイルを移しました。

関連する問題