Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#/WPF: How do I separate structure from styles like in web programming?

Tags:

c#

styles

wpf

When programming for the web, you normally separate structure from style using a separation of HTML and CSS.

How do I accomplish the same in a WPF project? All the examples I find use "inline" styling. Is it possible at all? Does it even make any sense in WPF?

like image 294
Deniz Dogan Avatar asked Feb 13 '26 13:02

Deniz Dogan


1 Answers

You can pull out all styles into separate XAML files and only reference them from the XAML files that define your UI structure. ResourceDictionarys are your friend here.

Actually that's both common and recommended in WPF.

like image 185
Joey Avatar answered Feb 15 '26 04:02

Joey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!