Pompair
Pompair

Reputation: 7319

Binding to a value within a Resource?

Assuming one has this Resource:

<Window.Resources>
  <ImageBrush x:Key="MyImageBrush" Opacity="0.5"
             ImageSource="image1.png" Stretch="None" 
             AlignmentX="Center" AlignmentY="Center" />
</Window.Resources>

Then how would I get to the Opacity value of that resource? I've tried the following but it doesn't work.

<TextBlock Text="{Binding ElementName=MyImageBrush, Path=Opacity}" />

Upvotes: 0

Views: 95

Answers (1)

Kent Boogaart
Kent Boogaart

Reputation: 178810

<TextBlock Text="{Binding Source={StaticResource MyImageBrush}, Path=Opacity}" />

Upvotes: 1

Related Questions