当前位置: 首页>>代码示例>>C#>>正文


C# ContentPresenter.SetValue方法代码示例

本文整理汇总了C#中System.Windows.Controls.ContentPresenter.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# ContentPresenter.SetValue方法的具体用法?C# ContentPresenter.SetValue怎么用?C# ContentPresenter.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.ContentPresenter的用法示例。


在下文中一共展示了ContentPresenter.SetValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ThemedWindow

        public ThemedWindow()
        {
            this.ShouldBeThemed();

            WindowStyle = WindowStyle.None;
            ResizeMode = ResizeMode.CanResizeWithGrip;
            Background = Brushes.Transparent;
            AllowsTransparency = true;
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            ShowInTaskbar = false;

            Grid host = new Grid();
            //Header
            host.RowDefinitions.Add(new RowDefinition
            {
                Height = GridLength.Auto
            });
            //Body
            host.RowDefinitions.Add(new RowDefinition());

            FrameworkElement header = BuildHeaderArea();
            header.SetValue(Grid.RowProperty, 0);
            host.Children.Add(header);

            ContentPresenter contentPresenter = new ContentPresenter();
            contentPresenter.SetValue(Grid.RowProperty, 1);
            contentPresenter.SetBinding(ContentPresenter.ContentProperty, new Binding
            {
                Mode = BindingMode.OneWay,
                RelativeSource = new RelativeSource
                {
                    Mode = RelativeSourceMode.FindAncestor,
                    AncestorType = typeof(ThemedWindow)
                },
                Path = new PropertyPath("Content")
            });
            contentPresenter.Resources = Resources;
            host.Children.Add(contentPresenter);

            host.SetResourceReference(BackgroundProperty, EnvironmentColors.ToolWindowBackgroundBrushKey);

            Border hostContainer = new Border
            {
                Child = host,
                //Margin = new Thickness(1, 1, 5, 5),
                BorderThickness = new Thickness(1)
            };
            hostContainer.SetResourceReference(BorderBrushProperty, EnvironmentColors.MainWindowActiveDefaultBorderBrushKey);
            //hostContainer.Effect = new DropShadowEffect
            //{
            //    Direction = -75,
            //    ShadowDepth = 2,
            //    BlurRadius = 2,
            //    Color = Colors.Azure
            //};

            base.Content = hostContainer;
        }
开发者ID:madskristensen,项目名称:Packman,代码行数:58,代码来源:ThemedWindow.cs

示例2: DragContentAdorner

        public DragContentAdorner(UIElement adornedElement, object draggedData, DataTemplate dataTemplate, Point offset)
            : base(adornedElement)
        {
            _contentPresenter = new ContentPresenter {
                Content = draggedData,
                ContentTemplate = dataTemplate,
                Opacity = 0.7
            };

            _translate = new TranslateTransform { X = 0, Y = 0 };
            _contentPresenter.RenderTransform = _translate;

            _offset = offset;

            Host.Children.Add(_contentPresenter);

            _contentPresenter.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Left);
            _contentPresenter.SetValue(VerticalAlignmentProperty, VerticalAlignment.Top);
        }
开发者ID:t-kojima,项目名称:FluidLauncher,代码行数:19,代码来源:DragContentAdorner.cs

示例3: BeginTransition

        protected internal override void BeginTransition(TransitionElement transitionElement, ContentPresenter oldContent, ContentPresenter newContent)
        {
            Storyboard oldStoryboard = OldContentStoryboard;
            Storyboard newStoryboard = NewContentStoryboard;

            if (oldStoryboard != null || newStoryboard != null)
            {
                oldContent.Style = OldContentStyle;
                newContent.Style = NewContentStyle;

                // Flag to determine when both storyboards are done
                bool done = oldStoryboard == null || newStoryboard == null;

                if (oldStoryboard != null)
                {
                    oldStoryboard = oldStoryboard.Clone();
                    oldContent.SetValue(OldContentStoryboardProperty, oldStoryboard);
                    oldStoryboard.Completed += delegate
                    {
                        if (done)
                            EndTransition(transitionElement, oldContent, newContent);
                        done = true;
                    };
                    oldStoryboard.Begin(oldContent, true);
                }

                if (newStoryboard != null)
                {
                    newStoryboard = newStoryboard.Clone();
                    newContent.SetValue(NewContentStoryboardProperty, newStoryboard);
                    newStoryboard.Completed += delegate
                    {
                        if (done)
                            EndTransition(transitionElement, oldContent, newContent);
                        done = true;
                    };
                    newStoryboard.Begin(newContent, true);
                }
            }
            else
            {
                EndTransition(transitionElement, oldContent, newContent);
            }
        }
开发者ID:sclcwwl,项目名称:Gimela,代码行数:44,代码来源:StoryboardTransition.cs

示例4: CreateTickMark

        /// <summary>
        /// 
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        FrameworkElement CreateTickMark(Point start, Point end, TickLocation location)
        {
            // If no template was specified, use the default
                if (TickTemplate == null)
                {
                    System.Windows.Shapes.Line ln = new System.Windows.Shapes.Line();
                    ln.Stroke = new SolidColorBrush(Colors.Black);
                    ln.StrokeThickness = 1.0;
                    ln.X1 = start.X;
                    ln.Y1 = start.Y;
                    ln.X2 = end.X;
                    ln.Y2 = end.Y;

                    return ln;
                }
                else
                {
                    ContentPresenter cp = new ContentPresenter();
                    //cp.Content = "a";
                    cp.ContentTemplate = TickTemplate;

                    if (location == TickLocation.Top)
                    {
                        cp.SetValue(Canvas.TopProperty, start.Y - cp.ActualHeight);
                        cp.SetValue(Canvas.LeftProperty, start.X - (cp.ActualWidth / 2));
                    }
                    else
                    {
                        cp.SetValue(Canvas.TopProperty, end.Y);
                        cp.SetValue(Canvas.LeftProperty, start.X - (cp.ActualWidth / 2));
                    }

                    return cp;
                }
        }
开发者ID:senfo,项目名称:snaglV2,代码行数:41,代码来源:Slider.cs

示例5: AddTickmark

 private void AddTickmark(double position)
 {
     ContentPresenter c = new ContentPresenter();
     c.SetValue(PositionProperty, position);
     c.SetBinding(ContentPresenter.ContentTemplateProperty, new System.Windows.Data.Binding()
     {
         Source = this,
         BindsDirectlyToSource = true,
         Path = new PropertyPath("TickMarkTemplate")
     });
     Children.Add(c);
 }
开发者ID:Esri,项目名称:arcgis-toolkit-sl-wpf,代码行数:12,代码来源:TickBar.cs

示例6: SetIsCenter

 private static void SetIsCenter(ContentPresenter element, bool value)
 {
     element.SetValue(IsCentersCenterPropertyKey, value);
 }
开发者ID:edealbag,项目名称:bot,代码行数:4,代码来源:Graph.cs

示例7: CreateDragAdorner

    private static void CreateDragAdorner(DropInfo dropInfo)
    {
      var template = GetDragAdornerTemplate(m_DragInfo.VisualSource);
      var templateSelector = GetDragAdornerTemplateSelector(m_DragInfo.VisualSource);

      UIElement adornment = null;

      var useDefaultDragAdorner = GetUseDefaultDragAdorner(m_DragInfo.VisualSource);
      var useVisualSourceItemSizeForDragAdorner = GetUseVisualSourceItemSizeForDragAdorner(m_DragInfo.VisualSource);

      if (template == null && templateSelector == null && useDefaultDragAdorner) {
        var bs = CaptureScreen(m_DragInfo.VisualSourceItem, m_DragInfo.VisualSourceFlowDirection);
        if (bs != null) {
          var factory = new FrameworkElementFactory(typeof(Image));
          factory.SetValue(Image.SourceProperty, bs);
          factory.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);
          factory.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.HighQuality);
          factory.SetValue(FrameworkElement.WidthProperty, bs.Width);
          factory.SetValue(FrameworkElement.HeightProperty, bs.Height);
          factory.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Left);
          factory.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Top);
          template = new DataTemplate { VisualTree = factory };
        }
      }

      if (template != null || templateSelector != null) {
        if (m_DragInfo.Data is IEnumerable && !(m_DragInfo.Data is string)) {
          if (!useDefaultDragAdorner && ((IEnumerable)m_DragInfo.Data).Cast<object>().Count() <= 10) {
            var itemsControl = new ItemsControl();
            itemsControl.ItemsSource = (IEnumerable)m_DragInfo.Data;
            itemsControl.ItemTemplate = template;
            itemsControl.ItemTemplateSelector = templateSelector;

            if (useVisualSourceItemSizeForDragAdorner)
            {
              var bounds = VisualTreeHelper.GetDescendantBounds(m_DragInfo.VisualSourceItem);
              itemsControl.SetValue(FrameworkElement.MinWidthProperty, bounds.Width);
            }

            // The ItemsControl doesn't display unless we create a grid to contain it.
            // Not quite sure why we need this...
            var grid = new Grid();
            grid.Children.Add(itemsControl);
            adornment = grid;
          }
        } else {
          var contentPresenter = new ContentPresenter();
          contentPresenter.Content = m_DragInfo.Data;
          contentPresenter.ContentTemplate = template;
          contentPresenter.ContentTemplateSelector = templateSelector;

          if (useVisualSourceItemSizeForDragAdorner)
          {
            var bounds = VisualTreeHelper.GetDescendantBounds(m_DragInfo.VisualSourceItem);
            contentPresenter.SetValue(FrameworkElement.MinWidthProperty, bounds.Width);
            contentPresenter.SetValue(FrameworkElement.MinHeightProperty, bounds.Height);
          }

          adornment = contentPresenter;
        }
      }

      if (adornment != null) {
        if (useDefaultDragAdorner) {
          adornment.Opacity = GetDefaultDragAdornerOpacity(m_DragInfo.VisualSource);
        }

        var rootElement = RootElementFinder.FindRoot(dropInfo.VisualTarget ?? m_DragInfo.VisualSource);
        DragAdorner = new DragAdorner(rootElement, adornment);
      }
    }
开发者ID:Deadpikle,项目名称:gong-wpf-dragdrop,代码行数:71,代码来源:DragDrop.cs

示例8: Render

        private void Render()
        {
            ColumnDefinitions.Clear();
            Children.Clear();

            if (ItemsSource == null) return;

            var i = 0;
            foreach (var item in ItemsSource)
            {
                var valueProperty = item.GetType().GetProperty(ValueMemberPath);
                var value = valueProperty != null ? (int)valueProperty.GetValue(item, null) : 1;

                var column = new ColumnDefinition {Width = new GridLength(value, GridUnitType.Star)};
                ColumnDefinitions.Add(column);

                var bar = new ContentPresenter {ContentTemplate = ItemTemplate, Content = item};
                Children.Add(bar);
                bar.SetValue(ColumnProperty, i);
                i++;
            }
        }
开发者ID:mousetwentytwo,项目名称:test,代码行数:22,代码来源:ProportionalPanel.cs

示例9: CreateTick

 FrameworkElement CreateTick(Point start, Point end)
 {
     if (TickTemplate == null) {
         Line ln = new Line();
         ln.SetBinding(Line.StrokeProperty, new System.Windows.Data.Binding("Foreground"));
         ln.StrokeThickness = 1.0;
         ln.X1 = start.X;
         ln.Y1 = start.Y;
         ln.X2 = end.X;
         ln.Y2 = end.Y;
         return ln;
     } else {
         ContentPresenter cp = new ContentPresenter();
         cp.Content = "a";
         cp.ContentTemplate = TickTemplate;
         cp.SetValue(Canvas.TopProperty, (IsHorizontal ? start.Y : start.Y - cp.ActualHeight / 2 ));
         cp.SetValue(Canvas.LeftProperty, (IsHorizontal ? start.X - cp.ActualWidth / 2 : start.X));
         return cp;
     }
     //return null;
 }
开发者ID:LucasPeacecraft,项目名称:rawr,代码行数:21,代码来源:RangeSlider.xaml.cs

示例10: SetRefreshTriggerBinding

 public static void SetRefreshTriggerBinding(ContentPresenter element, bool value)
 {
     element.SetValue(RefreshTriggerBindingProperty, value);
 }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:4,代码来源:ContentTemplateSelector.RefreshTriggerBinding.cs


注:本文中的System.Windows.Controls.ContentPresenter.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。