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


C# DependencyObject.GetValue方法代码示例

本文整理汇总了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);
            }

        }
开发者ID:sanjayasl,项目名称:Q42.WinRT,代码行数:53,代码来源:ImageExtensions.cs

示例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;
        }
开发者ID:HimanshPal,项目名称:Cimbalino-Toolkit,代码行数:35,代码来源:MonitoredInteraction.cs

示例3: GetXmlnsDefinition

        public static string GetXmlnsDefinition(DependencyObject dependencyObject)
        {
            if (dependencyObject == null)
                throw new ArgumentNullException ();

            return (string)dependencyObject.GetValue (XmlnsDefinitionProperty);
        }
开发者ID:shahid-pk,项目名称:MonoPresentationFoundation,代码行数:7,代码来源:XmlAttributeProperties.cs

示例4: GetXmlNamespaceMaps

        public static string GetXmlNamespaceMaps(DependencyObject dependencyObject)
        {
            if (dependencyObject == null)
                throw new ArgumentNullException ();

            return (string)dependencyObject.GetValue (XmlNamespaceMapsProperty);
        }
开发者ID:shahid-pk,项目名称:MonoPresentationFoundation,代码行数:7,代码来源:XmlAttributeProperties.cs

示例5: GetPlacementTarget

	public static UIElement GetPlacementTarget(DependencyObject element)
	{
		if (element == null)
			throw new ArgumentNullException ("element");

		return (UIElement)element.GetValue(ToolTipService.PlacementTargetProperty);
	}
开发者ID:kangaroo,项目名称:moon,代码行数:7,代码来源:ToolTipService.cs

示例6: GetWorkflowDefinitionLockObject

 internal static object GetWorkflowDefinitionLockObject(DependencyObject dependencyObject)
 {
     lock (dependencyObject)
     {
         return dependencyObject.GetValue(WorkflowDefinitionLockObjectProperty);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:WorkflowDefinitionLock.cs

示例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;
        }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:30,代码来源:FocusManager.cs

示例8: GetXmlnsDictionary

		public static XmlnsDictionary GetXmlnsDictionary (DependencyObject dependencyObject)
		{
			if (dependencyObject == null)
				throw new ArgumentNullException ();

			return (XmlnsDictionary)dependencyObject.GetValue (XmlnsDictionaryProperty);
		}
开发者ID:alesliehughes,项目名称:olive,代码行数:7,代码来源:XmlAttributeProperties.cs

示例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;
 }
开发者ID:expanz,项目名称:expanz-Microsoft-XAML-SDKs,代码行数:13,代码来源:ValidationHelper.cs

示例10: GetPlacement

 public static PlacementMode GetPlacement(DependencyObject element)
 { 
     if (element == null)
     {
         throw new ArgumentNullException("element"); 
     }
     return (PlacementMode)element.GetValue(ToolTipService.PlacementProperty);
 } 
开发者ID:kangaroo,项目名称:moon,代码行数:8,代码来源:ToolTipService.cs

示例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);
        }
开发者ID:lecode-official,项目名称:mvvm-framework,代码行数:13,代码来源:UIElement.cs

示例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;
 }
开发者ID:ruisebastiao,项目名称:DevExpress.Mvvm.Free,代码行数:8,代码来源:Interaction.cs

示例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);
 }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:15,代码来源:DataGridFrozenGrid.cs

示例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);
        }
开发者ID:lecode-official,项目名称:mvvm-framework,代码行数:13,代码来源:ScrollViewer.cs

示例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);
        }
开发者ID:lecode-official,项目名称:mvvm-framework,代码行数:13,代码来源:Control.cs


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