繁体   English   中英

在Windows Phone 8中更改枢纽项目的backgorund

[英]change the backgorund of the pivot item in windows phone 8

我有风格

  <Style x:Key="PivotStyle1" TargetType="phone: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="phone: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"/>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Image
                                Height="45"
                                HorizontalAlignment="Left"
                                Margin="12,0,0,0"
                                VerticalAlignment="Bottom"
                                Source="/Assets/Icons/MyTasks.png" />
                            <ContentControl
                                ContentTemplate="{TemplateBinding TitleTemplate}"
                                Content="{TemplateBinding Title}"
                                Grid.Column="1"
                                HorizontalAlignment="Left"
                                Margin="10,0,0,-7"
                                VerticalAlignment="Center"
                                Style="{StaticResource PivotTitleStyle}"/>
                            <Image
                                Grid.Column="2"
                                Height="55" Margin="0,10,20,0"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Bottom"
                                Source="/Assets/Icons/Settings.png"/>
                        </Grid>
                        <Primitives:PivotHeadersControl x:Name="HeadersListElement" Grid.Row="1"/>
                        <ItemsPresenter x:Name="PivotItemPresenter" Margin="{TemplateBinding Padding}"
                                        Grid.Row="2"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

这是我的枢纽代码:

 <phone:Pivot Title="MY TASKS" Style="{StaticResource PivotStyle1}" >

        <!--Pivot item one-->
        <phone:PivotItem Header="all">               

        </phone:PivotItem>

        <phone:PivotItem Header="assigned">

        </phone:PivotItem>

        <phone:PivotItem Header="overdue">

        </phone:PivotItem>
    </phone:Pivot>

我想更改枢纽项目的颜色。 枢纽项目标头“全部”为红色,枢纽项目“已分配”为绿色。 我试图更改背景,但这会更改整个背景。 请提出建议。

这个为我工作。

 <phone:PivotItem>
            <phone:PivotItem.Header>
                <TextBlock Text="assigned" Foreground="#FF145377"></TextBlock>
            </phone:PivotItem.Header>
        </phone:PivotItem>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM