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

Nik*_*wal 5 .net c# wpf xaml

我创建了一个mycustomItemsPanelApp.Resources

<Application.Resources>
    <ItemsPanelTemplate x:Key="mycustomItemsPanel">
        .... Some code here
    </ItemsPanelTemplate>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)

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

<.... ItemsPanel="{StaticResource mycustomItemsPanel}" />
Run Code Online (Sandbox Code Playgroud)

但我知道这可以作为提供

<.... ItemsPanel="Binding Source={StaticResource mycustomItemsPanel}}" />
Run Code Online (Sandbox Code Playgroud)

这些有什么区别?

H.B*_*.B. 3

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

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

DataSourceProvider使用 then提供的对象而不是其DataSourceProvider本身。

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