Resizing frame and controls according to device size .Suggestions?

后端 未结 1 1649
-上瘾入骨i
-上瘾入骨i 2021-01-27 12:26

I have a frame with 2 buttons and label. What is the best practice to make sure the frame and controls inside resize according to the screen size?

Whatever I have tried

1条回答
  •  无人共我
    2021-01-27 12:53

    You could change the width and height according to your frame via binding Value Converters.

    Binding Value Converters: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/data-binding/converters

    Set the name to your Frame first.

        
    

    Create the MyConverter. MyConverter.cs

    public class MyConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return (double)value / 3.0;
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    

    Set the StaticResource.

     
        
            
        
    
    

    Binding to your button.

      
                    

    0 讨论(0)
提交回复
热议问题