2012-11-13 3 views
9

저는 WPF 기술을 처음 사용합니다. WPF에서 다음 창 선언이 있습니다.WPF 창 그림자 효과

<Window x:Class="CustomWindows.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="MainWindow" Height="480" Width="640" ScrollViewer.VerticalScrollBarVisibility="Disabled" WindowStyle="None" AllowsTransparency="True"> 
    <Window.Effect> 
     <DropShadowEffect BlurRadius="15" Direction="-90" RenderingBias="Quality" ShadowDepth="2"/> 
    </Window.Effect> 
    <Grid> 

    </Grid> 
</Window> 

그러나 실행할 때 그림자가 나타나지 않습니다. 무엇을 할 수 있습니까? 또는 어디에서 실수입니까?

+0

: 기본 창 모양을 무시하려면 대신, 당신은 윈도우에 포함 된 다른 요소에 효과를 적용해야 그리기 영역과 그림자 깊이의 값과 동일한 여백을 설정하는 것도 효과가 있습니다. – Silvermind

+0

@ Silvermind, 당신의 방법은 작동하지 않습니다. 그림자는 여전히 표시 될 수 없습니다 ... – Victor

+0

그것은 내 머리 꼭대기에서 벗어나 시도 할만한 가치가 있습니다. :). 어쨌든 HighCore의 대답이면 충분합니다. – Silvermind

답변

29

DropShadowEffectWindow에 적용 할 수 없습니다. 그것은 또한 이상이라고 할 수 @HighCore의 대답 외에

<Window x:Class="WpfApplication2.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="MainWindow" Height="350" Width="525" WindowStyle="None" AllowsTransparency="True" Background="Transparent"> 
    <Grid Margin="20" Background="Red"> 
     <Grid.Effect> 
      <DropShadowEffect BlurRadius="15" Direction="-90" RenderingBias="Quality" ShadowDepth="2"/> 
     </Grid.Effect> 
     ... 

    </Grid> 
</Window> 
+1

대단히 감사합니다! 매우 유용한 예입니다. –

+0

@HighCore, 감사합니다. 매우 도움이되었고 시간을 절약 해주었습니다 :) –

+0

저는 한동안 창에 DropShadowEffect를 사용해 왔습니다. 아마도이 답변은 구형입니다. – OfficeAddinDev

-2
<Window 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:ee="http://schemas.microsoft.com/expression/2010/effects" 
     mc:Ignorable="d" 
     x:Class="Loader.MainWindow" 
     Title="MainWindow" Height="470" Width="770" Deactivated="WorkSpace_Deactivated" Activated="WorkSpace_Activated" 
     x:Name="WorkSpace" WindowStyle="None" AllowsTransparency="True"> 
    <Window.Background> 
     <SolidColorBrush/> 
    </Window.Background> 
    <Window.Effect> 
     <DropShadowEffect/> 
    </Window.Effect> 
    <Grid Background="#2D2D30" Height="450" Width="750"> 
     ... 
    </Grid> 

</Window> 
+5

OP 질문에 대한 답변에 대해 자세히 설명해야합니다. –