예제 #1
0
        public static void SafeForceUpdateLayout(this FrameworkElement refrence)
        {
            if (!refrence.CheckAccess())
            {
                refrence.Dispatcher.Invoke(new Action(refrence.SafeForceUpdateLayout));
                return;
            }

            if (refrence.ActualWidth.IsZero() || refrence.ActualHeight.IsZero())
            {
                var availableSize = new System.Windows.Size(refrence.Width, refrence.Height);
                if (availableSize.IsNaN())
                {
                    availableSize = new System.Windows.Size(1000, 1000);
                }
                refrence.Measure(availableSize);
                refrence.Arrange(new Rect(PointExtension.ZeroPoint, availableSize));
                refrence.UpdateLayout();
            }
        }