wpf - WPF 是完全区分大小写的吗?宽度字段中的 "Auto"值是否区分大小写?

标签 wpf xaml width

这是 WPF 的 v.basic 问题。

乍一看,WPF 似乎是区分大小写的。但是,如果这必须是真的,那么 width="auto"和 width="Auto"怎么都可以正常工作呢?另一方面,如果不区分大小写,那么为什么控件不接受“宽度”作为其属性?您只能使用“Width”(大写 W)来定义控件的宽度。

Consolidated answer link

最佳答案

对了一半。

来自官方XAML Overview page

XAML is generally speaking case sensitive. For purposes of resolving backing types, WPF XAML is case sensitive by the same rules that the CLR is case sensitive. Object elements, property elements, and attribute names must all be specified by using the sensitive casing when compared by name to the underlying type in the assembly, or to a member of a type. XAML language keywords and primitives are also case sensitive. Values are not always case sensitive. Case sensitivity for values will depend on the type converter behavior associated with the property that takes the value, or the property value type. For example, properties that take the Boolean type can take either true or True as equivalent values, but only because the native WPF XAML parser type conversion for string to Boolean already permits these as equivalents.

一般 XAML 是区分大小写的,但属性值并不总是因为这取决于属性转换器,所以在大多数情况下它可以工作,例如 Autoauto,尽管在​​某些特殊情况下,属性转换器可能无法以不区分大小写的方式处理它们

注意:我们在这里讨论的是属性,而不是属性名称

关于wpf - WPF 是完全区分大小写的吗?宽度字段中的 "Auto"值是否区分大小写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9377824/

相关文章:

c# - 列表框未绑定(bind)到 BindingList<T>

c# - MVVM? mvvmc?还是我做错了?

c# - 如何让一个简单的超链接在 XAML 中工作?

c++ - 为什么来自 GetWindowRect(rcWindow2) 的 cx/cy 与馈入 OnSize 的 cx/cy 不同?

wpf - WPF UserControl上的依赖注入(inject)(Windsor)

c# - 如何从另一个控件中绑定(bind)到自定义控件按钮可见性

c# - WPF 改变对象的位置

c# - 使用数据绑定(bind)访问 DataTemplate 中的 WPF 组件

html - border-collapse 改变元素的宽度

css - 为什么这个 `word-wrap: break-word` 规则在 Firefox 中没有按预期工作?