什么是使用&QUOT之间的差异;用的StaticResource&QUOT约束力;并使用"的StaticResource直接"在WPF [英] What is the difference between using "Binding with StaticResource" and using "StaticResource directly" in WPF

查看:95
本文介绍了什么是使用&QUOT之间的差异;用的StaticResource&QUOT约束力;并使用"的StaticResource直接"在WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 App.Resources

<Application.Resources>
    <ItemsPanelTemplate x:Key="mycustomItemsPanel">
        .... Some code here
    </ItemsPanelTemplate>
</Application.Resources>

和提供这一个UIControl这样

and providing this to a UIControl this way

<.... ItemsPanel="{StaticResource mycustomItemsPanel}" />

不过,我才知道,这可以作为

But I came to know that this can be provided as

<.... ItemsPanel="Binding Source={StaticResource mycustomItemsPanel}}" />

这两者之间的区别是什么?

What is the difference between these?

推荐答案

一方面绑定只能在的依赖属性,另一种是某些对象的行为不同,当为一个 Binding.Source ,即的 DataSourceProviders

For one thing the binding will only be able on dependency properties, another would be that some objects behave differently when assigned as a Binding.Source, namely DataSourceProviders.

公共基类和合同的 DataSourceProvider 的对象,这是工厂中执行的一些查询,产生一个单一的对象,或者您可以使用作为绑定源对象的对象的列表。

Common base class and contract for DataSourceProvider objects, which are factories that execute some queries to produce a single object or a list of objects that you can use as binding source objects.

所规定的对象 DataSourceProvider 则是用来代替 DataSourceProvider 本身。

The object provided by the DataSourceProvider then is used instead of the DataSourceProvider itself.

在这种特定情况下出现,因此应的没有实际的区别的。

In this specific case there hence should be no practical difference.

这篇关于什么是使用&QUOT之间的差异;用的StaticResource&QUOT约束力;并使用&QUOT;的StaticResource直接&QUOT;在WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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