Exemple #1
0
        private void EnsurePopup(FloatingDialogStyle style, Point position)
        {
            //if (_popup != null)
            //if (_grid != null)
            //    return;

            if (IsEnsured)
            {
                return;
            }

            IsEnsured = true;
            //_popup = new Popup();
            //_grid = new Grid();
            //_popup.Child = _grid;
            _popup.Closed += new EventHandler(_popup_Closed);
            _popup.Opened += new EventHandler(_popup_Opened);

            if (style != FloatingDialogStyle.NonModal)
            {
                // If Canvas.Background != null, you cannot click through it
                _canvas = new Canvas();
                _canvas.MouseLeftButtonDown += new MouseButtonEventHandler(_canvas_MouseLeftButtonDown);

                if (style == FloatingDialogStyle.Modal)
                {
                    _canvas.Background = new SolidColorBrush(Colors.Transparent);
                }

                else if (style == FloatingDialogStyle.ModalDimmed)
                {
                    _canvas.Background = new SolidColorBrush(Color.FromArgb(0x20, 0x80, 0x80, 0x80));
                }

                //_grid.Children.Add(_canvas);
            }

            _popup.Child = _canvas;
            _canvas.Children.Add(_content = GetContent());

            UpdateSize();

            if (position.X.CompareTo(double.NaN) == 0 && position.Y.CompareTo(double.NaN) == 0)
            {
                _content.LayoutUpdated += new EventHandler(_content_LayoutUpdated);
            }
            else
            {
                MoveTo(position);
            }
        }
        private void EnsurePopup(FloatingDialogStyle style, Point position)
        {
            //if (_popup != null)
            //if (_grid != null)
            //    return;

            if (IsEnsured)
                return;

            IsEnsured = true;
            //_popup = new Popup();
            //_grid = new Grid();
            //_popup.Child = _grid;
            _popup.Closed += new EventHandler(_popup_Closed);
            _popup.Opened += new EventHandler(_popup_Opened);

            if (style != FloatingDialogStyle.NonModal)
            {
                // If Canvas.Background != null, you cannot click through it
                _canvas = new Canvas();
                _canvas.MouseLeftButtonDown += new MouseButtonEventHandler(_canvas_MouseLeftButtonDown);

                if (style == FloatingDialogStyle.Modal)
                {
                    _canvas.Background = new SolidColorBrush(Colors.Transparent);
                }

                else if (style == FloatingDialogStyle.ModalDimmed)
                {
                    _canvas.Background = new SolidColorBrush(Color.FromArgb(0x20, 0x80, 0x80, 0x80));
                }

                //_grid.Children.Add(_canvas);
            }

            _popup.Child = _canvas;
            _canvas.Children.Add(_content = GetContent());

            UpdateSize();

            if (position.X.CompareTo(double.NaN) == 0 && position.Y.CompareTo(double.NaN) == 0)
            {
                _content.LayoutUpdated += new EventHandler(_content_LayoutUpdated);
            }
            else
            {
                MoveTo(position);
            }
        }