DROPSHADOW FOR WPF BORDERLESS WINDOW

marcel ethan

Total Post:105

Points:735
Posted by  marcel ethan
WPF 
WPF
 6849  View(s)
Ratings:
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).

  1. shreesh chandra shukla

    Post:105

    Points:735
    Re: DropShadow for WPF Borderless Window

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!