I want to access a property nested inside a style's control template. I know that you can do this in the code-behind:
GradientStop stop = (GradientStop)progressBar1.Template.FindName("gradStop", progressBar1);
stop.Color = Colors.Black;
Is it possible to do the same, but in the XAML? For example:
<ProgressBar Style="{StaticResource CustomProgressBar}" [???].Color="FF000000"/>
Can you not use TemplateBinding?
<Style x:Key="MyStyle" TargetType="{x:Type ContentControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContentControl}">
<Border Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Background="{TemplateBinding Background}" >
<ContentPresenter />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Then specify the template bound values when you apply the style.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With