什么是一个依赖属性?它有什么用呢? [英] What is a dependency property? What is its use?

查看:490
本文介绍了什么是一个依赖属性?它有什么用呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  什么是依赖属性?

什么是依赖属性?它是如何从一个普通财产有什么不同?依赖属性的目的是什么?

What is a dependency property? How does it differ from a normal property? What is the purpose of dependency properties?

推荐答案

依赖属性:由一个 <一个支持的属性href="http://msdn.microsoft.com/en-us/library/system.windows.dependencyproperty.aspx">DependencyProperty.

Dependency property: A property that is backed by a DependencyProperty.

依赖属性的目的是提供一种方法来计算一个属性的根据价值的其他投入的价值。

The purpose of dependency properties is to provide a way to compute the value of a property based on the value of other inputs.

这些其他投入可能包括系统属性,如主题和用户preference,只是即时性决定机制,如数据绑定和动画/故事板,多次使用的模板,如资源和样式,或值知通过与元素树等元素的父子关系。

These other inputs might include system properties such as themes and user preference, just-in-time property determination mechanisms such as data binding and animations/storyboards, multiple-use templates such as resources and styles, or values known through parent-child relationships with other elements in the element tree.

它具有以下功能:

  • 该属性可以在样式进行设置。

  • The property can be set in a style.

该属性可以通过数据绑定设置。

The property can be set through data binding.

属性可以设置动态的资源引用。

The property can be set with a dynamic resource reference.

该属性可以自动从元素树父元素继承其价值。

The property can inherit its value automatically from a parent element in the element tree.

属性可以是动画。

属性,当属性的previous值已经改变,属性值可以强制可以报告。

The property can report when the previous value of the property has been changed and the property value can be coerced.

属性报告信息WPF,如是否更改属性值应要求布局系统重新对视觉效果的元素。

The property reports information to WPF, such as whether changing a property value should require the layout system to recompose the visuals for an element.

属性接收WPF设计为Visual Studio支持。例如,该属性可编辑在属性窗口中。

The property receives support in the WPF Designer for Visual Studio. For example, the property can be edited in the Properties window.

(内容摘自MSDN)

这篇关于什么是一个依赖属性?它有什么用呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆