绑定与x之间的区别:绑定 [英] Difference between Binding and x:Bind
问题描述
在UWP中使用什么,绑定
或 x:绑定
它们之间有什么区别? p>
因为我看到很多帖子,人们使用绑定
,我只绑定与 x:在UWP中绑定
在MSDN主页上,它只表示由 {x:Bind }
和 {Binding}
在很大程度上与功能相当。而 x:绑定
是更快。
但是它们之间有什么区别?
因为 不等同于。
我的报价链接: MSDN
所以我的问题是:
在UWP中使用Binding或x:Bind有什么区别?
以下可能不完整,但有一些主要区别是
-
旧样式
{Binding}
- 绑定到DataContext
- 绑定到属性名称,灵活关于实际的来源类型
- 新样式
{x:Bind}
- 绑定到框架元素(代码隐藏类)
- 需要在compi上修改所有类型le时间
- 默认为更节俭的OneTime模式
和从构建14393开始, {x:Bind}
支持:
- 直接BooleanToVisibility绑定,没有ValueConverter
- 扩展功能绑定
- cast
- 索引器
较新的{x:Bind}在运行时更快一些,但同样重要的是会给错误绑定的编译器错误。在{Binding}中,大多数情况下您将看到一个空的控件。
What to use in UWP, Binding
or x:Bind
and what is the difference between them?
Because I see a lot of posts where people use Binding
and I only Bind with x:Bind
in UWP.
At the MSDN Homepage it only says that "the binding objects created by {x:Bind}
and {Binding}
are largely functionally equivalent." and that x:Bind
is faster.
But what is the difference between them?
Because "largely functionally equivalent" does not mean equivalent.
The Link from my Quote: MSDN
So my Question is:
What is the difference in using Binding or x:Bind in UWP?
The following is probably not complete, but some of the major differences are
Old style
{Binding }
- binds to the DataContext
- binds to a Property Name, flexible about the actual source type
- New style
{x:Bind }
- binds to the Framework element (code-behind class)
- needs all types fixed at compile time
- defaults to the more frugal OneTime mode
And starting with build 14393, {x:Bind }
supports:
- direct BooleanToVisibility binding, without a ValueConverter
- expanded Function binding
- casting
- dictionary indexers
The newer {x:Bind } is a little faster at runtime but just as important it will give compiler errors for erroneous bindings. With {Binding } you would just see an empty Control in most cases.
这篇关于绑定与x之间的区别:绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!