2014-01-22 49 views
2

在Windows 8中,您可以爲應用程序創建自己的主題(here's a tutorial)。在Windows 8.1中創建主題

在Windows 8.1應用程序中,主題處理方式不同:您可以在運行時更改它們,併爲XAML中的特定控件設置主題(如果您不想將主題應用於整個應用程序)。

例如:

<Grid x:Name="MainGrid" RequestedTheme="Dark"> 

但是,我無法找到一個方法來創建自己的主題。屬性RequestedTheme需要枚舉(其類型爲FrameworkElement.RequestedTheme),並且定義中的枚舉不能擴展(在C#中)。另外,如果我想定義一個新的Theme Dictionary我會寫:

<ResourceDictionary.ThemeDictionaries> 

但它並不提供在Windows 8.1。

如何在Windows 8.1中創建主題?我僅限於現有的(光暗&黑暗)?

+0

您不會創建新主題,而是覆蓋3個現有主題。 – WiredPrairie

回答

3

是你限制在3個主題,我相信

默認(光) 黑暗 高對比度

您可以創建新的樣式或覆蓋了3個主題這樣現有的8.1 ​​

<ResourceDictionary.ThemeDictionaries> 
      <ResourceDictionary x:Key="Default"> 
       <Style TargetType="TextBlock"> 
        <Setter Property="FontSize" Value="24" /> 
        <Setter Property="Foreground" Value="Green"/> 
       </Style> 
      </ResourceDictionary> 
      <ResourceDictionary x:Key="Dark"> 
       <Style TargetType="TextBlock"> 
        <Setter Property="FontSize" Value="30" /> 
        <Setter Property="Foreground" Value="Orange"/> 
       </Style> 
      </ResourceDictionary> 
      <ResourceDictionary x:Key="HighContrast"> 
       <Style TargetType="TextBlock"> 
        <Setter Property="FontSize" Value="24" /> 
        <Setter Property="Foreground" Value="Blue"/> 
       </Style> 
      </ResourceDictionary>    
     </ResourceDictionary.ThemeDictionaries>