示例#1
0
        private static void OnContentNamePropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            ContentLayout currentOwner = GetContainer(o);

            if (currentOwner != null)
            {
                currentOwner.OnContentNameChanged(o, (string)e.OldValue, (string)e.NewValue);
            }
        }
示例#2
0
        private void OnContentListCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                UIElement content = (UIElement)e.NewItems[0];

                ContentLayout currentOwner = ContentLayout.GetContainer(content);
                if (currentOwner != null)
                {
                    currentOwner.ContentList.Remove(content);
                }

                ContentLayout.SetContainer(content, this);

                string contentName = ContentLayout.GetContentName(content);

                ContentPresenter contentPresenter = GetPresenter(contentName);
                if (contentPresenter != null)
                {
                    Grid grid = new Grid();
                    grid.Children.Add(content);

                    contentPresenter.Content = grid;
                    grid.UpdateLayout();
                }
            }
            else if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                UIElement content = (UIElement)e.OldItems[0];

                string contentName = ContentLayout.GetContentName(content);

                ContentPresenter contentPresenter = GetPresenter(contentName);
                if (contentPresenter != null)
                {
                    contentPresenter.Content = null;
                }
            }
        }
示例#3
0
        /// <internalonly />
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (_contentList.Count != 0)
            {
                Dispatcher.BeginInvoke(delegate() {
                    foreach (UIElement content in _contentList)
                    {
                        string contentName = ContentLayout.GetContentName(content);
                        ContentPresenter contentPresenter = GetPresenter(contentName);

                        if (contentPresenter != null)
                        {
                            Grid grid = new Grid();
                            grid.Children.Add(content);

                            contentPresenter.Content = grid;
                            grid.UpdateLayout();
                        }
                    }
                });
            }
        }
示例#4
0
 internal static void SetContainer(DependencyObject o, ContentLayout value)
 {
     o.SetValue(ContainerProperty, value);
 }
示例#5
0
 internal static void SetContainer(DependencyObject o, ContentLayout value)
 {
     o.SetValue(ContainerProperty, value);
 }