-1

i have two assemblies
1. MyProj.GUI 2. MyProj

in MyProj i define an enum MergeAction {ApplyTarget, ApplyToWorkingCopy, Ignore};
in the MyProj.GUI, i have a Xaml for Combobox as so:

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>

when i open the Window, i get the exception System.Resources.MissingManifestResourceException
Could not find any resources appropriate for the specified culture or the neutral culture...

Without having the ComboBox.Items Tag... everything is cool...

why is that?
what am i doing wrong?

Edit:

The assembly is called several times from the Xaml (even the same object)
Example

 <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>

but only the ComboBox is doing the error.

Tomer W
  • 3,395
  • 2
  • 29
  • 44
  • Is it the only place where you use another assembly? It seems that the problem not in Xaml, it occures when another assembly is loaded. – dvvrd Jul 03 '12 at 06:49
  • @dvvrd no, i use it a lot, the ViewModel is in this `Merge` assembly. edited the post – Tomer W Jul 03 '12 at 06:54
  • May be you are trying to localize display names of the MergeAction enum or smth like this? And it is really interesting to see some of your VM code – dvvrd Jul 03 '12 at 07:00

1 Answers1

1

Well, Found the Solution:

I'm kind'a nub to WPF so i don't know the reason why it worked, but it did!

I Added an ItemTemplate to the ComboBox as such:

<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>

And now it is all Cool..

But,... I don't get why?

Tomer W
  • 3,395
  • 2
  • 29
  • 44
  • Heh, really cool :) And will this exception be thrown if you change TextBlock tag into one? – dvvrd Jul 03 '12 at 07:12
  • Yes, it does happen again with the `ContentPresenter`, what's the difference ? why is that so? what resources did it search for? – Tomer W Jul 03 '12 at 07:25
  • I can`t know it exactly, but maybe when you are trying to pass some enum value into ContentPresenter, WPF magic does not just call ToString() for this but wants to do possible localization and requests resources with current culture for this. Your issue is [known](http://support.microsoft.com/kb/839861?ln=en-us). I would recomend you using [ObjectDataProvider](http://stackoverflow.com/questions/6145888/how-to-bind-an-enum-to-a-combobox-control-in-wpf) instead of your solution, it makes adding values to enum more simple and not so cheaty :) – dvvrd Jul 03 '12 at 07:59
  • I Tried ObjectDataProvider as well, thought it is the problem so i simplified the situation :) it fails as well if there is no template. – Tomer W Jul 03 '12 at 08:04