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正在执行错误。
答案 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>
现在一切都很酷..
但是,......我不明白为什么?