L
Lloyd Dupont
I'm trying to create a subclass of Slider which slide from one color to the
next and has a gradient brush background.
The C# code has 2 new properties: StartColor, EndColor
The XAML code is the following:
==================
<Slider x:Class="TransparencySlider.ColorSlider"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="root">
<Slider.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="{Binding StartColor, ElementName=root}"
Offset="0.0"/>
<GradientStop Color="{Binding EndColor, ElementName=root}" Offset="1.0"
/>
</LinearGradientBrush>
</Slider.Background>
</Slider>
==================
however at runtime the gradient brush is all white and the log message (in
the output windows) is: "cannot find source element for the binding", i.e.
cannot find 'root', this slider, the control itself.
mmhh... why is that?
what should I write?
I'm running into a wall......
next and has a gradient brush background.
The C# code has 2 new properties: StartColor, EndColor
The XAML code is the following:
==================
<Slider x:Class="TransparencySlider.ColorSlider"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="root">
<Slider.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="{Binding StartColor, ElementName=root}"
Offset="0.0"/>
<GradientStop Color="{Binding EndColor, ElementName=root}" Offset="1.0"
/>
</LinearGradientBrush>
</Slider.Background>
</Slider>
==================
however at runtime the gradient brush is all white and the log message (in
the output windows) is: "cannot find source element for the binding", i.e.
cannot find 'root', this slider, the control itself.
mmhh... why is that?
what should I write?
I'm running into a wall......