本文整理汇总了C#中DependencyObject.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject.GetValue方法的具体用法?C# DependencyObject.GetValue怎么用?C# DependencyObject.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DependencyObject
的用法示例。
在下文中一共展示了DependencyObject.GetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCacheUriChanged
private static async void OnCacheUriChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
//Uri oldCacheUri = (Uri)e.OldValue;
Uri newCacheUri = (Uri)d.GetValue(CacheUriProperty);
if (newCacheUri != null)
{
try
{
//Get image from cache (download and set in cache if needed)
var cacheUri = await WebDataCache.GetLocalUriAsync(newCacheUri);
// Check if the wanted image uri has not changed while we were loading
if (newCacheUri != (Uri)d.GetValue(CacheUriProperty)) return;
#if NETFX_CORE
//Set cache uri as source for the image
SetSourceOnObject(d, new BitmapImage(cacheUri));
#elif WINDOWS_PHONE
BitmapImage bimg = new BitmapImage();
using (IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream stream = iso.OpenFile(cacheUri.PathAndQuery, FileMode.Open, FileAccess.Read))
{
bimg.SetSource(stream);
}
}
//Set cache uri as source for the image
SetSourceOnObject(d, bimg);
#endif
}
catch (Exception ex)
{
Debug.WriteLine(ex);
//Revert to using passed URI
SetSourceOnObject(d, new BitmapImage(newCacheUri), false);
}
}
else
{
SetSourceOnObject(d, null, false);
}
}
示例2: GetBehaviors
/// <summary>
/// Gets the <see cref="BehaviorCollection"/> associated with a specified object.
/// </summary>
/// <param name="obj">The object from which to retrieve the <see cref="BehaviorCollection"/>.</param>
/// <returns>A <see cref="BehaviorCollection"/> containing the behaviors associated with the specified object.</returns>
public static BehaviorCollection GetBehaviors(DependencyObject obj)
{
var behaviorCollection = (BehaviorCollection)obj.GetValue(BehaviorsProperty);
if (behaviorCollection == null)
{
#if WINDOWS_PHONE
behaviorCollection = (BehaviorCollection)typeof(BehaviorCollection)
.GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, null)
.Invoke(null);
#else
behaviorCollection = new BehaviorCollection();
#endif
obj.SetValue(BehaviorsProperty, behaviorCollection);
obj.SetValue(Interaction.BehaviorsProperty, behaviorCollection);
var frameworkElement = obj as FrameworkElement;
if (frameworkElement != null)
{
frameworkElement.Loaded -= FrameworkElement_Loaded;
frameworkElement.Loaded += FrameworkElement_Loaded;
frameworkElement.Unloaded -= FrameworkElement_Unloaded;
frameworkElement.Unloaded += FrameworkElement_Unloaded;
}
}
return behaviorCollection;
}
示例3: GetXmlnsDefinition
public static string GetXmlnsDefinition(DependencyObject dependencyObject)
{
if (dependencyObject == null)
throw new ArgumentNullException ();
return (string)dependencyObject.GetValue (XmlnsDefinitionProperty);
}
示例4: GetXmlNamespaceMaps
public static string GetXmlNamespaceMaps(DependencyObject dependencyObject)
{
if (dependencyObject == null)
throw new ArgumentNullException ();
return (string)dependencyObject.GetValue (XmlNamespaceMapsProperty);
}
示例5: GetPlacementTarget
public static UIElement GetPlacementTarget(DependencyObject element)
{
if (element == null)
throw new ArgumentNullException ("element");
return (UIElement)element.GetValue(ToolTipService.PlacementTargetProperty);
}
示例6: GetWorkflowDefinitionLockObject
internal static object GetWorkflowDefinitionLockObject(DependencyObject dependencyObject)
{
lock (dependencyObject)
{
return dependencyObject.GetValue(WorkflowDefinitionLockObjectProperty);
}
}
示例7: GetFocusScope
/// <summary>
/// Gets the closest ancestor of the specified element which is a focus scope.
/// </summary>
/// <param name="element">The element for which to find a focus scope.</param>
/// <returns>The closest ancestor of the specified element which is a focus scope.</returns>
public static DependencyObject GetFocusScope(DependencyObject element)
{
Contract.Require(element, "element");
if (element.GetValue<Boolean>(IsFocusScopeProperty))
return element;
var current = element as UIElement;
if (current != null)
{
var logicalParent = LogicalTreeHelper.GetParent(current);
if (logicalParent != null)
{
return GetFocusScope(logicalParent);
}
var visualParent = VisualTreeHelper.GetParent(current);
if (visualParent != null)
{
return GetFocusScope(visualParent);
}
}
return current;
}
示例8: GetXmlnsDictionary
public static XmlnsDictionary GetXmlnsDictionary (DependencyObject dependencyObject)
{
if (dependencyObject == null)
throw new ArgumentNullException ();
return (XmlnsDictionary)dependencyObject.GetValue (XmlnsDictionaryProperty);
}
示例9: GetValidationMetadata
/// <summary>
/// Gets the ValidationMetadata property for the input control
/// </summary>
/// <param name="inputControl">The input control to get the ValidationMetadata property from.</param>
/// <returns>The ValidationMetadata associated with the input control.</returns>
internal static ValidationMetadata GetValidationMetadata(DependencyObject inputControl)
{
if (inputControl == null)
{
throw new ArgumentNullException("inputControl");
}
return inputControl.GetValue(ValidationMetadataProperty) as ValidationMetadata;
}
示例10: GetPlacement
public static PlacementMode GetPlacement(DependencyObject element)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
return (PlacementMode)element.GetValue(ToolTipService.PlacementProperty);
}
示例11: GetInputBindings
/// <summary>
/// Gets the value of the <see cref="InputBindingsProperty"/> attached property.
/// </summary>
/// <param name="uiElement">The UI element which is used to get the value.</param>
/// <returns>Returns the value of the attached property.</returns>
public static ICommand GetInputBindings(DependencyObject uiElement)
{
// Validates the argument
if (uiElement == null)
throw new ArgumentNullException(nameof(uiElement));
return (ICommand)uiElement.GetValue(UIElement.InputBindingsProperty);
}
示例12: GetBehaviors
public static BehaviorCollection GetBehaviors(DependencyObject d) {
BehaviorCollection behaviors = (BehaviorCollection)d.GetValue(BehaviorsProperty);
if(behaviors == null) {
behaviors = new BehaviorCollection();
d.SetValue(BehaviorsProperty, behaviors);
}
return behaviors;
}
示例13: GetIsFrozen
/// <summary>
/// Gets a value that indicates whether the grid is frozen.
/// </summary>
/// <param name="element">
/// The object to get the <see cref="P:System.Windows.Controls.Primitives.DataGridFrozenGrid.IsFrozen" /> value from.
/// </param>
/// <returns>true if the grid is frozen; otherwise, false. The default is true.</returns>
public static bool GetIsFrozen(DependencyObject element)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
return (bool)element.GetValue(IsFrozenProperty);
}
示例14: GetIsHorizontalScrollingEnabled
/// <summary>
/// Gets the value of the <see cref="IsHorizontalScrollingEnabledProperty"/> attached property.
/// </summary>
/// <param name="scrollViewer">The scroll viewer which is used to get the value.</param>
/// <returns>Returns the value of the attached property.</returns>
public static bool GetIsHorizontalScrollingEnabled(DependencyObject scrollViewer)
{
// Validates the parameters
if (scrollViewer == null)
throw new ArgumentNullException(nameof(scrollViewer));
return (bool)scrollViewer.GetValue(ScrollViewer.IsHorizontalScrollingEnabledProperty);
}
示例15: GetIsValid
/// <summary>
/// Gets the value of the <see cref="IsValidProperty"/> attached property.
/// </summary>
/// <param name="frameworkElement">The framework element which is used to get the value.</param>
/// <returns>Returns the value of the attached property.</returns>
public static bool GetIsValid(DependencyObject frameworkElement)
{
// Validates the argument
if (frameworkElement == null)
throw new ArgumentNullException(nameof(frameworkElement));
return (bool)frameworkElement.GetValue(Control.IsValidProperty);
}