Hello,
I am evaluating your control suit for WPF and I find it extremely tedious and tiresome to colorize a control. I have to reimplement the control template just for a simple color change. Not only this is extremely counter-productive, it can lead to errors when the template is updated on a future UI for WPF version.
Let's take the simple case of a DropDownButton control. I want to have 2 dropdownbutton controls. I have settled on the theme, say Office2013 theme. I want the e.g. selected background on the first control to be red and on the second control green.
How can I do this easily if I don't have a simple property to set? You don't even expose the theme colors as *attached* properties, like in the code I am posting below (no complete code included for brevity) in order to make our lives easier.
<Style x:Key="RadDropDownButtonOffice2013ColorizableStyle" TargetType="telerik:RadDropDownButton">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FontFamily" Value="Calibri" />
<Setter Property="MinHeight" Value="26" />
<Setter Property="Padding" Value="6 2" />
<Setter Property="FontSize" Value="15" />
<Setter Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource Self}, Path=(t:Office2013Brushes.HighDarkBrush)}" />
<Setter Property="Background" Value="{Binding RelativeSource={RelativeSource Self}, Path=(t:Office2013Brushes.BasicBrush)}" />
<Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource Self}, Path=(t:Office2013Brushes.InvertedBrush)}" />
<Setter Property="CornerRadius" Value="0" />
<Setter Property="IsOpen" Value="false" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="telerik:RadDropDownButton">
<Grid SnapsToDevicePixels="True">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Path" Storyboard.TargetProperty="Fill">
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(t:Office2013Brushes.InvertedBrush)}" />
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation Duration="00:00:00.25" Storyboard.TargetName="OuterMouseOverBorder" Storyboard.TargetProperty="(UIElement.Opacity)" To="1" />
</Storyboard>
</VisualState>
...... etc.................
and a static class to define the attached properties as shown below:
namespace Telerik
{
public static class Office2013Brushes
{
#region Attached property BasicBrush
//Define and register attached property
public static readonly DependencyProperty BasicBrushProperty = DependencyProperty.RegisterAttached(
"BasicBrush",
typeof(Brush),
typeof(Office2013Brushes),
new FrameworkPropertyMetadata(new SolidColorBrush(Office2013Palette.Palette.BasicColor), FrameworkPropertyMetadataOptions.Inherits)
);
//Get/Set methods
public static Brush GetBasicBrush(DependencyObject obj)
{
return (Brush)obj.GetValue(BasicBrushProperty);
}
public static void SetBasicBrush(DependencyObject obj, Brush value)
{
obj.SetValue(BasicBrushProperty, value);
}
#endregion
#region Attached property MainBrush
//Define and register attached property
public static readonly DependencyProperty MainBrushProperty = DependencyProperty.RegisterAttached(
"MainBrush",
typeof(Brush),
typeof(Office2013Brushes),
new FrameworkPropertyMetadata(new SolidColorBrush(Office2013Palette.Palette.MainColor), FrameworkPropertyMetadataOptions.Inherits)
);
//Get/Set methods
public static Brush GetMainBrush(DependencyObject obj)
{
return (Brush)obj.GetValue(MainBrushProperty);
}
public static void SetMainBrush(DependencyObject obj, Brush value)
{
obj.SetValue(MainBrushProperty, value);
}
#endregion
........ etc..
The above code works fine: I can set the colors of the controls independently if I want to, or leave it to the default theme color. But, as it's easily understood, it is counter-productive for the developer to rewrite all the templates with the above logic.
The question is:
a) why you haven't created your controls to be "independently colorizable" (using attached properties or any other method you see fit)
b) if you are planning to implement some pattern to make "colorization" easier.
Best regards,
Theodore