Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build Custom Theme or Use Standard Theme in WPF

Soon to be a professional .NET developer (I hope) I start to dig into Windows Presentation Foundation (WPF). Looking into several video tutorials, I find design of GUI a daunting task. Having to specify every color, on every element, in every situation, to every platform seems a bit too much. How can you make this process simpler, and more generic when it comes to design? Is there any templates to start from, or is one expected to specify a couple of hundred rows of XAML before the design is looking appealing?

Considering the code-block below...

<Style TargetType="{x:Type Button}">
    <Setter Property="Background" Value="LightGreen" />
    <Setter Property="Foreground" Value="DarkGreen" />
</Style>

... where properties for hover and pushed-button style is left out which need additional rows of XAML to do what the developer wants.

Might there be a simple XAML-editor around to increase productivity? If there isn't, its just to dig dip into XAML and start building styles too keep for later projects.

like image 337
Benny Skogberg Avatar asked Jul 08 '10 16:07

Benny Skogberg


2 Answers

Designing your own theme is great but it requires a lot of expertise and time. From my point of view its not a great idea to invest in designing your own theme, provided you already have so many themes availabe online. You can take one which suits you and modify it as per your needs.

I genrally refer these links for themes -

WPF Themes -

http://wpfthemes.codeplex.com/

http://wpf.codeplex.com/wikipage?title=WPF%20Themes&ProjectName=wpf

WPF Theme Selector

http://wpfthemeselector.codeplex.com/

Wpf Project With 21 Theme

https://marketplace.visualstudio.com/items?itemName=AliAlikhani.SahaWpfTheme2012

In case you need more options you can buy one here -

http://www.xamltemplates.net/wpf-themes/

like image 100
akjoshi Avatar answered Nov 08 '22 19:11

akjoshi


There is no requirement to create a Style. You can just use the default style. Consider this simple messagebox style window:

<Window x:Class="MyProject.Test"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        Title="Test" Height="217" Width="298">
    <StackPanel Orientation="Vertical">
       <Label>Here is the Message.</Label>
       <StackPanel Orientation="Horizontal">
           <Button>OK</Button>
           <Button>Cancel</Button>
       </StackPanel>
    </StackPanel>
</Window>

If you really need to re-style controls, I would pick and choose which ones to do. Otherwise, yes I think creating a custom style is a pretty big task.

like image 30
TheSean Avatar answered Nov 08 '22 19:11

TheSean