WPF静态资源无法解析

时间:2013-06-01 11:04:10

标签: wpf mvvm

我在app.xaml中定义了静态资源

<Application x:Class="PortfolioManagementApp.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:PortfolioManagementApp.Models" 
             >
<Application.Resources>
<x:Array x:Key="CityList" Type="local:City">
            <local:City Name = "Ottawa" />
            <local:City Name = "Toronto"/>
            <local:City Name = "North Bay"/>
        </x:Array>
</Application.Resources>
</Application>


namespace PortfolioManagementApp.Models
{
    public class City
    {
        public string Name { get; set; }
        public string ShortCode { get; set; }
    }
}

我正在尝试为控件中的组合框访问ItemSource的此资源

<ComboBox DisplayMemberPath="Name" Grid.Column="1" Grid.Row="7" Height="22" HorizontalAlignment="Left" ItemsSource="{StaticResource CityList}" Margin="3,5,0,5" Name="cityComboBox" VerticalAlignment="Center" Width="120">

我为CityList抛出'静态资源无法解析'。在组合框中。我在这做错了什么

0 个答案:

没有答案