2009-07-02 64 views
0

假設一個有這個資源:綁定到資源中的值?

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

那麼我將如何得到該資源的不透明度值? 我試過以下,但它不起作用。

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

回答

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