【发布时间】:2019-01-12 11:45:57
【问题描述】:
谁能解释为什么Stretch 在Ellipse 元素中无效。无论我使用None,Fill,UniformToFill 还是Uniform,结果都是一样的。
如果我在 DataTemplate (GridView) 中使用相同的代码,它可以正常工作。
<Button x:Name="UI_Application_LogIn_ProfilePictureButton_Button" Style="{StaticResource LogInButton}" BorderBrush="{ThemeResource SystemControlForegroundBaseMediumBrush}" IsTabStop="False" UseSystemFocusVisuals="False">
<Grid x:Name="UI_Application_LogIn_ProfilePicture_Grid" IsHitTestVisible="False">
<Ellipse x:Name="UI_Application_LogIn_ProfilePicture" Width="160" Height="160">
<Ellipse.Fill>
<ImageBrush x:Name="UI_Application_LogIn_ProfilePictureImageBrush" Stretch="UniformToFill" AlignmentY="Top"/>
</Ellipse.Fill>
</Ellipse>
<Ellipse x:Name="UI_Application_LogIn_ProfilePictureNonStaticLightEffect" Width="160" Height="160" Fill="{ThemeResource SystemControlHighlightTransparentRevealBorderBrush}"/>
</Grid>
</Button>
【问题讨论】:
-
我找到了拉伸不起作用的原因。真是脑残。当我创建新的
ImageBrush时,我忘记在我的代码中使用Stretch。所以在创建新的ImageBrush后添加行ShapeImageBrush.Stretch = Stretch.UniformToFill;解决问题。
标签: c# uwp uwp-xaml ellipse stretch