You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: wpf/Themes/Skin-Manager.md
+69Lines changed: 69 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -536,6 +536,75 @@ Dark Theme:
536
536
537
537

538
538
539
+
### Accessing Theme Resources Using TryFindResource
540
+
541
+
To access specific theme resources in your WPF application, you can use the `TryFindResource(key)` method to retrieve a resource by its key and apply it in the code-behind.
542
+
543
+
Theme resource keys are typically defined in:
544
+
545
+
1)**Brushes.xaml:** Contains brush-related keys such as ContentBackground, ContentForeground, etc.
546
+
547
+
2)**Common.xaml:** Contains font size and style keys like HeaderTextStyle, SubHeaderTextStyle, etc.
548
+
549
+
These files are located under the Common folder when [exporting a theme from ThemeStudio](https://help.syncfusion.com/wpf/themes/theme-studio#exporting-theme-project). You can also refer to the [Resource Key list](https://help.syncfusion.com/wpf/themes/skin-manager#resource-key-list) to locate specific styles for various controls.
SolidColorBrush backgroundBrush = TryFindResource(foregroundStyleKey) as SolidColorBrush;
595
+
myButton.Foreground = backgroundBrush;
596
+
}
597
+
598
+
{% endhighlight %}
599
+
600
+
{% endtabs %}
601
+
602
+
This example demonstrates how to dynamically apply a button style, foreground color, and font size using theme resource keys defined in the Brushes.xaml and Common.xaml files for the Windows11Light theme.
603
+
604
+
**Output Screenshot**
605
+
606
+

0 commit comments