Beispiel #1
0
        public void SetElement(VisualElement element)
        {
            if (element != null && !(element is MasterDetailPage))
            {
                throw new ArgumentException("Element must be a Page", "element");
            }

            MasterDetailPage oldElement = Element;

            Element = (MasterDetailPage)element;

            if (oldElement != null)
            {
                oldElement.PropertyChanged -= OnElementPropertyChanged;
            }

            if (element != null)
            {
                if (_container == null)
                {
                    _container = new MasterDetailControl();
                    _container.UserClosedPopover += OnUserClosedPopover;
                    _container.SizeChanged       += OnNativeSizeChanged;

                    Tracker = new BackgroundTracker <PageControl>(Control.BackgroundProperty)
                    {
                        Element = (Page)element, Container = _container
                    };

                    _container.Loaded   += OnLoaded;
                    _container.Unloaded += OnUnloaded;
                }

                element.PropertyChanged += OnElementPropertyChanged;
                UpdateBehavior();
                SetMaster(Element.Master);
                SetDetail(Element.Detail);
                UpdateIsPresented();
            }

            OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));
        }
		public void SetElement(VisualElement element)
		{
			if (element != null && !(element is MasterDetailPage))
				throw new ArgumentException("Element must be a Page", "element");

			MasterDetailPage oldElement = Element;
			Element = (MasterDetailPage)element;

			if (oldElement != null)
			{
				oldElement.PropertyChanged -= OnElementPropertyChanged;
			}

			if (element != null)
			{
				if (_container == null)
				{
					_container = new MasterDetailControl();
					_container.UserClosedPopover += OnUserClosedPopover;
					_container.SizeChanged += OnNativeSizeChanged;

					Tracker = new BackgroundTracker<PageControl>(Control.BackgroundProperty) { Element = (Page)element, Container = _container };

					_container.Loaded += OnLoaded;
					_container.Unloaded += OnUnloaded;
				}

				element.PropertyChanged += OnElementPropertyChanged;
				UpdateBehavior();
				SetMaster(Element.Master);
				SetDetail(Element.Detail);
				UpdateIsPresented();
			}

			OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));
		}