本文整理汇总了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));
}
示例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 );
}
}
}
示例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);
}
示例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));
}
示例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);
}
}
示例6: GetPushBindings
public static PushBindingCollection GetPushBindings(FrameworkElement obj)
{
if (obj.GetValue(PushBindingsProperty) == null)
{
obj.SetValue(PushBindingsProperty, new PushBindingCollection(obj));
}
return (PushBindingCollection)obj.GetValue(PushBindingsProperty);
}
示例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);
}
示例8: Get
public object Get(FrameworkElement elem, DependencyProperty prop)
{
return elem.Dispatcher.Invoke(new Func<object>(() =>
{
return elem.GetValue(prop);
}));
}
示例9: GetAllowDrag
public static bool GetAllowDrag(FrameworkElement frameworkElement)
{
if (frameworkElement == null)
throw new ArgumentNullException("frameworkElement");
return frameworkElement.GetValue(AllowDragPropery).Return(x => (bool)x, false);
}
示例10: GetDragCommand
public static ICommand GetDragCommand(FrameworkElement frameworkElement)
{
if (frameworkElement == null)
throw new ArgumentNullException("frameworkElement");
return frameworkElement.GetValue(DragCommandProperty) as ICommand;
}
示例11: GetAllowableDataFormats
public static string GetAllowableDataFormats(FrameworkElement frameworkElement)
{
if (frameworkElement == null)
throw new ArgumentNullException("frameworkElement");
return frameworkElement.GetValue(AllowableDataFormatsProperty) as string;
}
示例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);
}
示例13: GetDefaultSource
public static string GetDefaultSource(FrameworkElement image)
{
if (image == null)
{
throw new ArgumentNullException("Image");
}
return (string)image.GetValue(ImageDecoder.DefaultSourceProperty);
}
示例14: GetHasBeenStyled
private static bool GetHasBeenStyled(FrameworkElement element)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
return (bool) element.GetValue(HasBeenStyledProperty);
}
示例15: GetFill
public static bool GetFill(FrameworkElement element)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
return (bool)element.GetValue(ZoomScrollViewer.FillProperty);
}