如何更改未选定的数据透视表标题的颜色?

发布于 2024-11-07 10:44:16 字数 5122 浏览 0 评论 0原文

我想做的是更改未选择的数据透视表标题的颜色。我总是在 WP7 Silverlight 应用程序中使用 Blend 进行样式设计,现在当我查看 XAML 时,我不知道发生了什么。 我在遵循 PivotStyle 方面需要很少的帮助:

<Style x:Key="PivotStyle" TargetType="controls:Pivot">
            <Setter Property="Margin" Value="0"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <Grid/>
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="controls:Pivot">
                        <Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid Background="{TemplateBinding Background}" CacheMode="BitmapCache" Grid.RowSpan="3"/>
                            <ContentPresenter ContentTemplate="{TemplateBinding TitleTemplate}" Content="{TemplateBinding Title}" Margin="24,17,0,-7"/>

                            <controlsPrimitives:PivotHeadersControl Grid.Row="1"  x:Name="HeadersListElement" FontSize="{StaticResource PhoneFontSizeExtraExtraLarge}" FontFamily="{StaticResource PhoneFontFamilySemiLight}">
                                <controlsPrimitives:PivotHeadersControl.ItemContainerStyle>
                                    <Style TargetType="controlsPrimitives:PivotHeaderItem">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="controlsPrimitives:PivotHeaderItem">
                                                    <Grid>
                                                        <VisualStateManager.VisualStateGroups>
                                                            <VisualStateGroup x:Name="SelectionStates">
                                                                <VisualState x:Name="Unselected"/>
                                                                <VisualState x:Name="Selected">
                                                                    <Storyboard>
                                                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="contentPresenter"/>
                                                                    </Storyboard>
                                                                </VisualState>
                                                            </VisualStateGroup>
                                                        </VisualStateManager.VisualStateGroups>
                                                        <ContentPresenter                                                             
                                                            x:Name="contentPresenter" 
                                                            Content="{TemplateBinding Content}"                                                                                                 
                                                            Opacity="1"
                                                            ContentTemplate="{TemplateBinding ContentTemplate}"
                                                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                            Margin="{TemplateBinding Padding}"/>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </controlsPrimitives:PivotHeadersControl.ItemContainerStyle>
                            </controlsPrimitives:PivotHeadersControl>

                            <ItemsPresenter x:Name="PivotItemPresenter" Margin="{TemplateBinding Padding}" Grid.Row="2"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

What I'm trying to do is changing color for unselected pivot header. I always used Blend for styling design in WP7 Silverlight apps and now when I'm looking at XAML I don't know what's going on.
I need little help in following PivotStyle:

<Style x:Key="PivotStyle" TargetType="controls:Pivot">
            <Setter Property="Margin" Value="0"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <Grid/>
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="controls:Pivot">
                        <Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Grid Background="{TemplateBinding Background}" CacheMode="BitmapCache" Grid.RowSpan="3"/>
                            <ContentPresenter ContentTemplate="{TemplateBinding TitleTemplate}" Content="{TemplateBinding Title}" Margin="24,17,0,-7"/>

                            <controlsPrimitives:PivotHeadersControl Grid.Row="1"  x:Name="HeadersListElement" FontSize="{StaticResource PhoneFontSizeExtraExtraLarge}" FontFamily="{StaticResource PhoneFontFamilySemiLight}">
                                <controlsPrimitives:PivotHeadersControl.ItemContainerStyle>
                                    <Style TargetType="controlsPrimitives:PivotHeaderItem">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="controlsPrimitives:PivotHeaderItem">
                                                    <Grid>
                                                        <VisualStateManager.VisualStateGroups>
                                                            <VisualStateGroup x:Name="SelectionStates">
                                                                <VisualState x:Name="Unselected"/>
                                                                <VisualState x:Name="Selected">
                                                                    <Storyboard>
                                                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="contentPresenter"/>
                                                                    </Storyboard>
                                                                </VisualState>
                                                            </VisualStateGroup>
                                                        </VisualStateManager.VisualStateGroups>
                                                        <ContentPresenter                                                             
                                                            x:Name="contentPresenter" 
                                                            Content="{TemplateBinding Content}"                                                                                                 
                                                            Opacity="1"
                                                            ContentTemplate="{TemplateBinding ContentTemplate}"
                                                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                            Margin="{TemplateBinding Padding}"/>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </controlsPrimitives:PivotHeadersControl.ItemContainerStyle>
                            </controlsPrimitives:PivotHeadersControl>

                            <ItemsPresenter x:Name="PivotItemPresenter" Margin="{TemplateBinding Padding}" Grid.Row="2"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

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

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

发布评论

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

评论(1

云胡 2024-11-14 10:44:16

您需要为“选定”或“未选定”状态设置不同的 VisualState。
请参阅 http://social。 msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/2146f5c9-e009-4b72-b4e9-43eec458c7cc

You'll need to set a different VisualState for either the Selected or Unselected state.
See http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/2146f5c9-e009-4b72-b4e9-43eec458c7cc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文