[ACCEPTED]-How do I apply an effect to a Border but not to its contents in WPF?-border
Accepted answer
The link from gcores had the answer, which 3 is to put the border and its content together 2 in the same grid so the content overlays 1 the border.
<Window x:Class="WpfEffectTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Border BorderBrush="Black" BorderThickness="10" CornerRadius="5" Margin="25">
<Border.Effect>
<DropShadowEffect BlurRadius="10" ShadowDepth="5" />
</Border.Effect>
</Border>
<StackPanel Margin="35">
<TextBlock>This is some text</TextBlock>
<TextBlock>This is some text</TextBlock>
<TextBlock>This is some text</TextBlock>
<TextBlock>This is some text</TextBlock>
<TextBlock>This is some text</TextBlock>
<TextBlock>This is some text</TextBlock>
</StackPanel>
</Grid>
</Window>
One simple (hack?) solution is to do
<StackPanel Background="White">
This 6 should solve the text with drop-shadow problem 5 (Not sure about the performance problem 4 though). The problem is that WPF applies 3 effects to the set element and all it's 2 children in the visual tree. This link 1 explains it better: DropShadowEffect performance issue
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.