2

I am trying to fix one issue and suddenly this:



What is wrong? It's compilable and seems to work at run-time without problems. Restarting VS doesn't help, xaml designer say "Invalid markup" all time.


Xaml:

<Window x:Class="WpfApplication1.MainWindow"
        ...
        xmlns:SystemGlobalization="clr-namespace:System.Globalization;assembly=mscorlib">
    <TextBlock Text="{Binding Test, ConverterCulture={x:Static SystemGlobalization:CultureInfo.CurrentCulture}}" />
</Window>

Compiler error:

The member "CurrentCulture" is not recognized or is not accessible.

Some more details:

  • VS 2015
  • .Net Framework 4.5
Sinatr
  • 20,892
  • 15
  • 90
  • 319
  • Please see the post: http://stackoverflow.com/questions/27477598/the-member-currentculture-is-not-recognized-or-is-not-accessible – MarPreSI May 12 '16 at 12:25
  • Works for me, no errors in VS2010 or VS2013 – Manfred Radlwimmer May 12 '16 at 12:27
  • 1
    @MartinPrediger, thanks for finding duplicate, but it doesn't have accepted solution and none of answers helps, e.g. I must target `4.5` and I am trying to switch from custom binding to xaml earlier because of [issue](http://stackoverflow.com/q/37182987/1997232). – Sinatr May 12 '16 at 12:55

1 Answers1

4

@Sinatr, CurrentCulture is a read only property. so you can use

Text="{Binding Test,ConverterCulture={x:Static SystemGlobalization:CultureInfo.DefaultThreadCurrentCulture}}"
Smirti
  • 305
  • 2
  • 12
  • 1
    I needed to set value to DefaultThreadCurrentCulture on App.cs (was null) just added : `CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CurrentCulture;` under app.cs c'tor – shmoltz Jul 26 '17 at 12:27