有点棘手,我是这样做的。
<ControlTemplate x:Key="ShadowBorderShadowTemplate">
<!-- Start shadow effect to fragment -->
<Grid x:Name="Transform">
<Border BorderThickness="1"
BorderBrush="Gray"
Background="{x:Null}"
Margin="1">
<Border.Effect>
<DropShadowEffect BlurRadius="6"
Direction="270"
ShadowDepth="2" />
</Border.Effect>
</Border>
<Border BorderThickness="0"
Margin="1,2,1,1"
BorderBrush="{x:Null}"
Background="White" />
</Grid>
<!-- End shadow effect to fragment -->
</ControlTemplate>
<ControlTemplate x:Key="ContentControlTemplateWithShadow"
TargetType="{x:Type ContentControl}">
<Grid>
<!-- Shadow around the left nav -->
<ContentControl Template="{DynamicResource ShadowBorderShadowTemplate}" />
<ContentPresenter />
</Grid>
</ControlTemplate>
并使用类似的资源
<ContentControl Template="{StaticResource ContentControlTemplateWithShadow}">
<Border>
<Canvas>
<TextBox Text="ABCD" Canvas.Left="115" Canvas.Top="134" />
<Button Canvas.Left="115" Canvas.Top="91">Test</Button>
<ComboBox Canvas.Left="115" Canvas.Top="54" />
</Canvas>
</Border>
</ContentControl>
希望能帮助到你..