コード例 #1
0
 private void _innerFrameInLabDimensions_Click(object sender, RoutedEventArgs e)
 {
     if (double.IsInfinity(_pagePresenter.MaxWidth))
     {
         // Not CI mode, so enter it now
         _pagePresenter.MaxWidth  = 1024;
         _pagePresenter.MaxHeight = 664;
     }
     else
     {
         // We are already in "CI mode"
         _pagePresenter.ClearValue(MaxWidthProperty);
         _pagePresenter.ClearValue(MaxHeightProperty);
     }
 }
コード例 #2
0
 private static void ClearContentPresenter(ContentPresenter cp,
                                           object item)
 {
     if (cp != item)
     {
         cp.ClearValue(ContentPresenter.ContentProperty);
     }
 }
コード例 #3
0
ファイル: HACKS.cs プロジェクト: Jamnine/OrmFrameEmpty
        private static bool RemoveParent(FrameworkElement child, ContentPresenter parent)
        {
            if (parent != null && parent.Content == child)
            {
                parent.ClearValue(ContentPresenter.ContentProperty);
                return(true);
            }

            return(false);
        }
コード例 #4
0
        private void SynchronizeContentPosition()
        {
            switch (ContentPosition)
            {
            case ContentPosition.Left:
            case ContentPosition.Right:
            {
                Grid.SetColumn(content, ContentPosition.Left == ContentPosition ? 0 : 1);
                Grid.SetColumn(animation, ContentPosition.Right == ContentPosition ? 0 : 1);
                Grid.SetRow(content, 0);
                Grid.SetRow(animation, 0);
                Grid.SetRowSpan(content, 2);
                Grid.SetRowSpan(animation, 2);
                content.ClearValue(Grid.ColumnSpanProperty);
                animation.ClearValue(Grid.ColumnSpanProperty);
                content.HorizontalContentAlignment = (ContentPosition.Left == ContentPosition)
                        ? HorizontalAlignment.Right
                        : HorizontalAlignment.Left;
                content.VerticalContentAlignment = VerticalAlignment.Center;

                break;
            }

            case ContentPosition.Top:
            case ContentPosition.Bottom:
            {
                Grid.SetColumn(content, 0);
                Grid.SetColumn(animation, 0);
                Grid.SetRow(content, ContentPosition.Top == ContentPosition ? 0 : 1);
                Grid.SetRow(animation, ContentPosition.Bottom == ContentPosition ? 0 : 1);
                content.ClearValue(Grid.RowSpanProperty);
                animation.ClearValue(Grid.RowSpanProperty);
                Grid.SetColumnSpan(content, 2);
                Grid.SetColumnSpan(animation, 2);
                content.VerticalContentAlignment = (ContentPosition.Top == ContentPosition)
                        ? VerticalAlignment.Bottom
                        : VerticalAlignment.Top;
                content.HorizontalContentAlignment = HorizontalAlignment.Center;

                break;
            }
            }
        }
コード例 #5
0
        /// <summary>
        /// Binds the ContentPresenter's Content property to the Binding set on this control.
        /// </summary>
        private void UpdateBindings()
        {
            if (_content == null)
            {
                return;
            }

            if (_binding != null)
            {
                _content.SetBinding(ContentPresenter.ContentProperty, _binding);
            }
            else
            {
                _content.ClearValue(ContentPresenter.ContentProperty);
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
ファイル: ContentPresenterTest.cs プロジェクト: ynkbt/moon
        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")
                            );
        }
コード例 #8
0
        private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ContentPresenter cp = (ContentPresenter)d;
            bool             reevaluateTemplate;

            if (cp.ContentTemplate != null)
            {
                reevaluateTemplate = false; // explicit template - do not re-apply
            }
            else if (cp.Template == UIElementContentTemplate)
            {
                reevaluateTemplate = true; // direct template - always re-apply
                cp.Template        = null; // and release the old content so it can be re-used elsewhere
            }
            else
            {
                Debug.Assert(cp.Template == null ||
                             cp.Template == DefaultContentTemplate);
                reevaluateTemplate = true; // default template - always re-apply
            }

            if (e.NewValue is UIElement)
            {
                // If we're using the content directly, clear the data context.
                // The content expects to inherit.
                cp.ClearValue(DataContextProperty);
            }
            else
            {
                // set data context to the content, so that the template can bind to
                // properties of the content.
                cp.DataContext = e.NewValue;
            }

            if (reevaluateTemplate)
            {
                cp.ReevaluateTemplate();
            }
        }
コード例 #9
0
 protected override void OnTransitionEnded(TransitionElement transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
 {
     newContent.ClearValue(ContentPresenter.RenderTransformProperty);
     oldContent.ClearValue(ContentPresenter.RenderTransformProperty);
 }
コード例 #10
0
        internal Size MeasureTemplate(Size rect, object record, GridColumnBase column, GridQueryBounds bounds, ContentPresenter ctrl)
#endif
        {
#if UWP
            var _popUp = GetPopUp();
            _popUp.Child  = ctrl;
            ctrl.FontSize = column != null && column.hasFontSize ? GetFontSize(column) : FontSize;
            ctrl.ClearValue(ContentPresenter.MarginProperty);
#endif
            ctrl.Measure(new Size());
            if (column.GetType() == typeof(GridUnBoundColumn))
            {
                var contentValue      = (GridBase as SfDataGrid).GetUnBoundCellValue(column as GridColumn, record);
                var dataContextHelper = GetDataContextHelper(column, record);
                dataContextHelper.Value = contentValue;
                ctrl.Content            = dataContextHelper;
            }
            else
            {
                if (column.SetCellBoundValue)
                {
                    var dataContextHelper = GetDataContextHelper(column, record);
                    dataContextHelper.SetValueBinding(column.ValueBinding, record);
                    ctrl.Content = dataContextHelper;
                }
                else
                {
                    ctrl.DataContext = record;
                    ctrl.Content     = record;
                }
            }

            if (column.hasCellTemplate)
            {
                ctrl.ContentTemplate = column.CellTemplate;
            }
            else if (column.hasCellTemplateSelector)
            {
                ctrl.ContentTemplateSelector = column.CellTemplateSelector;
            }
            else
            {
                if (column.IsTemplate && GridBase.hasCellTemplateSelector)
                {
                    ctrl.ContentTemplateSelector = GridBase.CellTemplateSelector;
                }
            }

            var controlsize = Size.Empty;
            if (bounds == GridQueryBounds.Height)
            {
                var tectangleWidth = column.IsHidden || column.Width == 0.0 ? GetDefaultLineSize() : rect.Width;
                ctrl.Measure(new Size(tectangleWidth, Double.PositiveInfinity));
                controlsize = ctrl.DesiredSize.Height == 0 ? new Size(ctrl.DesiredSize.Width, this.GridBase.RowHeight) : ctrl.DesiredSize;
            }
            else
            {
                ctrl.Measure(new Size(Double.PositiveInfinity, rect.Height));
                controlsize = ctrl.DesiredSize.Width == 0 ? new Size(150, ctrl.DesiredSize.Height) : ctrl.DesiredSize;
            }
            ctrl.Content                 = null;
            ctrl.ContentTemplate         = null;
            ctrl.ContentTemplateSelector = null;
#if UWP
            _popUp.Child = null;
#endif
            return(controlsize);
        }
コード例 #11
0
 private void _innerFrameInLabDimensions_Unchecked(object sender, RoutedEventArgs e)
 {
     // Leave CI mode
     _pagePresenter.ClearValue(MaxWidthProperty);
     _pagePresenter.ClearValue(MaxHeightProperty);
 }