2012-11-13 34 views
9

WPF teknolojisine yeni katılıyorum. WPF aşağıdaki pencere beyanı bulunur:WPF pencere gölge efekti

<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> 

Ama bunu çalıştırdığınızda, gölge görünmez. Ne yapabilirim, ya da yanlış nerede? Bir Window numaralı telefona

+0

: Eğer varsayılan pencere görünümünü değiştirmek istersem yerine, pencerenin içinde bulunan bir diğer kısmına efekti uygulamak zorunda çizim bölgesi ve pencerenin bir kenar boşluğunu gölge derinliğinin değerine göre ayarlamak da işe yarayabilir. – Silvermind

+0

@Silvermind, yönteminiz çalışmıyor. Gölge hala görüntülenemiyor ... – Victor

+0

Başımın tepesinden çıktı ve denemeye değdi :). Her neyse, HighCore'un cevabı yeterli olur. – Silvermind

cevap

29

DropShadowEffect uygulanmaz. o da bunun ötesinde olduğunu olabilir @HighCore cevabı yanında

<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

Çok teşekkür ederim! Çok kullanışlı bir örnek. –

+0

@HighCore, Teşekkür ederim, çok yardımcı oldu ve zamanımı kurtardım :) –

+0

Bir süredir bir Pencere üzerinde DropShadowEffect kullanıyorum. Belki bu cevap şimdi modası geçmiş. – 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'lerin bu soruyu nasıl yanıtladığı konusunda daha fazla ayrıntıya girmelisiniz. –