User Tools

Site Tools


notes:uwp:styles

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
notes:uwp:styles [2017/01/18]
admin
notes:uwp:styles [2017/03/06] (current)
admin
Line 189: Line 189:
 </​StackPanel>​ </​StackPanel>​
 </​code>​ </​code>​
 +
 +Example: Define **ThemeDictionaries**:​
 +
 +<code xml>
 +<​Application
 +    x:​Class="​TestApp.App"​
 +    xmlns="​http://​schemas.microsoft.com/​winfx/​2006/​xaml/​presentation"​
 +    xmlns:​x="​http://​schemas.microsoft.com/​winfx/​2006/​xaml"​
 +    xmlns:​local="​using:​TestApp"​
 +    RequestedTheme="​Light">​
 +
 +    <​Application.Resources>​
 +        <​ResourceDictionary>​
 +            <​ResourceDictionary.ThemeDictionaries>​
 +                <​ResourceDictionary x:​Key="​Dark">​
 +                    <Style x:​Key="​AppBodyTextBlockStyle"​ TargetType="​TextBlock" ​
 +                           ​BasedOn="​{StaticResource BodyTextBlockStyle}">​
 +                        <Setter Property="​Foreground"​ Value="​White"/>​
 +                    </​Style>​
 +
 +                    <Style x:​Key="​AppCaptionTextBlockStyle"​ TargetType="​TextBlock" ​
 +                           ​BasedOn="​{StaticResource CaptionTextBlockStyle}">​
 +                        <Setter Property="​FontSize"​ Value="​12"/>​
 +                        <Setter Property="​Foreground"​ Value="​White"/>​
 +                    </​Style>​
 +                </​ResourceDictionary>​
 +
 +                <​ResourceDictionary x:​Key="​Light">​
 +                    <Style x:​Key="​AppBodyTextBlockStyle"​ TargetType="​TextBlock" ​
 +                           ​BasedOn="​{StaticResource BodyTextBlockStyle}">​
 +                        <Setter Property="​Foreground"​ Value="​Black"/>​
 +                    </​Style>​
 +
 +                    <Style x:​Key="​AppCaptionTextBlockStyle"​ TargetType="​TextBlock" ​
 +                           ​BasedOn="​{StaticResource CaptionTextBlockStyle}">​
 +                        <Setter Property="​FontSize"​ Value="​12"/>​
 +                        <Setter Property="​Foreground"​ Value="​Black"/>​
 +                    </​Style>​
 +                </​ResourceDictionary>​
 +
 +                <!-- don't set the Foreground in a high contrast theme -->
 +                <​ResourceDictionary x:​Key="​HighContrast">​
 +                    <Style x:​Key="​AppBodyTextBlockStyle"​ TargetType="​TextBlock" ​
 +                           ​BasedOn="​{StaticResource BodyTextBlockStyle}"​ />
 +
 +                    <Style x:​Key="​AppCaptionTextBlockStyle"​ TargetType="​TextBlock" ​
 +                           ​BasedOn="​{StaticResource CaptionTextBlockStyle}">​
 +                        <Setter Property="​FontSize"​ Value="​12"/>​
 +                    </​Style>​
 +                </​ResourceDictionary>​
 +            </​ResourceDictionary.ThemeDictionaries>​
 +        </​ResourceDictionary>​
 +    </​Application.Resources>​
 +</​Application>​
 +</​code>​
 +
 +You can find more information on //​ThemeDictionaries//​ [[https://​docs.microsoft.com/​en-us/​uwp/​api/​Windows.UI.Xaml.ResourceDictionary#​Windows_UI_Xaml_ResourceDictionary_ThemeDictionaries_|here]].
  
notes/uwp/styles.txt ยท Last modified: 2017/03/06 by admin