0

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.
  • The Project is using Unity.
LastBye
  • 1,143
  • 4
  • 19
  • 37

2 Answers2

1

You can try with this code

{Binding Source={x:Static MyNamespace:MyStaticClass.MyStaticStringField}}

So

<TextBlock Text="{Binding Source={x:Static Xz.Infrastructure:Titles.Title1}}" />
Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51
1

Since this is a static string you can simply use:

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

If you really do want this bound and supporting change notification and such, have a look at this

Community
  • 1
  • 1
Simon Brydon
  • 985
  • 8
  • 12