Silverlight 工具包 Accordion - 更改颜色

发布于 2024-09-10 12:22:51 字数 23335 浏览 6 评论 0原文

在工具包中,我不知道如何更改所选部分下文本的颜色。它是灰色的,看起来像是被禁用了。 我该如何更改才能以默认颜色显示它?

谢谢!

替代文本 http://img199.imageshack.us/img199/7517/accordion.png< /a>

<!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->

<UserControl x:Class="System.Windows.Controls.Samples.AccordionShowcase" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:layoutToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit" xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" xmlns:layoutToolkitPrimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Layout.Toolkit">
    <StackPanel Background="White">

    <ContentControl Content="Accordion restyled (based on ajax toolkit style)" Style="{StaticResource Header}"/>
    <layoutToolkit:Accordion>
      <layoutToolkit:Accordion.Resources>
        <!-- ajax toolkit styled AccordionItemHeader-->
        <ControlTemplate TargetType="layoutToolkitPrimitives:AccordionButton" x:Key="AjaxHeader">
          <Grid Background="Transparent">
            <vsm:VisualStateManager.VisualStateGroups>
              <!-- ExpansionStates -->
              <vsm:VisualStateGroup x:Name="ExpansionStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Collapsed">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Expanded">
                  <Storyboard>
                    <Storyboard>
                      <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0030000" Storyboard.TargetName="background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)">
                        <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF5078B3"/>
                      </ColorAnimationUsingKeyFrames>
                    </Storyboard>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>
              <!-- CheckStates -->
              <vsm:VisualStateGroup x:Name="CheckStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="00:00:00"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Checked">
                </vsm:VisualState>
                <vsm:VisualState x:Name="Unchecked"/>
              </vsm:VisualStateGroup>
              <!-- CommonStates -->
              <vsm:VisualStateGroup x:Name="CommonStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                  <vsm:VisualTransition GeneratedDuration="00:00:00.1" From="MouseOver" To="Normal"/>
                  <vsm:VisualTransition GeneratedDuration="00:00:00.1" To="MouseOver"/>
                  <vsm:VisualTransition GeneratedDuration="00:00:00.1" To="Pressed"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Normal"/>
                <vsm:VisualState x:Name="MouseOver">
                  <Storyboard>
                    <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0030000" Storyboard.TargetName="MouseOverBackground" Storyboard.TargetProperty="(Grid.Background).(SolidColorBrush.Color)">
                      <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF2E4D7B"/>
                    </ColorAnimationUsingKeyFrames>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Pressed">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Disabled">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>
              <!-- FocusStates -->
              <vsm:VisualStateGroup x:Name="FocusStates">
                <vsm:VisualState x:Name="Focused">
                  <Storyboard>
                    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility">
                      <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                    </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Unfocused"/>
              </vsm:VisualStateGroup>
            </vsm:VisualStateManager.VisualStateGroups>

            <Border x:Name="MouseOverBackground" Background="#FF2E4D7B" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
              <Border x:Name="background" Background="Transparent">
                <Grid Background="Transparent" Margin="{TemplateBinding Padding}">
                   <ContentControl x:Name="header" Grid.Column="1" Grid.Row="0" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Foreground="{TemplateBinding Foreground}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                  </ContentControl>
                </Grid>
              </Border>
            </Border>
            <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="false" Stroke="Green" StrokeDashArray="1 2" StrokeThickness="1" Visibility="Collapsed"/>
          </Grid>
        </ControlTemplate>
        <!-- ajax toolkit styled AccordionItem-->
        <ControlTemplate TargetType="layoutToolkit:AccordionItem" x:Key="ajaxTemplate">
          <Grid Background="Transparent">
            <vsm:VisualStateManager.VisualStateGroups>
              <!-- CommonState -->
              <vsm:VisualStateGroup x:Name="CommonStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Normal"/>
                <vsm:VisualState x:Name="Disabled">
                  <Storyboard>
                    <DoubleAnimation Duration="0" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>
              <!-- FocusStates -->
              <vsm:VisualStateGroup x:Name="FocusStates">
                <vsm:VisualState x:Name="Focused">
                  <Storyboard>
                    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility">
                      <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                    </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
                </vsm:VisualState>
                <!-- Unfocused -->
                <vsm:VisualState x:Name="Unfocused"/>
              </vsm:VisualStateGroup>
              <!-- ExpansionStates -->
              <vsm:VisualStateGroup x:Name="ExpansionStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Collapsed">
                    <Storyboard>
                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(ExpandableContentControl.Percentage)">
                      <SplineDoubleKeyFrame KeyTime="00:00:00.3" KeySpline="0.2,0,0,1" Value="0"/>
                    </DoubleAnimationUsingKeyFrames>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Expanded">
                  <Storyboard>
                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(ExpandableContentControl.Percentage)">
                      <SplineDoubleKeyFrame KeyTime="00:00:00.3" KeySpline="0.2,0,0,1" Value="1"/>
                    </DoubleAnimationUsingKeyFrames>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>              
              <!-- ExpansionStates -->
              <vsm:VisualStateGroup x:Name="LockedStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Locked">
                    <Storyboard>
                    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpanderButton" Storyboard.TargetProperty="IsEnabled">
                      <DiscreteObjectKeyFrame KeyTime="0" Value="False"/>
                    </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Unlocked">
                  <Storyboard>
                    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpanderButton" Storyboard.TargetProperty="IsEnabled">
                      <DiscreteObjectKeyFrame KeyTime="0" Value="True"/>
                    </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>
            </vsm:VisualStateManager.VisualStateGroups>
            <Border x:Name="Background" Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4">
              <Grid>
                <Grid.RowDefinitions>
                  <RowDefinition Height="Auto"/>
                  <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <layoutToolkitPrimitives:AccordionButton Template="{StaticResource AjaxHeader}" x:Name="ExpanderButton" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" IsChecked="{TemplateBinding IsSelected}" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Padding="4" Margin="0" FontFamily="{TemplateBinding FontFamily}" FontSize="14" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="Bold" Foreground="#FFFFFFFF" HorizontalContentAlignment="Left" VerticalContentAlignment="Center"/>

                <layoutToolkitPrimitives:ExpandableContentControl x:Name="ExpandSite" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Percentage="0" Background="#FFD3DEEF" RevealMode="{TemplateBinding ExpandDirection}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Padding="2" Margin="1" FontFamily="{TemplateBinding FontFamily}" FontSize="12" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="DarkGray" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" VerticalAlignment="Stretch" VerticalContentAlignment="Top"/>

              </Grid>
            </Border>
            <Border x:Name="DisabledVisualElement" IsHitTestVisible="false" Opacity="0" Background="#A5FFFFFF" CornerRadius="3"/>
            <Border x:Name="FocusVisualElement" IsHitTestVisible="false" Visibility="Collapsed" BorderThickness="1" CornerRadius="3">
              <Border.BorderBrush>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                  <GradientStop Color="#FFA3AEB9"/>
                  <GradientStop Color="#FF8399A9" Offset="0.375"/>
                  <GradientStop Color="#FF718597" Offset="0.375"/>
                  <GradientStop Color="#FF617584" Offset="1"/>
                </LinearGradientBrush>
              </Border.BorderBrush>
            </Border>
          </Grid>
        </ControlTemplate>
      </layoutToolkit:Accordion.Resources>

      <layoutToolkit:AccordionItem Header="1. Accordion" Template="{StaticResource ajaxTemplate}">
          <layoutToolkit:AccordionItem.Content>
          <TextBlock>
            The Accordion is a control that allows you to provide multiple panes and display them.<LineBreak/>
            There are several selection modes, so you can decide if only one pane can be open, <LineBreak/>
            or multiple.<LineBreak/>
            It is also possible to adjust the order in which the panes open and close:<LineBreak/>
            Simultaneous or close first. <LineBreak/>
            <LineBreak/>
            The Accordion is implemented as an itemscontrol that contains AccordionItem controls. <LineBreak/>
            Each AccordionItem control has a template for its Header and its Content. <LineBreak/>
          </TextBlock>
        </layoutToolkit:AccordionItem.Content>
      </layoutToolkit:AccordionItem>
      <layoutToolkit:AccordionItem Header="2. AutoSize" Template="{StaticResource ajaxTemplate}">
        <TextBlock>
          It also supports filling to a specific height or width. <LineBreak/>
          To do so, either set a Height (or Width) or use a VerticalAlignment <LineBreak/>
          (or HorizontalAlignment) of 'Stretch'. <LineBreak/>
          The Accordion will now always fill to that space. If more than one pane <LineBreak/>
          may be opened, space is divided equally among them.
          <LineBreak/>
          Whether you fill to height or width is determined by the ExpandDirection property.<LineBreak/>
          An accordion will is able to expand to Down, Up, Left and Right directions.
        </TextBlock>
      </layoutToolkit:AccordionItem>
      <layoutToolkit:AccordionItem Header="3. Template parts" Template="{StaticResource ajaxTemplate}">
        <TextBlock>
          The accordion uses AccordionItems that can be fully templated.<LineBreak/>
          In order to 'reveal' contents slowly, an ExpandableContentControl is used. <LineBreak/>
          That control has a percentage property that can be animated. A value of 1 <LineBreak/>
          means that the content is completely shown.<LineBreak/>
          <LineBreak/>
          AccordionItem animates this property using a keyspline to get a nice <LineBreak/>
          easing-in effect. You can retemplate AccordionItem and create your own <LineBreak/>
          transitions!<LineBreak/>
        </TextBlock>
      </layoutToolkit:AccordionItem>
    </layoutToolkit:Accordion>

    <ContentControl Content="Accordion restyled horizontally" Style="{StaticResource Header}"/>
    <layoutToolkit:Accordion ExpandDirection="Left" Background="#FFE7E7E7">
      <layoutToolkit:Accordion.Resources>
        <!-- horizontal header -->
        <ControlTemplate TargetType="layoutToolkitPrimitives:AccordionButton" x:Key="HorizontalHeader">
          <Grid Background="Transparent">
            <vsm:VisualStateManager.VisualStateGroups>
              <!-- ExpandDirectionStates -->
              <vsm:VisualStateGroup x:Name="ExpandDirectionStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="ExpandDown">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="ExpandUp">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="ExpandLeft">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="ExpandRight">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>
              <!-- ExpansionStates -->
              <vsm:VisualStateGroup x:Name="ExpansionStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Collapsed">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Expanded">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>
              <!-- CheckStates -->
              <vsm:VisualStateGroup x:Name="CheckStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="00:00:00"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Checked"/>
                <vsm:VisualState x:Name="Unchecked"/>
              </vsm:VisualStateGroup>
              <!-- CommonStates -->
              <vsm:VisualStateGroup x:Name="CommonStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                  <vsm:VisualTransition GeneratedDuration="00:00:00.1" From="MouseOver" To="Normal"/>
                  <vsm:VisualTransition GeneratedDuration="00:00:00.1" To="MouseOver"/>
                  <vsm:VisualTransition GeneratedDuration="00:00:00.1" To="Pressed"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Normal"/>
                <vsm:VisualState x:Name="MouseOver">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Pressed">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Disabled">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>
              <!-- FocusStates -->
              <vsm:VisualStateGroup x:Name="FocusStates">
                <vsm:VisualState x:Name="Focused">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Unfocused"/>
              </vsm:VisualStateGroup>
            </vsm:VisualStateManager.VisualStateGroups>

            <Border x:Name="MouseOverBackground" Background="Transparent">
              <Border x:Name="background" Background="Transparent">
                <Grid Width="20" Height="200" Margin="{TemplateBinding Padding}">

                  <Path Width="60" Data="M7.2912064,0.5 C35.733871,0.5 58.791206,44.375938 58.791206,98.5 C58.791206,152.62386 35.734119,196.5 7.2912064,196.5 C5.5135384,196.5 3.7569084,196.32861 2.025631,195.99403 L0.5,195.55096 L3.2518349,194.50899 C13.537304,189.28716 22.366497,174.14719 28.045227,153.29272 C30.884619,142.86546 32.936363,131.00955 33.988701,118.25042 C35.041069,105.49129 35.041069,91.508682 33.988701,78.74958 C31.884027,53.231354 25.781698,31.325907 17.37603,17.23686 C13.173197,10.192317 8.3945103,5.1018929 3.2518349,2.4910123 L0.5,1.4490361 L2.025631,1.0059637 C3.7569084,0.67139101 5.5135384,0.5 7.2912064,0.5 z" Stretch="Fill" Stroke="Black" StrokeThickness="2" Height="197" Margin="-40,0,0,0">
                    <Path.Fill>
                      <LinearGradientBrush EndPoint="-0.162,1.001" StartPoint="2.078,0.261">
                        <GradientStop Color="#FFC4C4C4"/>
                        <GradientStop Color="#FFF2F2F2" Offset="1"/>
                      </LinearGradientBrush>
                    </Path.Fill>
                  </Path>

                  <layoutToolkit:LayoutTransformer x:Name="header" Margin="0,0,5,0" RenderTransformOrigin="0.5,0.5" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Foreground="{TemplateBinding Foreground}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <layoutToolkit:LayoutTransformer.LayoutTransform>
                      <RotateTransform Angle="90"/>
                    </layoutToolkit:LayoutTransformer.LayoutTransform>
                  </layoutToolkit:LayoutTransformer>
                </Grid>

              </Border>
            </Border>
            <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="false" Stroke="Green" StrokeDashArray="1 2" StrokeThickness="1" Visibility="Collapsed"/>
          </Grid>
        </ControlTemplate>

In the toolkit, I can't figure out how to change the color of the text under the selected section. It is gray and looks like it is disabled.
What do I change to display it in the default color?

Thanks!

alt text http://img199.imageshack.us/img199/7517/accordion.png

<!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->

<UserControl x:Class="System.Windows.Controls.Samples.AccordionShowcase" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:layoutToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit" xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" xmlns:layoutToolkitPrimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Layout.Toolkit">
    <StackPanel Background="White">

    <ContentControl Content="Accordion restyled (based on ajax toolkit style)" Style="{StaticResource Header}"/>
    <layoutToolkit:Accordion>
      <layoutToolkit:Accordion.Resources>
        <!-- ajax toolkit styled AccordionItemHeader-->
        <ControlTemplate TargetType="layoutToolkitPrimitives:AccordionButton" x:Key="AjaxHeader">
          <Grid Background="Transparent">
            <vsm:VisualStateManager.VisualStateGroups>
              <!-- ExpansionStates -->
              <vsm:VisualStateGroup x:Name="ExpansionStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Collapsed">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Expanded">
                  <Storyboard>
                    <Storyboard>
                      <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0030000" Storyboard.TargetName="background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)">
                        <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF5078B3"/>
                      </ColorAnimationUsingKeyFrames>
                    </Storyboard>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>
              <!-- CheckStates -->
              <vsm:VisualStateGroup x:Name="CheckStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="00:00:00"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Checked">
                </vsm:VisualState>
                <vsm:VisualState x:Name="Unchecked"/>
              </vsm:VisualStateGroup>
              <!-- CommonStates -->
              <vsm:VisualStateGroup x:Name="CommonStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                  <vsm:VisualTransition GeneratedDuration="00:00:00.1" From="MouseOver" To="Normal"/>
                  <vsm:VisualTransition GeneratedDuration="00:00:00.1" To="MouseOver"/>
                  <vsm:VisualTransition GeneratedDuration="00:00:00.1" To="Pressed"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Normal"/>
                <vsm:VisualState x:Name="MouseOver">
                  <Storyboard>
                    <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0030000" Storyboard.TargetName="MouseOverBackground" Storyboard.TargetProperty="(Grid.Background).(SolidColorBrush.Color)">
                      <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF2E4D7B"/>
                    </ColorAnimationUsingKeyFrames>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Pressed">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Disabled">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>
              <!-- FocusStates -->
              <vsm:VisualStateGroup x:Name="FocusStates">
                <vsm:VisualState x:Name="Focused">
                  <Storyboard>
                    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility">
                      <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                    </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Unfocused"/>
              </vsm:VisualStateGroup>
            </vsm:VisualStateManager.VisualStateGroups>

            <Border x:Name="MouseOverBackground" Background="#FF2E4D7B" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
              <Border x:Name="background" Background="Transparent">
                <Grid Background="Transparent" Margin="{TemplateBinding Padding}">
                   <ContentControl x:Name="header" Grid.Column="1" Grid.Row="0" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Foreground="{TemplateBinding Foreground}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                  </ContentControl>
                </Grid>
              </Border>
            </Border>
            <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="false" Stroke="Green" StrokeDashArray="1 2" StrokeThickness="1" Visibility="Collapsed"/>
          </Grid>
        </ControlTemplate>
        <!-- ajax toolkit styled AccordionItem-->
        <ControlTemplate TargetType="layoutToolkit:AccordionItem" x:Key="ajaxTemplate">
          <Grid Background="Transparent">
            <vsm:VisualStateManager.VisualStateGroups>
              <!-- CommonState -->
              <vsm:VisualStateGroup x:Name="CommonStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Normal"/>
                <vsm:VisualState x:Name="Disabled">
                  <Storyboard>
                    <DoubleAnimation Duration="0" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>
              <!-- FocusStates -->
              <vsm:VisualStateGroup x:Name="FocusStates">
                <vsm:VisualState x:Name="Focused">
                  <Storyboard>
                    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility">
                      <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                    </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
                </vsm:VisualState>
                <!-- Unfocused -->
                <vsm:VisualState x:Name="Unfocused"/>
              </vsm:VisualStateGroup>
              <!-- ExpansionStates -->
              <vsm:VisualStateGroup x:Name="ExpansionStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Collapsed">
                    <Storyboard>
                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(ExpandableContentControl.Percentage)">
                      <SplineDoubleKeyFrame KeyTime="00:00:00.3" KeySpline="0.2,0,0,1" Value="0"/>
                    </DoubleAnimationUsingKeyFrames>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Expanded">
                  <Storyboard>
                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(ExpandableContentControl.Percentage)">
                      <SplineDoubleKeyFrame KeyTime="00:00:00.3" KeySpline="0.2,0,0,1" Value="1"/>
                    </DoubleAnimationUsingKeyFrames>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>              
              <!-- ExpansionStates -->
              <vsm:VisualStateGroup x:Name="LockedStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Locked">
                    <Storyboard>
                    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpanderButton" Storyboard.TargetProperty="IsEnabled">
                      <DiscreteObjectKeyFrame KeyTime="0" Value="False"/>
                    </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Unlocked">
                  <Storyboard>
                    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpanderButton" Storyboard.TargetProperty="IsEnabled">
                      <DiscreteObjectKeyFrame KeyTime="0" Value="True"/>
                    </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>
            </vsm:VisualStateManager.VisualStateGroups>
            <Border x:Name="Background" Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4">
              <Grid>
                <Grid.RowDefinitions>
                  <RowDefinition Height="Auto"/>
                  <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <layoutToolkitPrimitives:AccordionButton Template="{StaticResource AjaxHeader}" x:Name="ExpanderButton" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" IsChecked="{TemplateBinding IsSelected}" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Padding="4" Margin="0" FontFamily="{TemplateBinding FontFamily}" FontSize="14" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="Bold" Foreground="#FFFFFFFF" HorizontalContentAlignment="Left" VerticalContentAlignment="Center"/>

                <layoutToolkitPrimitives:ExpandableContentControl x:Name="ExpandSite" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Percentage="0" Background="#FFD3DEEF" RevealMode="{TemplateBinding ExpandDirection}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Padding="2" Margin="1" FontFamily="{TemplateBinding FontFamily}" FontSize="12" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="DarkGray" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" VerticalAlignment="Stretch" VerticalContentAlignment="Top"/>

              </Grid>
            </Border>
            <Border x:Name="DisabledVisualElement" IsHitTestVisible="false" Opacity="0" Background="#A5FFFFFF" CornerRadius="3"/>
            <Border x:Name="FocusVisualElement" IsHitTestVisible="false" Visibility="Collapsed" BorderThickness="1" CornerRadius="3">
              <Border.BorderBrush>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                  <GradientStop Color="#FFA3AEB9"/>
                  <GradientStop Color="#FF8399A9" Offset="0.375"/>
                  <GradientStop Color="#FF718597" Offset="0.375"/>
                  <GradientStop Color="#FF617584" Offset="1"/>
                </LinearGradientBrush>
              </Border.BorderBrush>
            </Border>
          </Grid>
        </ControlTemplate>
      </layoutToolkit:Accordion.Resources>

      <layoutToolkit:AccordionItem Header="1. Accordion" Template="{StaticResource ajaxTemplate}">
          <layoutToolkit:AccordionItem.Content>
          <TextBlock>
            The Accordion is a control that allows you to provide multiple panes and display them.<LineBreak/>
            There are several selection modes, so you can decide if only one pane can be open, <LineBreak/>
            or multiple.<LineBreak/>
            It is also possible to adjust the order in which the panes open and close:<LineBreak/>
            Simultaneous or close first. <LineBreak/>
            <LineBreak/>
            The Accordion is implemented as an itemscontrol that contains AccordionItem controls. <LineBreak/>
            Each AccordionItem control has a template for its Header and its Content. <LineBreak/>
          </TextBlock>
        </layoutToolkit:AccordionItem.Content>
      </layoutToolkit:AccordionItem>
      <layoutToolkit:AccordionItem Header="2. AutoSize" Template="{StaticResource ajaxTemplate}">
        <TextBlock>
          It also supports filling to a specific height or width. <LineBreak/>
          To do so, either set a Height (or Width) or use a VerticalAlignment <LineBreak/>
          (or HorizontalAlignment) of 'Stretch'. <LineBreak/>
          The Accordion will now always fill to that space. If more than one pane <LineBreak/>
          may be opened, space is divided equally among them.
          <LineBreak/>
          Whether you fill to height or width is determined by the ExpandDirection property.<LineBreak/>
          An accordion will is able to expand to Down, Up, Left and Right directions.
        </TextBlock>
      </layoutToolkit:AccordionItem>
      <layoutToolkit:AccordionItem Header="3. Template parts" Template="{StaticResource ajaxTemplate}">
        <TextBlock>
          The accordion uses AccordionItems that can be fully templated.<LineBreak/>
          In order to 'reveal' contents slowly, an ExpandableContentControl is used. <LineBreak/>
          That control has a percentage property that can be animated. A value of 1 <LineBreak/>
          means that the content is completely shown.<LineBreak/>
          <LineBreak/>
          AccordionItem animates this property using a keyspline to get a nice <LineBreak/>
          easing-in effect. You can retemplate AccordionItem and create your own <LineBreak/>
          transitions!<LineBreak/>
        </TextBlock>
      </layoutToolkit:AccordionItem>
    </layoutToolkit:Accordion>

    <ContentControl Content="Accordion restyled horizontally" Style="{StaticResource Header}"/>
    <layoutToolkit:Accordion ExpandDirection="Left" Background="#FFE7E7E7">
      <layoutToolkit:Accordion.Resources>
        <!-- horizontal header -->
        <ControlTemplate TargetType="layoutToolkitPrimitives:AccordionButton" x:Key="HorizontalHeader">
          <Grid Background="Transparent">
            <vsm:VisualStateManager.VisualStateGroups>
              <!-- ExpandDirectionStates -->
              <vsm:VisualStateGroup x:Name="ExpandDirectionStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="ExpandDown">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="ExpandUp">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="ExpandLeft">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="ExpandRight">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>
              <!-- ExpansionStates -->
              <vsm:VisualStateGroup x:Name="ExpansionStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Collapsed">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Expanded">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>
              <!-- CheckStates -->
              <vsm:VisualStateGroup x:Name="CheckStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="00:00:00"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Checked"/>
                <vsm:VisualState x:Name="Unchecked"/>
              </vsm:VisualStateGroup>
              <!-- CommonStates -->
              <vsm:VisualStateGroup x:Name="CommonStates">
                <vsm:VisualStateGroup.Transitions>
                  <vsm:VisualTransition GeneratedDuration="0"/>
                  <vsm:VisualTransition GeneratedDuration="00:00:00.1" From="MouseOver" To="Normal"/>
                  <vsm:VisualTransition GeneratedDuration="00:00:00.1" To="MouseOver"/>
                  <vsm:VisualTransition GeneratedDuration="00:00:00.1" To="Pressed"/>
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Normal"/>
                <vsm:VisualState x:Name="MouseOver">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Pressed">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Disabled">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
              </vsm:VisualStateGroup>
              <!-- FocusStates -->
              <vsm:VisualStateGroup x:Name="FocusStates">
                <vsm:VisualState x:Name="Focused">
                  <Storyboard>
                  </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Unfocused"/>
              </vsm:VisualStateGroup>
            </vsm:VisualStateManager.VisualStateGroups>

            <Border x:Name="MouseOverBackground" Background="Transparent">
              <Border x:Name="background" Background="Transparent">
                <Grid Width="20" Height="200" Margin="{TemplateBinding Padding}">

                  <Path Width="60" Data="M7.2912064,0.5 C35.733871,0.5 58.791206,44.375938 58.791206,98.5 C58.791206,152.62386 35.734119,196.5 7.2912064,196.5 C5.5135384,196.5 3.7569084,196.32861 2.025631,195.99403 L0.5,195.55096 L3.2518349,194.50899 C13.537304,189.28716 22.366497,174.14719 28.045227,153.29272 C30.884619,142.86546 32.936363,131.00955 33.988701,118.25042 C35.041069,105.49129 35.041069,91.508682 33.988701,78.74958 C31.884027,53.231354 25.781698,31.325907 17.37603,17.23686 C13.173197,10.192317 8.3945103,5.1018929 3.2518349,2.4910123 L0.5,1.4490361 L2.025631,1.0059637 C3.7569084,0.67139101 5.5135384,0.5 7.2912064,0.5 z" Stretch="Fill" Stroke="Black" StrokeThickness="2" Height="197" Margin="-40,0,0,0">
                    <Path.Fill>
                      <LinearGradientBrush EndPoint="-0.162,1.001" StartPoint="2.078,0.261">
                        <GradientStop Color="#FFC4C4C4"/>
                        <GradientStop Color="#FFF2F2F2" Offset="1"/>
                      </LinearGradientBrush>
                    </Path.Fill>
                  </Path>

                  <layoutToolkit:LayoutTransformer x:Name="header" Margin="0,0,5,0" RenderTransformOrigin="0.5,0.5" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Foreground="{TemplateBinding Foreground}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <layoutToolkit:LayoutTransformer.LayoutTransform>
                      <RotateTransform Angle="90"/>
                    </layoutToolkit:LayoutTransformer.LayoutTransform>
                  </layoutToolkit:LayoutTransformer>
                </Grid>

              </Border>
            </Border>
            <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="false" Stroke="Green" StrokeDashArray="1 2" StrokeThickness="1" Visibility="Collapsed"/>
          </Grid>
        </ControlTemplate>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

稚然 2024-09-17 12:22:51

我的机器上没有安装该工具包,但考虑到您的问题,我有一些建议供您尝试。

选项 1
查看您提供的 Accordion Control 模板,您可以修改 ExpandableContentControl 的样式。它当前有一个硬编码为“DarkGray”的前景。

这就是我正在讨论的行(搜索 Foreground=DarkGray)

<layoutToolkitPrimitives:ExpandableContentControl x:Name="ExpandSite" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Percentage="0" Background="#FFD3DEEF" RevealMode="{TemplateBinding ExpandDirection}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Padding="2" Margin="1" FontFamily="{TemplateBinding FontFamily}" FontSize="12" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="DarkGray" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" VerticalAlignment="Stretch" VerticalContentAlignment="Top"/>

选项 2
一个更简单的解决方法是设置 AccordianItems 中每个 TextBlock 的前景色。如果该值没有被您提供的实际内容覆盖,它们只会使用 ExandableContentControl 中定义的 DarkGray。

例如,您应该能够在 Textblock 上提供 Foreground=Red,如下所示:

 <layoutToolkit:AccordionItem Header="3. Template parts" Template="{StaticResource ajaxTemplate}">
    <TextBlock Foreground=Red>
      The accordion uses AccordionItems that can be fully templated.<LineBreak/>
      In order to 'reveal' contents slowly, an ExpandableContentControl is used. <LineBreak/>
      That control has a percentage property that can be animated. A value of 1 <LineBreak/>
      means that the content is completely shown.<LineBreak/>
      <LineBreak/>
      AccordionItem animates this property using a keyspline to get a nice <LineBreak/>
      easing-in effect. You can retemplate AccordionItem and create your own <LineBreak/>
      transitions!<LineBreak/>
    </TextBlock>
  </layoutToolkit:AccordionItem>

I don't have the Toolkit installed on my machine but looking at your problem I have a few suggestions for you to try.

Option 1
Looking at the Accordion Control Template you have supplied you can modify the ExpandableContentControl's style. It current has a Foreground hardcoded to "DarkGray".

This is the line I'm talking about (search for Foreground=DarkGray)

<layoutToolkitPrimitives:ExpandableContentControl x:Name="ExpandSite" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Percentage="0" Background="#FFD3DEEF" RevealMode="{TemplateBinding ExpandDirection}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Padding="2" Margin="1" FontFamily="{TemplateBinding FontFamily}" FontSize="12" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="DarkGray" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" VerticalAlignment="Stretch" VerticalContentAlignment="Top"/>

Option 2
An easier fix is to set the Foreground color of each of the TextBlocks in your AccordianItems. They will only use the DarkGray defined in the ExandableContentControl if the value isn't overridden by the actual content you supply.

For example you should be able to supply Foreground=Red on your Textblock as so:

 <layoutToolkit:AccordionItem Header="3. Template parts" Template="{StaticResource ajaxTemplate}">
    <TextBlock Foreground=Red>
      The accordion uses AccordionItems that can be fully templated.<LineBreak/>
      In order to 'reveal' contents slowly, an ExpandableContentControl is used. <LineBreak/>
      That control has a percentage property that can be animated. A value of 1 <LineBreak/>
      means that the content is completely shown.<LineBreak/>
      <LineBreak/>
      AccordionItem animates this property using a keyspline to get a nice <LineBreak/>
      easing-in effect. You can retemplate AccordionItem and create your own <LineBreak/>
      transitions!<LineBreak/>
    </TextBlock>
  </layoutToolkit:AccordionItem>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文