xaml语法中的圆括号 [英] round brackets in xaml syntax

查看:282
本文介绍了xaml语法中的圆括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用ColorAnimation更改控件背景时,我正在使用以下语法:

when I'm using ColorAnimation to change Background of control i'm using following syntax:

<ColorAnimation Duration="0:0:0.5" 
 Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)" 
 To="Black" />

我很高兴它能工作,但是我无法在xaml语法参考中找到有关圆括号的任何信息...

I'm very happy it works but I couldn't find any information about round braces in xaml syntax reference ...

那么您能否解释一下该语法的来源和大括号的实际含义?

So could you please explain where does this syntax come from and what does the round brace actually mean?

这将非常有帮助. 谢谢

It would be very helpful. Thanks

推荐答案

请参阅 PropertyPath XAML语法:

括号表示 PropertyPath中的属性应为 使用局部构造 资格.它可以使用XML 使用名称空间查找类型 适当的映射. ownerType 搜索XAML处理器的类型 可以通过访问 XmlnsDefinitionAttribute声明 在每个程序集中.大多数应用 映射了默认的XML名称空间 到 http://schemas.microsoft.com/winfx/2006/xaml/presentation 命名空间,因此前缀通常只是 自定义类型或类型必需的 否则在该名称空间之外. propertyName必须解析为 存在于 ownerType.该语法通常是 用于以下情况之一:

The parentheses indicate that this property in a PropertyPath should be constructed using a partial qualification. It can use an XML namespace to find the type with an appropriate mapping. The ownerType searches types that a XAML processor has access to, through the XmlnsDefinitionAttribute declarations in each assembly. Most applications have the default XML namespace mapped to the http://schemas.microsoft.com/winfx/2006/xaml/presentation namespace, so a prefix is usually only necessary for custom types or types otherwise outside that namespace. propertyName must resolve to be the name of a property existing on the ownerType. This syntax is generally used for one of the following cases:

  • 在XAML中指定的路径采用的样式或模板 没有指定的目标类型.一种 合格用法通常无效 对于除此以外的其他情况,因为 非样式,非模板的情况 属性存在于实例上,而不是 类型.

  • The path is specified in XAML that is in a style or template that does not have a specified Target Type. A qualified usage is generally not valid for cases other than this, because in non-style, non-template cases, the property exists on an instance, not a type.

该属性是附加属性.

您正在绑定到静态属性.

You are binding to a static property.

这篇关于xaml语法中的圆括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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