English 中文(简体)
为何不允许设置约束性变量[重复]
原标题:Why variables are not allowed for binding [duplicate]

为何不允许本地或全球变量作为WPF数据约束源; 只有包装属性才能被约束。

所以问题是,在变量上,哪些属性是折叠的属性,为什么这些属性是允许的,为什么变量是不允许的。

我需要知道 在引擎盖系统下。

最佳回答

用于绑定的机制 (PropertyDescriptionor , < a href=" >DefabidentencyProperty 等) ), 只能使用属性, 属性是您无法与字段捆绑的原因。 属性可以提供验证、 更改通知和更多, 这是选择属性的另一个原因。 字段不提供这些属性 。

而且,使用公共领域通常都是不良做法,所以它们为什么要费力执行对领域有约束力的规定?这只会促进这些不良做法。

问题回答

这不是完全真实的。您 能够 使用一个字段来设定一个约束性, 但首先您必须声明它像一种资源, 在通过约束性宣言中的资源键访问它之后 。

当您要重新约束对财产有约束力的代码时, 完成此操作是为了同时弹出 on Porperty Changed 通知 。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...