Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If you have elements within your device UI which require customization based on theme (ie, you wish to specify different colors depending on which theme is selected) then you have two the following options:

  1. Add a reference to Connexion.Share.Ui.Style and use one of our existing resources. Attached to this document are the dark.xaml and light.xaml files which define variables used within Connexion. You may dynamically reference one of these.

    Image Modified

2. Use code-behind to detect the theme (and when it changes) and use xaml bindings/styles to set the resources. In your viewmodel (or view class) you can use the IThemeProvider interface to hook theme infrastructure.

...

3. Bind to the IsDarkMode property directly in your XAML (Available in 16.1 R3 and newer):

Code Block
languagec#
<TextBlock>
  <TextBlock.Style>
    <Style TargetType="TextBlock">
      <Setter Property="Text" Value="LightMode" />
        <Style.Triggers>
          <DataTrigger Binding="{Binding Source={x:Static core:ThemeBinding.GlobalTheme}, Path=IsDarkMode, Mode=OneWay}"
                       Value="true">
            <Setter Property="Text" Value="DarkMode" />
          </DataTrigger>
        </Style.Triggers>
    </Style>
  </TextBlock.Style>
</TextBlock>

Specifically: Binding="{Binding Source={x:Static core:ThemeBinding.GlobalTheme}, Path=IsDarkMode, Mode=OneWay}"

You will need to add a reference to Connexion.Core in your XAML header (xmlns:core="Connexion.Core....)

Connexion Look & Feel

Within Connexion we have a general look and feel with our devices. If you wish to replicate this in your own devices, we recommend the following.

...