Windows phone 8 透视项目标题颜色更改所有标题的不透明度在windows Phone 8.1透视控件中保持不变

Windows phone 8 透视项目标题颜色更改所有标题的不透明度在windows Phone 8.1透视控件中保持不变,windows-phone-8,windows-8.1,windows-phone-8.1,Windows Phone 8,Windows 8.1,Windows Phone 8.1,我正在使用Windows Phone 8.1中的Pivot控件我将pivotitem标题的前景属性设置为红色它工作正常,但我将所有项目标题设置为红色,并且项目标题的不透明度不会改变未聚焦的pivotitem云请帮助我如何解决此问题 问题 这是密码 <Pivot Title="Pivot Title" > <PivotItem > <PivotItem.Header > <Tex

我正在使用Windows Phone 8.1中的Pivot控件我将pivotitem标题的前景属性设置为红色它工作正常,但我将所有项目标题设置为红色,并且项目标题的不透明度不会改变未聚焦的pivotitem云请帮助我如何解决此问题
问题 这是密码

   <Pivot Title="Pivot Title" >
        <PivotItem >
            <PivotItem.Header >
                <TextBlock Text="One" Foreground="Red" FontSize="48"/>
            </PivotItem.Header>
        </PivotItem>
        <PivotItem>
            <PivotItem.Header>
                <TextBlock Text="two" Foreground="Red" FontSize="48"/>
            </PivotItem.Header>
        </PivotItem>
        <PivotItem>
            <PivotItem.Header>
                <TextBlock Text="three" Foreground="Red" FontSize="48"/>
            </PivotItem.Header>
        </PivotItem>
    </Pivot>

我想您需要为选中或未选中状态设置不同的
VisualState

看看这里

或者,您可以将
SelectionChanged
事件处理程序用于透视:

private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (e.AddedItems.Count > 0)
    {
        PivotItem currentItem = e.AddedItems[0] as PivotItem;

        if (currentItem != null)
        {
            (currentItem.Header as TextBlock).Foreground = new SolidColorBrush(Colors.White);
        }
    }

    if (e.RemovedItems.Count > 0)
    {
        PivotItem currentItem = e.RemovedItems[0] as PivotItem;

        if (currentItem != null)
        {
            (currentItem.Header as TextBlock).Foreground = new SolidColorBrush(Colors.Red);
        }
    }
}

希望有帮助

默认样式应该在资源字典中被覆盖


您的意思是未聚焦的轴项目的标题颜色没有改变?是的,如果我没有设置任何背景颜色,当我改变背景颜色时,它工作正常。在选择更改时,它不工作。我们可以写入,但我想在选定和未选定的视觉状态下写入。您能帮助我写入视觉状态吗已选和未选的名称States@HarishKinthali我上面提供的链接只讨论视觉状态。它是针对Windows Phone 8的。我正在使用Windows Phone 8.1,它在Windows 8中工作,但在Windows 8.1中不工作