如何在银光导航应用程序中更改选项卡的颜色
本文关键字:选项 颜色 应用程序 导航 | 更新日期: 2023-09-27 18:31:57
我使用Silverlight模板创建了一个导航应用程序。我确实有 4 个名为 Home, About, Info, Maps
的选项卡现在,当我选择任何人时,它工作正常,但看起来不像选择了哪一个。由于所选选项卡的颜色没有变化。
请建议我如何更改所选选项卡的颜色?
谢谢
我自己从未明确使用过这个,但是对于默认样式,这种行为是存在的
<Border x:Name="LinksBorder" Style="{StaticResource LinksBorderStyle}">
<StackPanel x:Name="LinksStackPanel" Style="{StaticResource LinksStackPanelStyle}">
<HyperlinkButton x:Name="Link2" Style="{StaticResource LinkStyle}"
NavigateUri="/About" TargetName="ContentFrame" Content="About"/>
</StackPanel>
</Border>
在后面的代码中:
// After the Frame navigates, ensure the HyperlinkButton representing the current page is selected
private void ContentFrame_Navigated(object sender, NavigationEventArgs e)
{
//This is to hide/show the leftside menu
ApplyConfiguration(ApplicationConfiguration.GetConfiguration());
foreach (UIElement child in LinksStackPanel.Children)
{
HyperlinkButton hb = child as HyperlinkButton;
if (hb != null && hb.NavigateUri != null)
{
if (hb.NavigateUri.ToString().Equals(e.Uri.ToString()))
{
VisualStateManager.GoToState(hb, "ActiveLink", true);
}
else
{
VisualStateManager.GoToState(hb, "InactiveLink", true);
}
}
}
}
请注意 goto 状态为"活动"为"非活动"。此代码来自导航 silverlight 项目的默认模板。保留样式的静态资源应该可以解决此问题。然后你可以去创造自己的风格