2012-10-13 80 views
0

我想修改擴展WPF工具嚮導控制是它在generic.xaml文件中的默認樣式自定義控制,但現在我想這樣基於嚮導類型它的變化進行修改其風格完全風格作爲資源自定義用戶控件

<Style TargetType="{x:Type local:Wizard}"> 
    <Style.Triggers> 
     <Trigger Property="WizardType" Value="Normal"> 
      <Setter Property="Style" Value="{StaticResource StandartWizardTemplate}" /> 
     </Trigger> 
    </Style.Triggers> 
</Style> 

我這是怎麼了它的generic.xaml修改,但StandardWizardTemplate堅持

<Style x:Key="StandartWizardTemplate" TargetType="{x:Type local:Wizard}"> 
    <Setter Property="Background" Value="#F0F0F0" /> 
    <Setter Property="BorderBrush" Value="#A0A0A0" /> 
    <Setter Property="BorderThickness" Value="1" /> 
    <Setter Property="ItemsPanel"> 
     <Setter.Value> 
      <ItemsPanelTemplate> 
       <Grid /> 
      </ItemsPanelTemplate> 
     </Setter.Value> 
    </Setter> 
    <Setter Property="Template"> 
    //Content of default template before modification 
    </Setter> 
</Style> 

相同的文件包含了另一個樣式定義基於觸發器,它改變了頁面控件模板,所以我雖然我在沒有解決將能夠做同樣的事情嚮導

<Style TargetType="{x:Type local:WizardPage}"> 
    <Style.Triggers> 
     <Trigger Property="PageType" Value="Blank"> 
      <Setter Property="Background" Value="#FFF0F0F0" /> 
      <Setter Property="BorderThickness" Value="0" /> 
      <Setter Property="Template" Value="{StaticResource BlankWizardPageTemplate}" /> 
     </Trigger> 
     <Trigger Property="PageType" Value="Exterior"> 
      <Setter Property="Background" Value="#FFFFFF" /> 
      <Setter Property="BorderThickness" Value="0" /> 
      <Setter Property="ExteriorPanelBackground" Value="#E3EFFF" /> 
      <Setter Property="Template" Value="{StaticResource ExteriorWizardPageTemplate}" /> 
     </Trigger> 
     <Trigger Property="PageType" Value="Interior"> 
      <Setter Property="Background" Value="#FFF0F0F0" /> 
      <Setter Property="BorderBrush" Value="{x:Static SystemColors.ActiveBorderBrush}" /> 
      <Setter Property="BorderThickness" Value="0,1,0,0" /> 
      <Setter Property="HeaderBackground" Value="#FFFFFF" /> 
      <Setter Property="Template" Value="{StaticResource InteriorWizardPageTemplate}" /> 
     </Trigger> 
    </Style.Triggers> 
</Style> 

任何人都可以向我提供正確的造型實施,使我的嚮導自定義控制可以以同樣的方式頁面不被稱呼?

+0

設置風格是一種風格觸發器對我來說似乎很不尋常 – Vlad

+0

你是什麼意思?這是他們從擴展WPF工具包嚮導控制和設置基於觸發器的WizardPage模板真的很有趣,所以你可以發佈答案如何切換向導控制風格本身基於WizardType依賴屬性的觸發器? –

回答

0

OK,我發現解決這個問題,我所要做的就是創造新的資源字典,用按鍵精靈聲明控件模板。之後,裏面Generic.xaml我創建瑪吉資源詞典,其中包括內部

所有單獨的控制模板字典我所有的generic.xaml看上去經過這種方式現在。

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
       xmlns:Converters="clr-namespace:CuratioCMS.Client.UI.Core.Converters" 
       xmlns:local="clr-namespace:CuratioCMS.Client.UI.Controls"> 
<ResourceDictionary.MergedDictionaries> 
    <ResourceDictionary Source="./NormalWizardStyle.xaml" /> 
    <ResourceDictionary Source="./StepBased.xaml" /> 
    <ResourceDictionary Source="./MixedModeWizard.xaml" /> 
</ResourceDictionary.MergedDictionaries> 

<Converters:WizardPageButtonVisibilityConverter x:Key="WizardPageButtonVisibilityConverter" /> 

<Style TargetType="{x:Type local:Wizard}"> 
    <Style.Triggers> 
     <Trigger Property="WizardType" Value="Normal"> 
      <Setter Property="Template" Value="{StaticResource NormalModeWizardTemplate}" /> 
     </Trigger> 
     <Trigger Property="WizardType" Value="StepWisivle"> 
      <Setter Property="Template" Value="{StaticResource StepModeWizardTemplate}" /> 
     </Trigger> 
     <Trigger Property="WizardType" Value="MixedMode"> 
      <Setter Property="Template" Value="{StaticResource MixedModeWizardTemplate}" /> 
     </Trigger> 
    </Style.Triggers> 
    <Setter Property="Background" Value="#F0F0F0" /> 
    <Setter Property="BorderBrush" Value="#A0A0A0" /> 
    <Setter Property="BorderThickness" Value="1" /> 
    <Setter Property="ItemsPanel"> 
     <Setter.Value> 
      <ItemsPanelTemplate> 
       <Grid /> 
      </ItemsPanelTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 
</ResourceDictionary>