My application generates a dynamic number of styles in code-behind. I’d like to bind a specific property of those styles to a dependency property. It’s possible in XAML, but I found no way to do it in code-behind. Since Setter is no FrameworkElement, it does not provide a SetBinding() method. And since Setter.Value is no dependency property BindingOperations.SetBinding() won’t work either.
How does
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="{Binding FontSize}"/>
</Style>
look in code-behind?
Like this: