Exemplo n.º 1
0
        // Note that this can be called if e.g. the Layouter's AnchoringRect changes
        protected override void OnLayouterResultChanged(PropertyChangedEventArgs <LayoutResult> args)
        {
            var dpiResolution = DpiResolutions.FromAvalonElement(window);
            var location      = args.New.Bounds.ToAvalonRect(dpiResolution);

            window.Top  = location.Top;
            window.Left = location.Left;
        }
Exemplo n.º 2
0
        // Use the desired size to calculate a new layout
        // Called from:
        // * ctor (although unlikely to be valid)
        // * OnSourceInitialized
        // * Before show
        // * On size changed
        private void UpdatePopupLayout()
        {
            if (!window.IsMeasureValid)
            {
                window.Measure(new Size(double.MaxValue, double.MaxValue));
            }

            if (window.IsMeasureValid)
            {
                // Setting this causes the Layouter to compute a new LayoutResult and
                // we get notified via OnLayouterResultChanged
                var dpiResolution = DpiResolutions.FromAvalonElement(window);
                Layouter.Size.Value = window.DesiredSize.ToWinFormsSize(dpiResolution);
                // TODO: Should we check to see if the layouter gives us a different size, then re-measure?
            }
        }