|
-
Apr 26th, 2010, 12:25 PM
#1
Thread Starter
Addicted Member
Best way for custom theme
Hi, so I want to be able to have interchangeable themes within my application and I thought of two ways I could do this:
Xaml Files
By this the user would be able to select an XAML file containing the brushes for the controls I want to style, so like this:
Code:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Normal -->
<LinearGradientBrush x:Key="NormalBackground" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#f1f5f6" Offset="0.0"/>
<GradientStop Color="#c9d7da" Offset="1.0"/>
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush x:Key="NormalBorder" Color="#1785f8" />
<SolidColorBrush x:Key="Foreground" Color="#637275" />
<Thickness x:Key="NormalThickness" Left="3" Top="3" Right="3" Bottom="3" />
</ResourceDictionary>
Are there any disadvantages to letting users doing this, such as them being able to add XAML on themselves like:
Code:
<Style x:Key="LeftScrollViewer" TargetType="{x:Type ScrollViewer}">
<!-- Rest of stuff here -->
Which would be a problem because I only intend certain parts of the application to be skinable, the XAML file would contain the brushes and then I would do the styling.
or
XML Files
So this was I was thinking that, like XAML files the users would be able to select one that would contain the theme data:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Theme>
<Normal Border="#1785f8" Thickness="0" Opacity="0.7" Foreground="#637275" Start="#f1f5f6" End="#c9d7da" />
</Theme>
Obviously this way isn't as flexible as merging XAML files, although it would stop users adding their own XAML to the application to edit stuff I don't want to be edited.
Any help on what way is better is appreciated, thankyou.
-
May 10th, 2010, 11:06 AM
#2
Lively Member
Re: Best way for custom theme
not sure if this is the best way, but it looks like this person thinks using 2 separate files is the best. I can't confirm or deny that is the best way, but thats probably the way that i will do it.
http://www.codeproject.com/KB/WPF/Sk...nWPFBlend.aspx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|