訪問 C 中的主題資源

來自 MyExampleFile.xaml 的片段

<TextBlock x:Name="MyTextBlock"
         Text="This is a TextBlock colored from the code behind"/>

來自 MyExampleFile.xaml.cs 的片段

    // We use the application's Resource dictionary to get the current Accent of your Windows 10
    MyTextBlock.Color = new SolidColorBrush(Application.Current.Resources["SystemAccentColor"]);