繁体   English   中英

使用“绑定与StaticResource”和在WPF中使用“StaticResource”之间的区别是什么

[英]What is the difference between using “Binding with StaticResource” and using “StaticResource directly” in WPF

我在mycustomItemsPanel中创建了一个App.Resources

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

并以这种方式将其提供给UIControl

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

但我知道这可以作为提供

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

这些有什么区别?

一方面,绑定只能用于依赖属性 ,另一方面是某些对象在被指定为Binding.Source时表现不同,即DataSourceProviders

DataSourceProvider对象的公共基类和契约,它们是执行某些查询以生成单个对象的工厂或可用作绑定源对象的对象列表。

然后使用DataSourceProvider提供的对象而不是DataSourceProvider本身。

在这种特定情况下,因此应该没有实际差异

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM