只读依赖项属性 [英] Read Only Dependency Properties

查看:79
本文介绍了只读依赖项属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在ReadOnlyDependencyProperties中需要set子句以及为什么此set子句位于PropertyKey上?

Why in ReadOnlyDependencyProperties we need the set clause and why this set clause is on the PropertyKey?

推荐答案

您好,

在只读依赖项属性中,SetValue用于在初始化时为 DependencyPropertyKey 设置值,而不是直接将其破坏并设置为私有后备字段.要注意的是使用 DependencyPropertyKey 设置依赖性属性标识符.从而防止您暴露内部

MSDN提供了您需要的所有说明,请仔细阅读这些链接.

请参阅创建自定义只读依赖项属性"部分 [此处 [
Hi There,

In Read only dependency properties SetValue is used to set value for DependencyPropertyKey at initialisation instead of breaking and setting the value to private backing field directly.and thing to note is DependencyPropertyKey is used to set the dependency property identifier. Thus prevent you from exposing internal

MSDN got all explainations you need in detail read these links.

see Creating Custom Read-Only Dependency Properties section[^]

Dependency Properties Securities Explained here[^]

Hope this helps you. Thanks


这篇关于只读依赖项属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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