Replies: 1 comment 2 replies
-
I did temporary realization, but this code too bad and I want to know how can I realize it normally: public MainPage()
{
this.InitializeComponent();
System.Diagnostics.Debug.WriteLine($"grid start width is {grid.ActualWidth}");
grid.Foo(() =>
{
System.Diagnostics.Debug.WriteLine($"__________grid loaded__________");
System.Diagnostics.Debug.WriteLine($"grid current width is {grid.ActualWidth}");
});
} public static class UnoTemprarySizeInitializationHelper
{
/// <summary>
/// Performs an action after size initizalizion.
/// </summary>
/// <param name="execute">Some action after size will iti</param>
public static void Foo(this FrameworkElement element, Action execute)
{
SizeChangedEventHandler tempraryDelegate = null;
tempraryDelegate = delegate (object s, SizeChangedEventArgs e)
{
execute();
element.SizeChanged -= tempraryDelegate;
};
element.SizeChanged += tempraryDelegate;
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I created some element and subscribed to the ⚡Loaded action
I expect next result:
ActualWidth must have some value. For example -- 500
But the real result:
ActualWidth is 0
UWP debug result
WPF Skia result
Beta Was this translation helpful? Give feedback.
All reactions