locked
How can i make three user control as flyouts fit in all screen sizes ?

    Question

  • I am using the below class to display my userControls as flyouts and it display perfect but when i run it on the simulator and on a big screen the layout is messed up ,how can i make a layout that will fit all screen sizes , I really don't know what to do here.
     public class SettingsFlyout
        {
            private const int _width = 176;
            private const int _width2 = 376;
            private const int _width3 = 386;
            private Popup _popup;
    
            /// <summary>
            /// Show the Flyout with the UserControl as content
            /// </summary>
            /// <param name="control"></param>
            public void ShowFlyout(UserControl control)
            {
                _popup = new Popup();
                _popup.Closed += OnPopupClosed;
                Window.Current.Activated += OnWindowActivated;
                _popup.IsLightDismissEnabled = true;
                _popup.Width = _width;
                _popup.Height = Window.Current.Bounds.Height;
    
                control.Width = _width;
                
                control.Height = Window.Current.Bounds.Height;
    
                _popup.Child = control;
                _popup.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - 1440);
                _popup.SetValue(Canvas.TopProperty, 0);
    
                //_popup.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - 1925);
                //_popup.SetValue(Canvas.TopProperty, -80);
    
                _popup.IsOpen = true;
                _popup.FlowDirection = FlowDirection.LeftToRight;
    
            
            }
    
      
    
            public void ShowFlyout2(UserControl control)
            {
                _popup = new Popup();
                _popup.Closed += OnPopupClosed;
                Window.Current.Activated += OnWindowActivated;
                _popup.IsLightDismissEnabled = true;
                _popup.Width = _width2;
                _popup.Height = Window.Current.Bounds.Height;
    
                control.Width = _width2;
    
                control.Height = Window.Current.Bounds.Height;
    
                _popup.Child = control;
                _popup.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - 1265);
                _popup.SetValue(Canvas.TopProperty, 0);
    
                //_popup.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - 1925);
                //_popup.SetValue(Canvas.TopProperty, -80);
    
                _popup.IsOpen = true;
                _popup.FlowDirection = FlowDirection.LeftToRight;
    
    
            }
    
            public void ShowFlyout3(UserControl control)
            {
                _popup = new Popup();
                _popup.Closed += OnPopupClosed;
                Window.Current.Activated += OnWindowActivated;
                _popup.IsLightDismissEnabled = true;
                _popup.Width = _width3;
                _popup.Height = Window.Current.Bounds.Height;
    
                control.Width = _width3;
    
                control.Height = Window.Current.Bounds.Height;
    
                _popup.Child = control;
                _popup.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - 890);
                _popup.SetValue(Canvas.TopProperty, 0);
    
                //_popup.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - 1925);
                //_popup.SetValue(Canvas.TopProperty, -80);
    
                _popup.IsOpen = true;
                _popup.FlowDirection = FlowDirection.LeftToRight;
    
    
            }
    
            private void OnWindowActivated(object sender, Windows.UI.Core.WindowActivatedEventArgs e)
            {
                if (e.WindowActivationState == Windows.UI.Core.CoreWindowActivationState.Deactivated)
                {
                    _popup.IsOpen = false;
                }
            }
    
            void OnPopupClosed(object sender, object e)
            {
                Window.Current.Activated -= OnWindowActivated;
            }
        }


    19karabo91

    Monday, February 17, 2014 1:36 PM

All replies