我的代码中多次出现此代码
<Image
Aspect="AspectFit"
HeightRequest="75"
WidthRequest="75">
<Image.Clip>
<EllipseGeometry
Center="37.5,37.5"
RadiusX="37.5"
RadiusY="37.5" />
</Image.Clip>
</Image>
我想将其提取为 XAML 样式以重用并减少代码
它看起来像这样
<Style TargetType="Image" ApplyToDerivedTypes="True" x:Key="roundedImageStyle">
<Setter Property="HeightRequest" Value="75"/>
<Setter Property="WidthRequest" Value="75"/>
<Setter Property="Aspect" Value="AspectFit"/>
<Setter Property="Clip" Value="??????"/>
</Style>
如何在样式中设置Clip
?
最佳答案
@jfversluis告诉我可以这样实现
<Setter Property="Clip">
<EllipseGeometry
Center="37.5,37.5"
RadiusX="37.5"
RadiusY="37.5" />
</Setter>
关于xaml - 如何使用 XAML 样式剪辑 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69852948/