// Token: 0x06004DA7 RID: 19879 RVA: 0x0015E1D4 File Offset: 0x0015C3D4
        internal override void OnColumnPropertyChanged(GridViewColumn column, string propertyName)
        {
            if ("ActualWidth".Equals(propertyName))
            {
                return;
            }
            int actualIndex;

            if ((actualIndex = column.ActualIndex) >= 0 && actualIndex < base.InternalChildren.Count)
            {
                if (GridViewColumn.WidthProperty.Name.Equals(propertyName))
                {
                    base.InvalidateMeasure();
                    return;
                }
                if ("DisplayMemberBinding".Equals(propertyName))
                {
                    FrameworkElement frameworkElement = base.InternalChildren[actualIndex] as FrameworkElement;
                    if (frameworkElement != null)
                    {
                        BindingBase displayMemberBinding = column.DisplayMemberBinding;
                        if (displayMemberBinding != null && frameworkElement is TextBlock)
                        {
                            frameworkElement.SetBinding(TextBlock.TextProperty, displayMemberBinding);
                            return;
                        }
                        this.RenewCell(actualIndex, column);
                        return;
                    }
                }
                else
                {
                    ContentPresenter contentPresenter = base.InternalChildren[actualIndex] as ContentPresenter;
                    if (contentPresenter != null)
                    {
                        if (GridViewColumn.CellTemplateProperty.Name.Equals(propertyName))
                        {
                            DataTemplate cellTemplate;
                            if ((cellTemplate = column.CellTemplate) == null)
                            {
                                contentPresenter.ClearValue(ContentControl.ContentTemplateProperty);
                                return;
                            }
                            contentPresenter.ContentTemplate = cellTemplate;
                            return;
                        }
                        else if (GridViewColumn.CellTemplateSelectorProperty.Name.Equals(propertyName))
                        {
                            DataTemplateSelector cellTemplateSelector;
                            if ((cellTemplateSelector = column.CellTemplateSelector) == null)
                            {
                                contentPresenter.ClearValue(ContentControl.ContentTemplateSelectorProperty);
                                return;
                            }
                            contentPresenter.ContentTemplateSelector = cellTemplateSelector;
                        }
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Handler of column's PropertyChanged event. Update correspondent property
        /// if change is of Width / CellTemplate / CellTemplateSelector.
        /// </summary>
        internal override void OnColumnPropertyChanged(GridViewColumn column, string propertyName)
        {
            Debug.Assert(column != null);
            int index;

            // ActualWidth change is a noise to RowPresenter, so filter it out.
            // Note-on-perf: ActualWidth property change of will fire N x M times
            // on every start up. (N: number of column with Width set to 'auto',
            // M: number of visible items)
            if (GridViewColumn.c_ActualWidthName.Equals(propertyName))
            {
                return;
            }

            // Width is the #1 property that will be changed frequently. The others
            // (DisplayMemberBinding/CellTemplate/Selector) are not.

            if (((index = column.ActualIndex) >= 0) && (index < InternalChildren.Count))
            {
                if (GridViewColumn.WidthProperty.Name.Equals(propertyName))
                {
                    InvalidateMeasure();
                }

                // Priority: DisplayMemberBinding > CellTemplate > CellTemplateSelector
                else if (GridViewColumn.c_DisplayMemberBindingName.Equals(propertyName))
                {
                    FrameworkElement cell = InternalChildren[index] as FrameworkElement;
                    if (cell != null)
                    {
                        BindingBase binding = column.DisplayMemberBinding;
                        if (binding != null && cell is TextBlock)
                        {
                            cell.SetBinding(TextBlock.TextProperty, binding);
                        }
                        else
                        {
                            RenewCell(index, column);
                        }
                    }
                }
                else
                {
                    ContentPresenter cp = InternalChildren[index] as ContentPresenter;
                    if (cp != null)
                    {
                        if (GridViewColumn.CellTemplateProperty.Name.Equals(propertyName))
                        {
                            DataTemplate dt;
                            if ((dt = column.CellTemplate) == null)
                            {
                                cp.ClearValue(ContentControl.ContentTemplateProperty);
                            }
                            else
                            {
                                cp.ContentTemplate = dt;
                            }
                        }

                        else if (GridViewColumn.CellTemplateSelectorProperty.Name.Equals(propertyName))
                        {
                            DataTemplateSelector dts;
                            if ((dts = column.CellTemplateSelector) == null)
                            {
                                cp.ClearValue(ContentControl.ContentTemplateSelectorProperty);
                            }
                            else
                            {
                                cp.ContentTemplateSelector = dts;
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
 protected override void OnTransitionEnded(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
 {
     newContent.ClearValue(ContentPresenter.RenderTransformProperty);
       oldContent.ClearValue(ContentPresenter.RenderTransformProperty);
 }
        protected override void OnTransitionEnded(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
        {
            Storyboard oldStoryboard = (Storyboard)oldContent.GetValue(OldContentStoryboardProperty);
            if (oldStoryboard != null)
                oldStoryboard.Stop(oldContent);
            oldContent.ClearValue(ContentPresenter.StyleProperty);

            Storyboard newStoryboard = (Storyboard)newContent.GetValue(NewContentStoryboardProperty);
            if (newStoryboard != null)
                newStoryboard.Stop(newContent);
            newContent.ClearValue(ContentPresenter.StyleProperty);
        }
Exemple #5
0
		public void DataContextTest6 ()
		{
			// When the ContentPresenter is in the tree, its DataContext is updated as expected
			object o = new object ();
			object o2 = new object();
			ContentPresenter c = new ContentPresenter { DataContext = o };
			Assert.AreEqual (o, c.DataContext, "#1");
			CreateAsyncTest (c,
				() => c.DataContext = o,
				() => {
					Assert.AreEqual (o, c.DataContext, "#3");
					TestPanel.DataContext = o2;
				},
				() => Assert.AreEqual (o, c.DataContext, "#4"),
				() => c.ClearValue (ContentPresenter.DataContextProperty),
				() => Assert.AreEqual (o2, c.DataContext, "#5")
			);
		}