Binding to static texts from An Infrastructure assembly

Topics: Prism v4 - WPF 4
Oct 10, 2012 at 1:41 PM
Edited Oct 10, 2012 at 1:55 PM

I want to bind the titles of the Views to static text's from our Infrastructure's Titles Class.
Adding a symbol prefix (e.g "Ref") and registering it's namespace and use it in the View
What I want is to achieve something similar to this :

Part1:

xmlns:Ref="clr-namespace:Xz.Infrastructure;assembly=Xz.Infrastructure"

Part2:

<TextBlock Text="{Binding Titles.Title1}" />

Hopefully a way more similar to :
<TextBlock Text="{Binding Ref:Titles.Title1}" />
Please correct me.

Part3:

namespace Xz.Infrastructure
{
    public class Titles
    {
        public static string Title1 = "Title1";
        public static string RgnContent = "RgnContent";
    }
}

Our Infrastructure isn't defined as a module, it's just an assembly.

Developer
Oct 10, 2012 at 3:57 PM
Edited Oct 10, 2012 at 3:57 PM

Hi,

I believe you could try something like this:

<TextBlock Text="{x:Static Ref:Titles.Title1}"></TextBlock>

As you may find, a similar approach is used in the StockTrader RI for defining the region names in its RegionNames class, inside the Infrastructure project.

I hope you find this handy,

Agustin Adami
http://blogs.southworks.net/aadami

Oct 11, 2012 at 8:02 AM

Yes,

That's right, I found that after I asked,

Thanks...