2012-04-23 68 views
1

我使用silverlight模板創建了一個導航應用程序。我有4個選項卡Home, About, Info, Maps現在,當我選擇任何人都可以正常工作,但它看起來不像選擇哪一個。由於選定的一個標籤沒有顏色變化。如何更改silverlight導航應用程序中選項卡的顏色?

請建議我如何更改所選標籤的顏色?

感謝

+0

你可以提供一些所謂的標籤代碼示例?您是否使用帶有多個選項卡項目的選項卡控件,或者您正在討論作爲默認鏈接進入主頁面的鏈接按鈕? – Stainedart 2012-04-23 17:09:11

+0

是默認模板中的Home和About按鈕 – TheBond 2012-04-23 17:46:02

回答

0

我從來沒有與此明確地發揮自己,但默認樣式這個行爲是有

  <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); 
       } 
      } 
     } 
    } 

通知的進入狀態處於非活動狀態。此代碼來自導航silverlight項目的默認模板。 保持風格的StaticResource應該可以解決問題。那麼你可以去創建你自己的風格

相關問題