本文整理汇总了C#中System.Windows.DependencyObject.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject.GetValue方法的具体用法?C# DependencyObject.GetValue怎么用?C# DependencyObject.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.DependencyObject
的用法示例。
在下文中一共展示了DependencyObject.GetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAttachedDataContext
/// <summary>
/// Gets the value of the <strong>AttachedDataContext</strong> attached property from a given
/// <see cref="DependencyObject"/> object.
/// </summary>
/// <param name="obj">The object from which to read the property value.</param>
/// <return>The value of the <strong>AttachedDataContext</strong> attached property.</return>
/// <exception cref="ArgumentNullException">
/// <paramref name="obj"/> is <see langword="null"/>.
/// </exception>
public static object GetAttachedDataContext(DependencyObject obj)
{
if (obj == null)
throw new ArgumentNullException("obj");
return obj.GetValue(AttachedDataContextProperty);
}
示例2: SetPropertyValueOnTarget
public static bool SetPropertyValueOnTarget(DependencyObject target, string propertyName,bool ballowed)
{
var prop = GetDependencyProperty(target, propertyName);
if (target.GetValue(prop) == null || target.GetValue(prop).GetType() == typeof(string))
{
if (!ballowed)
{
target.SetValue(prop, String.Empty);
}
return true;
}
if (target.GetValue(prop).GetType() == typeof(bool))
{
target.SetValue(prop, ballowed);
return true;
}
if (target.GetValue(prop).GetType() == typeof(Visibility))
{
if (ballowed)
{
target.SetValue(prop, Visibility.Visible);
}
else
{
target.SetValue(prop, Visibility.Collapsed);
}
return true;
}
return false;
}
示例3: GetPushBindings
public static PushBindingCollection GetPushBindings(DependencyObject obj)
{
if (obj.GetValue(PushBindingsProperty) == null)
{
obj.SetValue(PushBindingsProperty, new PushBindingCollection(obj));
}
return (PushBindingCollection)obj.GetValue(PushBindingsProperty);
}
示例4: ColumnPropertiesGroup
// ------------------------------------------------------------------
// Constructor.
// Remarks - the pageWidth parameter can be used to limit column
// properties if the element is a FlowDocument.
// ------------------------------------------------------------------
internal ColumnPropertiesGroup(DependencyObject o)
{
_columnWidth = (double)o.GetValue(FlowDocument.ColumnWidthProperty);
_columnGap = (double)o.GetValue(FlowDocument.ColumnGapProperty);
_columnRuleWidth = (double)o.GetValue(FlowDocument.ColumnRuleWidthProperty);
_columnRuleBrush = (Brush)o.GetValue(FlowDocument.ColumnRuleBrushProperty);
_isColumnWidthFlexible = (bool)o.GetValue(FlowDocument.IsColumnWidthFlexibleProperty);
}
示例5: OnPropertyChanged
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var sourceValue = d.GetValue(ExtendedBinding.SourceProperty);
var targetValue = d.GetValue(ExtendedBinding.TargetProperty);
if (e.Property == ExtendedBinding.SourceProperty && !object.ReferenceEquals(sourceValue, targetValue))
d.SetValue(ExtendedBinding.TargetProperty, sourceValue);
else if (e.Property == ExtendedBinding.TargetProperty && !object.ReferenceEquals(sourceValue, targetValue))
d.SetValue(ExtendedBinding.SourceProperty, targetValue);
}
示例6: GetModifiedTypeface
internal static Typeface GetModifiedTypeface(DependencyObject element, FontFamily fontFamily)
{
Debug.Assert(element != null);
FontStyle fontStyle = (FontStyle) element.GetValue(TextElement.FontStyleProperty);
FontWeight fontWeight = (FontWeight) element.GetValue(TextElement.FontWeightProperty);
FontStretch fontStretch = (FontStretch) element.GetValue(TextElement.FontStretchProperty);
return new Typeface(fontFamily, fontStyle, fontWeight, fontStretch);
}
示例7: GetConnectionPoints
internal static List<ConnectionPoint> GetConnectionPoints(DependencyObject obj)
{
if (obj is StartSymbol)
{
return (List<ConnectionPoint>)obj.GetValue(StateContainerEditor.ConnectionPointsProperty);
}
if (!(obj is VirtualizedContainerService.VirtualizingContainer))
{
obj = VisualTreeUtils.FindVisualAncestor<VirtualizedContainerService.VirtualizingContainer>(obj);
}
return (List<ConnectionPoint>)obj.GetValue(StateContainerEditor.ConnectionPointsProperty);
}
示例8: OnTimeChanged
private static void OnTimeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
DoubleAnimation animation = (DoubleAnimation)sender;
double time = GetTime(animation);
Thickness from = (Thickness)sender.GetValue(FromProperty);
Thickness to = (Thickness)sender.GetValue(ToProperty);
DependencyProperty targetProperty = (DependencyProperty)sender.GetValue(TargetPropertyProperty);
DependencyObject target = (DependencyObject)sender.GetValue(TargetProperty);
target.SetValue(targetProperty, new Thickness((to.Left - from.Left) * time + from.Left,
(to.Top - from.Top) * time + from.Top,
(to.Right - from.Right) * time + from.Right,
(to.Bottom - from.Bottom) * time + from.Bottom));
}
示例9: AnimateEasingEquation
public static AnimationClock AnimateEasingEquation(
DependencyObject element,
DependencyProperty prop,
EasingFunction function,
double to,
int durationMS)
{
double from = double.IsNaN((double)element.GetValue(prop)) ?
0 :
(double)element.GetValue(prop);
AnimationTimeline timeline = GetEasingAnimation(function, EasingMode.EaseIn, from, to, durationMS);
return Animate(element, prop, timeline, durationMS, null, null, null);
}
示例10: GetBoundPassword
public static string GetBoundPassword(DependencyObject d)
{
var box = d as PasswordBox;
if (box == null)
return (string) d.GetValue(BoundPasswordProperty);
box.PasswordChanged -= PasswordChanged;
box.PasswordChanged += PasswordChanged;
var password = box.ToString();
if (password != null)
SetSelection(box, password.Length, 0);
return (string)d.GetValue(BoundPasswordProperty);
}
示例11: GetSortInfo
public static SortInfo GetSortInfo(DependencyObject obj)
{
if (obj == null)
throw new ArgumentNullException("obj");
return (SortInfo)obj.GetValue(SortInfoProperty.DependencyProperty);
}
示例12: GetSortField
public static string GetSortField(DependencyObject obj)
{
if (obj == null)
throw new ArgumentNullException("obj");
return (string)obj.GetValue(SortFieldProperty);
}
示例13: GetHeaderSort
public static bool GetHeaderSort(DependencyObject obj)
{
if (obj == null)
throw new ArgumentNullException("obj");
return (bool)obj.GetValue(HeaderSortProperty);
}
示例14: GetSelectedItemsSource
/// <summary>
/// Gets the IList that contains the values that should be selected.
/// </summary>
/// <param name="element">The ListBox to check.</param>
public static IList GetSelectedItemsSource(DependencyObject element)
{
if (element == null)
throw new ArgumentNullException("element");
return (IList)element.GetValue(SelectedItemsSourceProperty);
}
示例15: return
/// <summary>
/// Gets the update source on change.
/// </summary>
/// <param name="obj">The object.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
/// <exception cref="System.ArgumentNullException">obj</exception>
public static bool GetUpdateSourceOnChange
(DependencyObject obj)
{
if (obj == null) throw new ArgumentNullException("obj");
return (bool)obj.GetValue(UpdateSourceOnChangeProperty);
}