Reputation: 4830
In WPF, I have rectangle like this:
<Rectangle Grid.Column="1" Name="rectangleSignal" HorizontalAlignment="Left" Width="20" Height="20" >
<Rectangle.Fill>
<StaticResource ResourceKey="image0" />
</Rectangle.Fill>
</Rectangle>
In .cs file. In some cases, I want to set this rectangle to be transparent. I have code like this, What should I do for Resourcekey, that I can make this rectangele be transparent? thank you
rectangleSignal.SetResourceReference(Rectangle.FillProperty, "image0");
Edited:
I figured out myself. Just setting peroperty to "#FFFFFFFF" It will be fine. Thanks everyone.
Upvotes: 1
Views: 1958
Reputation: 184516
If you need to keep that reference you can add Brushes.Transparent
as a resource with that key, if you do not need to do that make an assigment to Fill. Alternatively you can also just set the Visibility
or Opacity
.
Upvotes: 2