Example #1
0
        protected override async Task OnInitializedAsync()
        {
            OnWindowResize(1920, 1080);  // initial guess
            var sz = await XFUilities.RegisterApplicationPage(this);

            OnWindowResize(sz.Width, sz.Height);
            await base.OnInitializedAsync();
        }
 protected override Size MeasureOverride(Size availableSize)
 {
     if (_needsTextMeasure)
     {
         _needsTextMeasure = false;
         XFUilities.MeasureText(
             this.Element.Text,
             this.ActualFontFamily,
             this.Element.FontSize).ContinueWith(t =>
         {
             _textSize = new Size(t.Result, this.Element.FontSize);
             this.Element.NativeSizeChanged();
             this.InvalidateRender();
         });
         return(new Size(
                    _textSize.Width +
                    8 * 2
                    ,
                    _textSize.Height +
                    8 * 2
                    //+ this.ActualBorderWidth * 2
                    ));
     }
     else
     {
         return(new Size
         {
             Width = _textSize.Width +
                     this.Element.Bounds.Width
                     //+ this.ActualBorderWidth * 2
             ,
             Height = _textSize.Height +
                      this.Element.Bounds.Height
                      //+ this.ActualBorderWidth * 2
         });
     }
 }
 protected override Size MeasureOverride(Size availableSize)
 {
     if (_needsTextMeasure)
     {
         _needsTextMeasure = false;
         var t = XFUilities.MeasureText(
             this.Element.Text,
             this.Element.FontFamily,
             this.Element.FontSize);
         t.ContinueWith(t =>
         {
             this.DesiredSize = new Size(t.Result, this.Element.FontSize * this.ActualLineHeight);
             this.Element.NativeSizeChanged();
             this.InvalidateRender();
         });
         return(new Size(
                    this.Element.FontSize * 0.75 * this.Element.Text.Length,                // just a guess
                    this.Element.FontSize));
     }
     else
     {
         return(this.DesiredSize);
     }
 }