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


C# FrameworkElement.GetValue方法代码示例

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


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

示例1: MultiDataTriggerBasicTest

        public void MultiDataTriggerBasicTest()
        {
            Condition condition1 = new Condition { Binding = new Binding { Path = PropertyPath.Parse("X") }, Value = 1 };
            Condition condition2 = new Condition { Binding = new Binding { Path = PropertyPath.Parse("Y") }, Value = 2 };

            MultiDataTrigger multiDataTrigger = new MultiDataTrigger();
            multiDataTrigger.Conditions.Add(condition1);
            multiDataTrigger.Conditions.Add(condition2);
            multiDataTrigger.Setters.Add(new Setter { Property = new DependencyPropertyPathElement(Value1Property), Value = 1 });

            FrameworkElement element = new FrameworkElement();
            element.DataContext = new Point(1, 2);

            Assert.AreEqual(0, element.GetValue(Value1Property));

            element.Triggers.Add(multiDataTrigger);
            Assert.AreEqual(1, element.GetValue(Value1Property));

            element.DataContext = Point.Zero;
            Assert.AreEqual(0, element.GetValue(Value1Property));

            element.DataContext = new Point(1, 2);
            Assert.AreEqual(1, element.GetValue(Value1Property));

            element.Triggers.Remove(multiDataTrigger);
            Assert.AreEqual(0, element.GetValue(Value1Property));
        }
开发者ID:highzion,项目名称:Granular,代码行数:27,代码来源:TriggerTest.cs

示例2: UpdateProperty

    internal void UpdateProperty( FrameworkElement element, DependencyProperty elementProp, DependencyProperty definitionProperty )
    {
      object currentValue = this.GetValue( definitionProperty );
      object localValue = this.ReadLocalValue( definitionProperty );
      object elementValue = element.GetValue( elementProp );
      bool areEquals = false;

      // Avoid setting values if it does not affect anything 
      // because setting a local value may prevent a style setter from being active.
      if( localValue != DependencyProperty.UnsetValue )
      {
        if( ( elementValue != null ) && ( currentValue != null ) )
        {
          areEquals = ( elementValue.GetType().IsValueType && currentValue.GetType().IsValueType )
                      ? elementValue.Equals( currentValue )  // Value Types
                      : currentValue == element.GetValue( elementProp ); // Reference Types
        }

        if( !areEquals )
        {
          element.SetValue( elementProp, currentValue );
        }
        else
        {
          element.ClearValue( elementProp );
        }
      }
    }
开发者ID:austinedeveloper,项目名称:WpfExtendedToolkit,代码行数:28,代码来源:EditorDefinitionBase.cs

示例3: EditableFrameworkElement

        internal EditableFrameworkElement(CanvasEditor editor, FrameworkElement element)
        {
            Editor = editor;
            UIElement = element;
            Position = new PointNotifyPropertyChanged(new Point(
                (double)element.GetValue(Canvas.LeftProperty),
                (double)element.GetValue(Canvas.TopProperty)));
            Size = new SizeNotifyPropertyChanged(new Size(
                (double)element.GetValue(Canvas.WidthProperty),
                (double)element.GetValue(Canvas.HeightProperty)));

            Binding xBinding = new Binding(PointNotifyPropertyChanged.XProperty);
            xBinding.Source = Position;
            element.SetBinding(Canvas.LeftProperty, xBinding);

            Binding yBinding = new Binding(PointNotifyPropertyChanged.YProperty);
            yBinding.Source = Position;
            element.SetBinding(Canvas.TopProperty, yBinding);

            Binding wBinding = new Binding(SizeNotifyPropertyChanged.WidthProperty);
            wBinding.Source = Size;
            element.SetBinding(Canvas.WidthProperty, wBinding);

            Binding hBinding = new Binding(SizeNotifyPropertyChanged.HeightProperty);
            hBinding.Source = Size;
            element.SetBinding(Canvas.HeightProperty, hBinding);

            Position.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Position_PropertyChanged);
            Size.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Size_PropertyChanged);
        }
开发者ID:Kaftan777ski,项目名称:mapinect,代码行数:30,代码来源:EditableFrameworkElement.cs

示例4: WasClicked

	bool WasClicked (FrameworkElement item, double x, double y)
	{
		double left = (double) item.GetValue (Canvas.LeftProperty);
		double top = (double) item.GetValue (Canvas.TopProperty);
		
		return (x >= left && x <= (left + item.Width)
			&& y >= top && y <= (top + item.Height));
	}
开发者ID:dfr0,项目名称:moon,代码行数:8,代码来源:video-player.cs

示例5: RemoveNavegationRegion

 public void RemoveNavegationRegion(FrameworkElement region_)
 {
     var container = GetContainerRegion((string)region_.GetValue(NavigationRegion.RegionNameProperty), (string)region_.GetValue(NavigationRegion.NavegationContextProperty));
     if (container != null)
     {
         _regionsRepository.Remove(container);
     }
 }
开发者ID:angelcdz,项目名称:Sirius,代码行数:8,代码来源:Navegator.cs

示例6: GetPushBindings

 public static PushBindingCollection GetPushBindings(FrameworkElement obj)
 {
     if (obj.GetValue(PushBindingsProperty) == null)
     {
         obj.SetValue(PushBindingsProperty, new PushBindingCollection(obj));
     }
     return (PushBindingCollection)obj.GetValue(PushBindingsProperty);
 }
开发者ID:vnl,项目名称:Monies,代码行数:8,代码来源:PushBindingManager.cs

示例7: Point

        public static Point CalculateElementPos
            (Point newMousePos, Point oldMousePos, FrameworkElement fe)
        {
            //We use the new position substract the old mouse position to find its X, & Y 
            //Increment and then we calculate where the object should be.
            double deltaV = newMousePos.Y - oldMousePos.Y;
            double deltaH = newMousePos.X - oldMousePos.X;
            double newTop = deltaV + (double)fe.GetValue(Canvas.TopProperty);
            double newLeft = deltaH + (double)fe.GetValue(Canvas.LeftProperty);

            return new Point(newLeft, newTop);
        }
开发者ID:SamuelToh,项目名称:Masters_Degree_Major_Project,代码行数:12,代码来源:UIHelper.cs

示例8: Get

 public object Get(FrameworkElement elem, DependencyProperty prop)
 {
     return elem.Dispatcher.Invoke(new Func<object>(() =>
     {
         return elem.GetValue(prop);
     }));
 }
开发者ID:icedream,项目名称:modernminas-launcher,代码行数:7,代码来源:OptionsDialog.xaml.cs

示例9: GetAllowDrag

        public static bool GetAllowDrag(FrameworkElement frameworkElement)
        {
            if (frameworkElement == null)
                throw new ArgumentNullException("frameworkElement");

            return frameworkElement.GetValue(AllowDragPropery).Return(x => (bool)x, false);
        }
开发者ID:NickSerg,项目名称:image-to-eps,代码行数:7,代码来源:DragDrop.cs

示例10: GetDragCommand

        public static ICommand GetDragCommand(FrameworkElement frameworkElement)
        {
            if (frameworkElement == null)
                throw new ArgumentNullException("frameworkElement");

            return frameworkElement.GetValue(DragCommandProperty) as ICommand;
        }
开发者ID:NickSerg,项目名称:image-to-eps,代码行数:7,代码来源:DragDrop.cs

示例11: GetAllowableDataFormats

        public static string GetAllowableDataFormats(FrameworkElement frameworkElement)
        {
            if (frameworkElement == null)
                throw new ArgumentNullException("frameworkElement");

            return frameworkElement.GetValue(AllowableDataFormatsProperty) as string;
        }
开发者ID:NickSerg,项目名称:image-to-eps,代码行数:7,代码来源:DragDrop.cs

示例12: GetIsConfigurable

 /// <summary>
 /// Gets the value of the IsConfigurable attached property for a specified FrameworkElement.
 /// </summary>
 /// <param name="element">The FrameworkElement from which the property value is read.</param>
 /// <returns>The IsConfigurable property value for the FrameworkElement.</returns>
 public static bool GetIsConfigurable(FrameworkElement element)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     return (bool)element.GetValue(IsConfigurableProperty);
 }
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:13,代码来源:ElementExtensions.cs

示例13: GetDefaultSource

 public static string GetDefaultSource(FrameworkElement image)
 {
     if (image == null)
     {
         throw new ArgumentNullException("Image");
     }
     return (string)image.GetValue(ImageDecoder.DefaultSourceProperty);
 }
开发者ID:nick121212,项目名称:xima_desktop3,代码行数:8,代码来源:ImageDecoder.cs

示例14: GetHasBeenStyled

 private static bool GetHasBeenStyled(FrameworkElement element)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     return (bool) element.GetValue(HasBeenStyledProperty);
 }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:8,代码来源:ImplicitStyleManager.cs

示例15: GetFill

 public static bool GetFill(FrameworkElement element)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     return (bool)element.GetValue(ZoomScrollViewer.FillProperty);
 }
开发者ID:ssickles,项目名称:archive,代码行数:8,代码来源:ZoomScrollViewer.cs


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