Quantcast
Channel: User Liyun Zhang - MSFT - Stack Overflow
Viewing all articles
Browse latest Browse all 445

Answer by Liyun Zhang - MSFT for How to resize image inside in .NET MAUI

$
0
0

It seems there is no a such Button control can achieve the effect you want. So you can use a control to contain the image and the text. And then use the TapGestureRecognizer to deal with the clicked event. Such as:

<Frame HeightRequest="150" WidthRequest="150" BorderColor="Red"           Margin="20" ><VerticalStackLayout Margin="-10"><Image Source="image.png"                    WidthRequest="100"                    HeightRequest="100"                    Margin="-10"/><Label Margin="0" Text="this is text"                    WidthRequest="100"                   HeightRequest="50"                    HorizontalTextAlignment="Center"                   VerticalTextAlignment="Center"/></VerticalStackLayout><Frame.GestureRecognizers><TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/></Frame.GestureRecognizers></Frame>

The Margin property can be used to adjust the fine position of the view.

And in the Page.cs:

    private void TapGestureRecognizer_Tapped(object sender, TappedEventArgs e)    {        // you can do the work you want when the button clicked    }

The result picture:

enter image description here

In addition, you can refer to this case about how to change xamarin frame border thickness to set the frame's border width.


Viewing all articles
Browse latest Browse all 445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>