I'm working on a personal library to define styles.
I have created some DependecyProperty to manage style size.
Here is a part of the dependencies I have created :
public class CheckboxExtensions : CheckBox
{
public static readonly DependencyProperty CheckHeightProperty =
DependencyProperty.RegisterAttached(
"CheckHeight",
typeof(double),
typeof(CheckboxExtensions),
new PropertyMetadata(OnHeightChange));
public static void SetCheckHeight(UIElement element, double value)
{
element.SetValue(CheckHeightProperty, value);
}
public static readonly DependencyProperty LeftColorProperty =
DependencyProperty.RegisterAttached(
"LeftColor",
typeof(SolidColorBrush),
typeof(CheckboxExtensions));
public static void SetLeftColor(UIElement element, SolidColorBrush value)
{
element.SetValue(LeftColorProperty, value);
}
public static SolidColorBrush GetLeftColor(UIElement element)
{
return (SolidColorBrush)element.GetValue(LeftColorProperty);
}
}
And I can define colors like this in my style :
<Setter Property="extensions:CheckboxExtensions.LeftColor" Value="{DynamicResource Foreground}" />
<Setter Property="extensions:CheckboxExtensions.RightColor" Value="{DynamicResource ControlBackground.Flash}" />
When I use it directly in window, it's working but I have a design time that isn't showing the "bullet"
But I have a bigger problem. When I use it in a UserControl library and load that UserControl into an application. I got the same result as in design time. No color at all but size are correctly set.
How can I fix this ?