protected override com.codename1.ui.geom.Dimension calcPreferredSize()
        {
            int w = 0;
            int h = 0;

            using (AutoResetEvent are = new AutoResetEvent(false))
            {
                SilverlightImplementation.dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    element.Measure(new Size(1000000, 1000000));
                    w = SilverlightImplementation.screen.ConvertDipsToPixels((float)(element.DesiredSize.Width * SilverlightImplementation.scaleFactor), CanvasDpiRounding.Round);
                    h = SilverlightImplementation.screen.ConvertDipsToPixels((float)(element.DesiredSize.Height * SilverlightImplementation.scaleFactor), CanvasDpiRounding.Round);
                    are.Set();
                }).AsTask().ConfigureAwait(false).GetAwaiter().GetResult();
                are.WaitOne();
            }
            com.codename1.ui.geom.Dimension d = new com.codename1.ui.geom.Dimension(Math.Max(2, w), Math.Max(2, h));
            //d.@this(Math.Max(2, w), Math.Max(2, h));
            return(d);
        }
 public override global::System.Object calcPreferredSize()
 {
     int w = 0;
     int h = 0;
     using (AutoResetEvent are = new AutoResetEvent(false))
     {
         SilverlightImplementation.dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             element.Measure(new Size(1000000, 1000000));
             w = SilverlightImplementation.screen.ConvertDipsToPixels((float)(element.DesiredSize.Width * SilverlightImplementation.scaleFactor), CanvasDpiRounding.Round);
             h = SilverlightImplementation.screen.ConvertDipsToPixels((float)(element.DesiredSize.Height * SilverlightImplementation.scaleFactor), CanvasDpiRounding.Round);
             are.Set();
         }).AsTask().ConfigureAwait(false).GetAwaiter().GetResult();
         are.WaitOne();
     }
     com.codename1.ui.geom.Dimension d = new com.codename1.ui.geom.Dimension();
     d.@this(Math.Max(2, w), Math.Max(2, h));
     return d;
 }