Home > DeveloperSection > Forums > DropShadow for WPF Borderless Window
marcel ethan
marcel ethan

Total Post:105

Points:735
Posted on    July-18-2013 2:29 AM

 WPF WPF 
Ratings:


 1 Reply(s)
 5490  View(s)
Rate this:
Hi !

I have a WPF Window with WindowStyle set to none. Is there some way I can force this window to drop a shadow (like the one you get when WindowStyle is not none)? I don't want to set AllowTransparency to true, because it affects the performance. And I also don't want to disable hardware rendering (I read somewhere that transparency performs better with it disabled).



shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Points:735
Posted on    July-18-2013 2:49 AM

Solution!


I have a WPF Window with WindowStyle set to none. Is there some way I can force this window to drop a shadow (like the one you get when WindowStyle is not none)? I don't want to set AllowTransparency to true, because it affects the performance. And I also don't want to disable hardware rendering (I read somewhere that transparency performs better with it disabled).

Answer 8:-

I made this from XAML code. Try this, too:

<Window x:Class="CustomWPFWindowShaddow.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="MainWindow" Height="215" Width="525" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" WindowStyle="None" AllowsTransparency="True">

    <Grid>

        <Border BorderBrush="#FF006900" BorderThickness="3" Height="157" HorizontalAlignment="Left" Margin="12,12,0,0" Name="border1" VerticalAlignment="Top" Width="479" Background="#FFCEFFE1" CornerRadius="20, 20, 20, 20">

            <Border.BitmapEffect>

                <DropShadowBitmapEffect Color="Black" Direction="320" ShadowDepth="10" Opacity="0.5" Softness="5" />

            </Border.BitmapEffect>

            <TextBlock Height="179" Name="textBlock1" Text="Hello, this is a beautiful DropShadow WPF Window Example." FontSize="40" TextWrapping="Wrap" TextAlignment="Center" Foreground="#FF245829" />

        </Border>

    </Grid>

    <Window.Background>

        <SolidColorBrush />

    </Window.Background>


Modified On Mar-18-2016 06:53:34 AM

Don't want to miss updates? Please click the below button!

Follow MindStick