Eduardo Brites
Eduardo Brites

Reputation: 4786

Setting the background with an existing brush

Imagine I have this brush:

<SolidColorBrush x:Key="MySolidDarkBackground" Color="{DynamicResource DarkBackgroundColorTop}" />

How can I use this brush for a scrollviewer background but with a different opacity?

<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1">
            <ScrollViewer.Background>
                < ??? >
            </ScrollViewer.Background>
</ScrollViewer>

Upvotes: 1

Views: 234

Answers (1)

Ross
Ross

Reputation: 4578

You'd either have to create a second Brush resource and use it:

<SolidColorBrush x:Key="MyTransparentDarkBackground" Opacity="0.5" Color="{DynamicResource DarkBackgroundColorTop}" />
<ScrollViewer Background="{DynamicResource MyTransparentDarkBackground}" />

Or you could just reuse the dynamic Color resource:

<ScrollViewer>
  <ScrollViewer.Background>
    <SolidColorBrush Opacity="0.5" Color="{DynamicResource DarkBackgroundColorTop}" />
  </ScrollViewer.Background>
</ScrollViewer>

Upvotes: 1

Related Questions