2017-02-17 2 views
1

Ich versuche, eine verschachtelte Konstante in WPF verwenden, aber XAML scheint nicht geschachtelte statische Klassen zu behandeln.Zugriff auf geschachtelte statische const

namespace MyCommon.Constants 
{ 
    public static class Constants 
    { 
     public static class Formatting 
     { 
      public static class DateTime 
      { 
       public const string BritishDateToString = "dd-MM-yy"; 
      } 
     } 
    } 
} 

Import der Namespace

xmlns:constants="clr-namespace:MyCommon.Constants;assembly=MyCommon" 

die folgenden Zeilen gibt einen Fehler

<DataGridTextColumn Binding="{Binding Path=Date, StringFormat={x:Static constants:Constants.Formatting.DateTime.BritishDateTimeToString}}" Header="Date" /> 
+1

werden können BritishDateToString sein sollte statisch – Florian

+1

@Florian, const => statisch – ASh

Antwort

1

Verwenden + für

verschachtelte Klassen Zugriff auf
<DataGridTextColumn Binding="{Binding Path=Date, StringFormat={x:Static constants:Constants+Formatting+DateTime.BritishDateTimeToString}}" Header="Date" /> 
Verwandte Themen