tags:

views:

28

answers:

1

Let's say I have a class defined something like the below:

namespace MyProject.MyConstants
{
    public class Constants
    {
        public class Group1Constants
        {
            public const string DoIt= "DoIt";
        }
    }
}

I am trying to use this const, from a separate project, in my xaml. I included the namespace:

xmlns:constants="clr-namespace:MyProject.MyConstants;assembly=MyProject.MyConstants"

and am trying to use the constant as follows:

<MenuItem Header="{x:Static controls:Constants.Group1Constants.DoIt}">

The above wont compile though, saying that

Cannot find the type 'Constants.Group1Constants'. Note that type names are case sensitive.

I must be missing something simple. All I want to do is use some constants from a class in different project in my xaml.

Any suggestions?

A: 

Try this one:

<MenuItem Header="{x:Static constants:Constants+Group1Constants.DoIt}">

I used "+" instead of "." to reference the nested class. Not sure if you'll run into problems doing this though.

karmicpuppet
Awesome, that fixed it! I have never seen the "+" syntax before.
Flack