lucy
lucy
CC#
Created by lucy on 8/26/2023 in #help
❔ wpf styling/templating with custom dependency properties?
for example
<Slider Style="{StaticResource ColourSliderStyle}" GradientColour="#ff0000"/>

<!--in the resources file-->

<Style x:Key=ColourSliderStyle TargetType="x:Type Slider">
<Setter Property="MiddleColour">
<Setter.Value>
<GradientBrush>
<GradientStop Color="#000000" Offset="0"/>
<GradientStop Color="{[passed GradientColour]}" Offset="1"/>
</GradientBrush>
</Setter.Value>
</Setter>
</Style>
<Slider Style="{StaticResource ColourSliderStyle}" GradientColour="#ff0000"/>

<!--in the resources file-->

<Style x:Key=ColourSliderStyle TargetType="x:Type Slider">
<Setter Property="MiddleColour">
<Setter.Value>
<GradientBrush>
<GradientStop Color="#000000" Offset="0"/>
<GradientStop Color="{[passed GradientColour]}" Offset="1"/>
</GradientBrush>
</Setter.Value>
</Setter>
</Style>
15 replies
CC#
Created by lucy on 8/26/2023 in #help
❔ wpf styling/templating with custom dependency properties?
rather than having to pass in a unique brush for each colour you want to use as a gradient
15 replies
CC#
Created by lucy on 8/26/2023 in #help
❔ wpf styling/templating with custom dependency properties?
yes, but i'm asking specifically is there a way to get it so you have the compnent, give it a style, give it a GradientColour, and the style handles translating GradientColour into a gradient brush
15 replies
CC#
Created by lucy on 8/26/2023 in #help
❔ wpf styling/templating with custom dependency properties?
with the second question, so the MiddleColour is a brush, but i'd like a style that gives it a gradient brush that goes from #000000 to a given colour GradientColour
15 replies
CC#
Created by lucy on 8/26/2023 in #help
❔ wpf styling/templating with custom dependency properties?
tyty
15 replies