Xamarin Forms Image fill width with proper aspect

后端 未结 11 2215
我寻月下人不归
我寻月下人不归 2020-12-09 08:05

Here is xaml (an image in stacklayout). Everything is logical: I set Aspect to AspectFit and HorizontalOptions to FillAndExpand. Width of image must fill the width of stackl

11条回答
  •  不知归路
    2020-12-09 08:39

    Up until now, the only solution I've found is to set Aspect="AspectFill" and set HeightRequest.

    You can bind HeightRequest to a property and calculate the height based on the page width.

    In my case the images are always the same proportion, so I do:

    HeightRequest = (int)Math.Truncate(Xamarin.Forms.Application.Current.MainPage.Width / 1.41);

提交回复
热议问题