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>

谁能为我提供正确的样式实现,以便我的向导自定义控件可以像 Page 一样设置样式?

4

1 回答 1

0

好的,我找到了解决这个问题的方法,我所要做的就是创建新的 ResourceDictionary 并使用键集声明 Wizard ControlTemplate。在 Generic.xaml 之后,我创建了 Marge Resource Dictionary 并在其中包含了所有单独的 Control 模板字典

毕竟我的 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>
于 2012-10-14T01:55:57.713 回答