C# WPF绑定:无法解析静态资源

C# WPF绑定:无法解析静态资源,c#,wpf,xaml,binding,C#,Wpf,Xaml,Binding,我试着跑,但遇到了绑定问题 设计器突出显示错误无法解决资源“monthCollection” 如何将Utility.MonthCollection用作本地资源 XAML部分: <Window x:Class="FaceReport.WindowMain" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml

我试着跑,但遇到了绑定问题

设计器突出显示错误
无法解决资源“monthCollection”

如何将Utility.MonthCollection用作本地资源

XAML部分:

<Window x:Class="FaceReport.WindowMain"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Title="Rapor" Height="402" Width="600" WindowState="Normal">
<Grid Name="gridMain" x:Uid="uidGridMain">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <ComboBox SelectedIndex="0" 
              DisplayMemberPath="Value" SelectedValuePath="Key" Margin="132,9,200,0"
              Grid.Row="3" Height="24" VerticalAlignment="Top" Name="cbBind" 

              ItemsSource="{Binding Source={StaticResource Utility.ReportForCollection},
                Path=Utility.ReportForCollection}"                   
              />
 </Grid>
 </Window>

C部分:

namespace FaceReport
{
内部类实用程序
{
公共枚举报告
{
选择,
全部的
集团,,
人
}
专用静态字典(用于);;
公共静态字典ReportForCollection
{
得到
{
返回(为);;
}
}
静态实用程序()
{
//为每个枚举使用用户友好的字符串初始化集合
_dictReportFor=新字典(){
{ReportFor.Choose,“Lütfen seçinazing…”,
{ReportFor.All,“Herkes”},
{ReportFor.Group,“Grup”},
{ReportFor.Person,“Şahıs};
}
}
/// 
///申请书的主要表格
/// 
公共部分类WindowMain:Window
{
/// 
///建造师
/// 
公共WindowMain()
{
初始化组件();
}
}

您缺少此位:


->此实用程序类可以实例化为资源请在app.xaml中添加如下条目:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
          <ResourceDictionary Source="/Skins/ControlSkin.xaml">
         </ResourceDictionary>
            <ResourceDictionary Source="/Skins/ListBox.xaml">
          </ResourceDictionary>
        </ResourceDictionary.MergedDicionaries>
    </ResourceDictionary>
</Application.Resources>

请发布代码的相关部分,而不是链接到外部网站或博客。
<Application.Resources>
    <local:Utility x:Key="monthCollection"/>
</Application.Resources>
xmlns:local="clr-namespace:YourNamespaceHere"
<Window x:Class="FaceReport.WindowMain"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FaceReport"

 Title="Rapor" Height="402" Width="600" WindowState="Normal">

<Application.Resources>
    <local:Utility x:Key="reportCollection"/>
</Application.Resources>

 <Grid Name="gridMain" x:Uid="uidGridMain">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <ComboBox SelectedIndex="0" DisplayMemberPath="Value" SelectedValuePath="Key"  Margin="132,9,200,0" Grid.Row="3" Height="24" VerticalAlignment="Top" Name="cbBind" 
     ItemsSource="{Binding Source={StaticResource reportCollection}, Path=ReportForCollection}" />
 </Grid>
</Window>
<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
          <ResourceDictionary Source="/Skins/ControlSkin.xaml">
         </ResourceDictionary>
            <ResourceDictionary Source="/Skins/ListBox.xaml">
          </ResourceDictionary>
        </ResourceDictionary.MergedDicionaries>
    </ResourceDictionary>
</Application.Resources>