[英]Property name in Bindings case insensitive?
I was debugging a piece of code and to my surprise the following lines both worked correct. 我正在调试一段代码,令我惊讶的是以下几行都正常。
Binding binding = new Binding("Text", myObject, "PropertyName");
Binding binding = new Binding("Text", myObject, "propertyname");
It seems that the property name is case-insensitive, but I cannot find anything about this. 似乎属性名称不区分大小写,但我找不到任何关于此的内容。
Can anybody tell me if I am missing something, or what could be the rational behind this? 任何人都可以告诉我,如果我错过了什么,或者这背后的理性是什么?
I don't know where it is documented, but it is in the source indeed. 我不知道它在哪里记录,但它确实在源头 。
It uses a StringComparison.OrdinalIgnoreCase
to compare the property name from the binding with the actual object's property: 它使用StringComparison.OrdinalIgnoreCase
将绑定的属性名称与实际对象的属性进行比较:
if( tempPropInfo==null
&&
String.Equals (propInfos[i].Name, propertyName, StringComparison.OrdinalIgnoreCase)
)
{
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.