VerticalOffset of ShowDialog from WindowManager

Topics: Bugs
Sep 6, 2011 at 4:06 PM
Edited Sep 7, 2011 at 11:51 AM

When SIP is available and we are editing some control that changes vertical offset that current Vertical Offset is negative then dialog that is rendered by caliburn is vertically shifted so the whole control is not visible. As a resolution i propose to modify this method:

 

            
            protected virtual void CreateUIElements()
            {
		double offsetY = 0;
		PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
		if( frame != null ) {
			var group = frame.RenderTransform as TransformGroup;
			if( group != null ) {
				var translate = group.Children[ 0 ] as TranslateTransform;
				offsetY = Math.Abs( translate.Y );
			}
		}
		viewContainer = new ContentControl
                {
                    HorizontalContentAlignment = HorizontalAlignment.Stretch,
                    VerticalContentAlignment = VerticalAlignment.Top
                };
                maskingLayer = new Border
                {
                    Child = viewContainer,
                    Background = new SolidColorBrush(Color.FromArgb(170, 0, 0, 0)),
                    VerticalAlignment = VerticalAlignment.Top,
                    HorizontalAlignment = HorizontalAlignment.Left
                };
                pageFreezingLayer = new Border
                {
                    Background = new SolidColorBrush(Colors.Transparent),
                    Width = Application.Current.Host.Content.ActualWidth,
					Height = Application.Current.Host.Content.ActualHeight
                };

                var panel = new Canvas();
                panel.Children.Add(pageFreezingLayer);
                panel.Children.Add(maskingLayer);

                hostPopup = new Popup { Child = panel };

		if( frame.Orientation == PageOrientation.None || frame.Orientation == PageOrientation.Portrait || frame.Orientation == PageOrientation.PortraitUp ) {
			hostPopup.VerticalOffset = offsetY;
		}
		else if( frame.Orientation == PageOrientation.LandscapeRight ) {
			hostPopup.HorizontalOffset = offsetY;
		}
		else if( frame.Orientation == PageOrientation.LandscapeLeft ) {
			hostPopup.HorizontalOffset = -offsetY;
		}
            }
            void CurrentPageOrientationChanged(object sender, OrientationChangedEventArgs e)
            {
		hostPopup.HorizontalOffset = 0;
		hostPopup.VerticalOffset = 0;
                ArrangePlacement();
            }