0

This problem is pretty much the same as this one. However my problem is that I get this error but it does compile run and find it find.

My XAML with the error is a resource dictionary (in a different project) and it is trying to use an enum called MainViewMode in a style. I have inherited the code from a previous team so I do not know why it was originally written like this but the xaml consists of all the path data for icons (using the <geometry> tag) as well as all of the Styles. I don't think this is relevant to the problem but just thought I would highlight it anyway.

As I said, when the program runs it does work fine however the designer mode is not working on one of the forms I need to modify and it is making it really annoying.

xmlns:cenum="clr-namespace:ABC;assembly=DEF"
...
  <Style x:Key="MainViewToggleButtonStyle" TargetType="ToggleButton">
     <Setter Property="SnapsToDevicePixels" Value="true" />
     <Setter Property="OverridesDefaultStyle" Value="true" />
     <Setter Property="CommandParameter" Value="{x:Static cenum:MainViewMode.Overview}" />
...
</style>

I have a resource dictionary, it calls an enum in a different project and says that it can't find it. It does however find it at runtime and work fine. The main issue is that the designer doesn't load for any forms using this resource dictionary.

Community
  • 1
  • 1
Keithin8a
  • 961
  • 7
  • 32
  • 1
    Please if you feel the need to down vote me when I have a perfectly valid question, at least have the decency to say why so that I can improve the question. – Keithin8a Jun 03 '15 at 12:13
  • I'ts hard to understand like this, add your codes – Noam M Jun 03 '15 at 12:15
  • I'm not the downvoter, but what are you asking specifically? – Patrick Jun 03 '15 at 12:15
  • @Patrick It's the same problem as in the link provided. I am getting the same error message but for my class and namespace. My specific problem is that it builds and runs and works perfectly but the designer doesn't show because of this error when I am trying to make the UI. – Keithin8a Jun 03 '15 at 12:19
  • You still need to show your code, it should be different than in the question you linked to. We can't help you if you keep us in the dark. Add more information to your question and someone might be able to give you an answer. Your code, class and namespace is a good place to start – CJK Jun 03 '15 at 12:29
  • @NoamM I have added some code and a summary of my problem. The reason why I didn't add code in the first place was because if you click the link to the other question I found you can see pretty much the same code. The previous question however did not seem to build and run so hence why I asked mine. – Keithin8a Jun 03 '15 at 12:30
  • the designer often doesn't work correctly for no reason – thumbmunkeys Jun 03 '15 at 12:31
  • @ThomasWeller I didn't flag them. I would have told you if I did, I don't hide behind anything on this site. – Keithin8a Jun 03 '15 at 13:05

1 Answers1

0

I believe your problem is that your namespace is incorrect. Take a look at the top answer in the question you linked to and notice how they have the example namespace. Since you're getting the enum from a different project you will also want to add that project as a reference.

To get the namespace right find the folder that the enum class is in, or if it's not in a folder just the project name. The namespace will be like one of the following,

If it's in a folder try something like this

 ProjectName.FolderName;assembly=ProjectName

If not try something like this

ProjectName;assembly=ProjectName
CJK
  • 952
  • 2
  • 10
  • 22
  • In my XAML which is using the resource dictionary I am using the following piece of code at the top. ' ' The bottom resource dictionary (which is in the same folder) works fine. and the spelling for the namespace is both the same. – Keithin8a Jun 03 '15 at 13:00
  • Sorry that was awful formatting, the help didn't help me get the code formatted. Additionally if the namespace was incorrect then wouldn't that mean that the program wouldn't work? Or does it try to resolve it the best it can at runtime? – Keithin8a Jun 03 '15 at 13:02
  • No problem I'll pick through it, you can't format code in a comment anyway. Im not sure why it would be working if the namespace is incorrect but I would start with trying correct it nonetheless – CJK Jun 03 '15 at 13:19
  • You also want to make sure the other project is added as a reference – CJK Jun 03 '15 at 13:21
  • It was the fact that the project wasn't referenced, which explains why it was working at runtime. Thank you very much for helping me out with this. – Keithin8a Jun 03 '15 at 13:39