I would like to be able to programmatically associate some data with dependency properties in BitmapEffect . With a FrameworkElement element, such as TextBlock, there is a SetBinding method where you can programmatically perform these bindings, for example:
myTextBlock.SetBinding(TextBlock.TextProperty, new Binding("SomeProperty"));
And I know that you can do it in direct XAML (as shown below)
<TextBlock Width="Auto" Text="Some Content" x:Name="MyTextBlock" TextWrapping="Wrap" >
<TextBlock.BitmapEffect>
<BitmapEffectGroup>
<OuterGlowBitmapEffect x:Name="MyGlow" GlowColor="White" GlowSize="{Binding Path=MyValue}" />
</BitmapEffectGroup>
</TextBlock.BitmapEffect>
</TextBlock>
But I can't figure out how to do this with C #, because BitmapEffect does not have a SetBinding method.
I tried:
myTextBlock.SetBinding(OuterGlowBitmapEffect.GlowSize, new Binding("SomeProperty") { Source = someObject });
But that will not work.
source
share