WPF-将静态资源分配到XAML数组中,无需代码延迟
我正在处理MS.NET WPF;在XAML中,我定义了一些静态资源。我想把它们分配到一个数组中,这个数组也是用XAML声明的 以下是静态资源:WPF-将静态资源分配到XAML数组中,无需代码延迟,wpf,xaml,staticresource,Wpf,Xaml,Staticresource,我正在处理MS.NET WPF;在XAML中,我定义了一些静态资源。我想把它们分配到一个数组中,这个数组也是用XAML声明的 以下是静态资源: <local:Person x:Key="PersonABC" Name="Hello" Age="29" /> <local:Person x:Key="PersonXYZ" Name="World" Age="55" /> 但我想要的是: <x:Array x:Key="PersonList" Type="{x:Typ
<local:Person x:Key="PersonABC" Name="Hello" Age="29" />
<local:Person x:Key="PersonXYZ" Name="World" Age="55" />
但我想要的是:
<x:Array x:Key="PersonList" Type="{x:Type local:Person}">
"{StaticResource PersonABC}"
"{StaticResource PersonXYZ}"
</x:Array>
“{StaticResource PersonABC}”
“{StaticResource PersonXYZ}”
静态资源可以用标记(元素)格式编写:
看
<x:Array x:Key="PersonList" Type="{x:Type local:Person}">
"{StaticResource PersonABC}"
"{StaticResource PersonXYZ}"
</x:Array>
<x:Array x:Key="PersonList" Type="{x:Type local:Person}">
<StaticResource ResourceKey="PersonABC"/>
<StaticResource ResourceKey="PersonXYZ"/>
</x:Array>