开发者

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 s开发者_开发知识库pecify 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.


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/


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.


Creating a custom style is a very large task, however, should you decide this is neccesary (it's not required). You can use Expression Blend to speed up the process.


Reuxables have a couple of free themes you can try. We've just bought one of their non-free ones and it's dead easy, you just throw in a reference in your app.xaml and it transforms your app. Easy to tailor, too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜