我有阴影效果的问题所以我决定用矩形替换阴影。看起来不错,但问题是矩形没有绘制在自己的容器上。
<!-- Window -->
<Viewbox x:Name="viewboxDC">
<Grid>
<!-- Shadow -->
<Rectangle Panel.ZIndex="-1" Margin="0,0,-12,-12" Width="1282" Height="722" Fill="#7F000000" />
<Border x:Name="BorderWindowSize" BorderBrush="Black" BorderThickness="1" Background="White" Width="1282" Height="722">
<Canvas Panel.ZIndex="1" x:Name="DesignCanvas" Background="White" MouseDown="DesignCanvas_MouseDown" >
</Canvas>
</Border>
</Grid>
</Viewbox>
有没有什么可以忽略容器大小?还是快速替代Drophadow效果? 感谢。
答案 0 :(得分:2)
尝试放置Canvas:
遇到同样的问题:
<Canvas x:Name="ClipCanvas" Grid.Row="0">
<Viewbox x:Name="Pin" RenderTransformOrigin=".5,1" Height="72" Margin="6,-72,0,0"
Visibility="Collapsed">
<Grid>
<Path
Data="blubb"
Fill="{DynamicResource PrimaryBrush}"
Grid.Row="0" Margin="-7,2,-8,4" />
<TextBlock x:Name="FormattedValue"
Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type vw:Slider}}, Path=FormattedValue}"
Foreground="{DynamicResource PrimaryForegroundBrush}"
HorizontalAlignment="Center" VerticalAlignment="Center"
FontWeight="Normal" FontSize="11"
Margin="-7 -6 -7 0" />
</Grid>
<Viewbox.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="0" ScaleY="0" />
<TranslateTransform Y="4" />
</TransformGroup>
</Viewbox.RenderTransform>
</Viewbox>
</Canvas>
我想在Viewbox之外画画。这解决了我的问题。