问题描述
我想设置 DropShadowPanel 的宽度和高度在仍然保持纵横比的情况下取决于其父级。
<Grid Background="White" Padding="10,10,10">
<controls:DropShadowPanel Color="Black"
BlurRadius="30"
ShadowOpacity=".7"
Width="200" Height="300"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch">
<Grid />
</controls:DropShadowPanel>
</Grid>
调整窗口大小(调整网格父级)时,其宽度或高度将更改为最大值。 我该怎么办?
解决方法
如何在 UWP 中的父视图中设置固定纵横比视图,并在调整窗口大小时可以均匀拉伸?
根据您的要求,我们建议您将 DropShadowPanel
插入 ViewBox,它是一个容器控件,可将其内容缩放到指定大小。
<Grid Padding="10,10,10" Background="White">
<Viewbox>
<controls:DropShadowPanel
Width="200"
Height="300"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
BlurRadius="30"
ShadowOpacity=".7"
Color="Black">
<Grid />
</controls:DropShadowPanel>
</Viewbox>
</Grid>