Forum Discussion
juansturla
Nov 05, 2021Copper Contributor
How to clip a View using XAML Style?
I have in my code several times this code
<Image
Aspect="AspectFit"
HeightRequest="75"
WidthRequest="75">
<Image.Clip>
<EllipseGeometry
Center="37.5,37.5"
RadiusX="37.5"
RadiusY="37.5" />
</Image.Clip>
</Image>
And I want to extract it as a XAML Style to reuse and reduce the code
It would look something like this
<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>
How can I set the Clip inside the style?
I think you should be able to do it like this:
<Setter Property="Clip"> <EllipseGeometry Center="37.5,37.5" RadiusX="37.5" RadiusY="37.5" /> </Setter>
- jfversluisMicrosoft
I think you should be able to do it like this:
<Setter Property="Clip"> <EllipseGeometry Center="37.5,37.5" RadiusX="37.5" RadiusY="37.5" /> </Setter>