Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not get the correct value of ActualWidth or ActualHeight after Loaded event on Desktop platform #17243

Closed
lindexi opened this issue Jun 20, 2024 · 6 comments
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/potentially-fixed Categorizes an issue as potentially fixed by some unlinked PR, fix needs to be verified triage/untriaged Indicates an issue requires triaging or verification

Comments

@lindexi
Copy link
Contributor

lindexi commented Jun 20, 2024

Current behavior

We can not get ActualWidth or ActualHeight value after Loaded event on Desktop platform. It is different from WinUI's behavior.

    public MainPage()
    {
        this.InitializeComponent();

        Loaded += MainPage_Loaded;
    }

    private void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        Debug.WriteLine($"Width={ActualWidth} Height={ActualHeight}");
    }

You can find the debug output Width=0 Height=0 on Desktop platform, and Width=1024 Height=720 on WinUI platform.

Expected behavior

We can get the correct value of ActualWidth or ActualHeight after Loaded event on Desktop platform. The behavior is same as WinUI platform.

How to reproduce it (as minimally and precisely as possible)

  1. Create the empty UNO project.
  2. Add the code in MainPage.xaml.cs:
    public MainPage()
    {
        this.InitializeComponent();

        Loaded += MainPage_Loaded;
    }

    private void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        Debug.WriteLine($"Width={ActualWidth} Height={ActualHeight}");
    }
  1. Run the program on Desktop platform and WinUI platform respectively.

And you can find the output in VisualStudio output window is difference on Desktop platform and WinUI platform.

You can find my code in https://github.com/lindexi/lindexi_gd/blob/eb445bd456345de745e16e73c58f3e8f1fe48216/UnoDemo/DalekairwiJebonacaki/DalekairwiJebonacaki/MainPage.xaml.cs

Workaround

No response

Works on UWP/WinUI

None

Environment

Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia

NuGet package version(s)

global.json:

{
  // To update the version of Uno please update the version of the Uno.Sdk here. See https://aka.platform.uno/upgrade-uno-packages for more information.
  "msbuild-sdks":
  {
    "Uno.Sdk": "5.2.161"
  }
}

Affected platforms

Skia (WPF), Skia (Linux X11), Skia (macOS), Skia (Linux Framebuffer), Skia (GTK)

IDE

Visual Studio 2022

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

Reference : #16120 and #15982 and #15841

@lindexi lindexi added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Jun 20, 2024
@jeromelaban
Copy link
Member

This behavior may have changed in latest uno.sdk previews.

@Youssef1313 Youssef1313 added the triage/potentially-fixed Categorizes an issue as potentially fixed by some unlinked PR, fix needs to be verified label Jun 21, 2024
@Youssef1313
Copy link
Member

@lindexi Were you able to re-test this with the latest dev?

@lindexi
Copy link
Contributor Author

lindexi commented Jun 25, 2024

@Youssef1313 Can I try 5.4.0-dev.464 version?

@Youssef1313
Copy link
Member

Yes, but keep in mind if you're using Uno.Sdk, the SDK versioning is different from Uno.WinUI versioning. The latest SDK as of writing this comment is 5.4.0-dev.51 which is using Uno.WinUI 5.4.0-dev.464

lindexi added a commit to lindexi/lindexi_gd that referenced this issue Jun 25, 2024
@lindexi
Copy link
Contributor Author

lindexi commented Jun 25, 2024

Thank you @jeromelaban and @Youssef1313 . The 5.4.0-dev.51 version Uno.Sdk fixes the behavior.

My test demo code: https://github.com/lindexi/lindexi_gd/tree/bf72c0981965bb4aed7f082ef81eed2e4b6d6913/UnoDemo/DalekairwiJebonacaki

@lindexi lindexi closed this as completed Jun 25, 2024
@Youssef1313
Copy link
Member

Thank you for confirming. Happy to know it's fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/potentially-fixed Categorizes an issue as potentially fixed by some unlinked PR, fix needs to be verified triage/untriaged Indicates an issue requires triaging or verification
Projects
None yet
Development

No branches or pull requests

3 participants