❔ wpf styling/templating with custom dependency properties?
is there a way to use custom dependency properties with styles and templates?
for example
if I want a property, MiddleColour, on a template for a slider, that changes the background colour of the middle bit of the slider
and I want to be able to change that colour using a style.
Is that possible?
Continuing on,
would it also be possible to pass a property to the style, eg GradientColour, which is then used and passed to the MiddleColour in the template?
Thanks
6 Replies
you can customize the visuals of a control by providing it a custom ControlTemplate
and in theory, I think you could define your
MiddleColour
property as an attached property, and be able to bind to that from within the template
not entirely sure what you're asking with the second questiontyty
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
well, that is a thing you can do with brushes
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
rather than having to pass in a unique brush for each colour you want to use as a gradient
for example
yeah, that should be doable, assuming what I said earlier is doable
with
passed
being an attached property
and with that being inside a ControlTemplate
you'd have that be a TemplateBinding
IIRCWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.