Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Databinding into grid's columnDefinition width

$
0
0

Hi, I am having problems with binding into grid's columndefinition width proprety.
I tried TestWidth.Value as well as just double and string.
Any idea whats the problem?

`<ColumnDefinition Width="{Binding Parent.SizeModifier.TestWidth, Source={x:Reference Self}}"></ColumnDefinition>`

    class SizeModifier
    {
        public int DefaultWindowWidth { get; set; }
        public int DefaultWindowHeight { get; set; }
        public int DefaultWindowDPI { get; set; }
        public double WidthModifier { get; set; }
        public double HeightModifier { get; set; }
        public double DPIModifier { get; set; }
        public int DeviceWidth { get; set; }
        public int DeviceHeight { get; set; }
        public int DeviceDPI { get; set; }
        public GridLength TestWidth { get; set; }
        public string Test = "400";

        public SizeModifier()
        {
            DefaultWindowWidth = 1280;
            DefaultWindowHeight = 800;
            DefaultWindowDPI = 160;
            DeviceDPI = DependencyService.Get<IGetScreenSizes>().GetDisplayDpi();
            DeviceWidth = DependencyService.Get<IGetScreenSizes>().GetDisplayWidth();
            DeviceHeight = DependencyService.Get<IGetScreenSizes>().GetDisplayHeight();
            DPIModifier = (double)DeviceDPI / (double)DefaultWindowDPI;
            WidthModifier = (double)DeviceWidth / (double)DefaultWindowWidth*DPIModifier;
            HeightModifier = (double)DeviceHeight / (double)DefaultWindowHeight*DPIModifier;
            TestWidth = new GridLength((double)400 * WidthModifier, GridUnitType.Absolute);

        }
    }


}

Viewing all articles
Browse latest Browse all 89864

Trending Articles



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