"Invalid markup" in Xaml design visual studio 2015

I have a project that has several UI culture references, for example:

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sysglb="clr-namespace:System.Globalization;assembly=mscorlib"
    xmlns:local="clr-namespace:WpfApplication1"
    mc:Ignorable="d"
    Title="MainWindow" Height="350" Width="525">
<Grid>
    <StackPanel Orientation="Horizontal" Grid.Column="1">
        <TextBlock Text="{Binding MyData, StringFormat={}{0:C2}, ConverterCulture={x:Static sysglb:CultureInfo.CurrentUICulture}}"  />
    </StackPanel>
</Grid>

      

In code, I have a simple implementation:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        DataContext = this;
        MyData = 10;
    }

    public int MyData { get; set; }
}

      

In App_Startup, I initialized CurrentUICulture:

Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");

      

When I open any such interface in the designer, I get "Invalid Markup" with the error:

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

      

Any idea why this basic use case won't work in Xaml design for Visual Studio 2015 RC? I tried the options mentioned in an earlier post, but that doesn't work ( Invalid 2012 XAML Designer Markup)

Previously, when loading the designer, we could see the controls and UI without issue in Visual Studio 2010, 2012 and 2013. We decided to try Visual Studio 2015 RC, but it looks like this is broken now.

+3


source to share


1 answer


In addition to my comment that changing the target structure to .NET Framework 4.6 solves the problem, I think this is a bug in VS2015 VSAM-XAML editor, something to do with changes in CultureInfo.CurrentUICulture Property is now read and written.

As a work, I changed the app launch to

CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-GB");

      



and the XAML is

<TextBlock Text="{Binding MyData, StringFormat={}{0:C2}, ConverterCulture={x:Static sysglb:CultureInfo.DefaultThreadCurrentUICulture}}"/>

      

and seems to like it.

+1


source







All Articles