通过Xaml调用不同程序集的枚举值时缺少资源

时间:2012-07-03 06:40:12

标签: wpf xaml exception resources enums

我有两个组件
1. MyProj.GUI 2. MyProj

MyProj中的

我定义了enum MergeAction {ApplyTarget, ApplyToWorkingCopy, Ignore};
MyProj.GUI中,我有一个Xaml for Combobox:

xmlns:Merge="clr-namespace:Megatec.EB2UDF.Merge;assembly=Megatec.EB2UDF"

<DataTemplate DataType="{x:Type Merge:DifferenceViewModel}">
  <ComboBox SelectedValue="{Binding Path=MergeAction}">
    <ComboBox.Items>
      <Merge:MergeAction>Ignore</Merge:MergeAction>
      <Merge:MergeAction>ApplyToWorkingCopy</Merge:MergeAction>
      <Merge:MergeAction>ApplyToTarget</Merge:MergeAction>
    </ComboBox.Items>
  </ComboBox>
</DataTemplate>

当我打开窗口时,我得到异常System.Resources.MissingManifestResourceException
找不到适合指定文化或中性文化的资源......

没有ComboBox.Items标签......一切都很酷......

为什么会这样? 我究竟做错了什么?

编辑:

从Xaml(甚至同一个对象)中多次调用程序集 实施例

 <ribbon:Button Label="Send Change"  CommandParameter="{x:Static Merge:MergeAction.ApplyToTarget}" Command="{Binding ApplyActionCommand}">
     <ribbon:Button.ImageSourceLarge>
        <BitmapImage UriSource="/Images/MAIL.png" />
     </ribbon:Button.ImageSourceLarge>
 </ribbon:Button>

ComboBox正在执行错误。

1 个答案:

答案 0 :(得分:1)

好吧,找到了解决方案:

我很喜欢WPF,所以我不知道它为什么会起作用,但确实如此!

我在ItemTemplate添加了ComboBox

<ComboBox SelectedValue="{Binding Path=MergeAction}">
  <ComboBox.Items>
    <Merge:MergeAction>Ignore</Merge:MergeAction>
    <Merge:MergeAction>ApplyToWorkingCopy</Merge:MergeAction>
    <Merge:MergeAction>ApplyToTarget</Merge:MergeAction>
  </ComboBox.Items>
  <ComboBox.ItemTemplate>
    <DataTemplate>
      <TextBlock Text="{Binding}"></TextBlock>
    </DataTemplate>
  </ComboBox.ItemTemplate>
</ComboBox>

现在一切都很酷..

但是,......我不明白为什么?