x:Static in XAML Style attribute leads to ambiguous type reference on 'System.Windows.Markup'

Adding a special style into XAML form as simple as this (I stripped down all unnecessary tags)

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Name="MainWin" Title="Main" Height="228" Width="525" WindowStyle="None">
    <Grid>
        <Button x:Name="ButtonClose" Content="r" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" HorizontalAlignment="Left" Margin="491,10,0,0" VerticalAlignment="Top" Width="24" Click="ButtonClose_Click" IsCancel="True" BorderThickness="0" Background="#00DDDDDD" Foreground="#FFEEEEEE" FontFamily="Marlett" FontSize="16" ToolTip="Close (Esc)"/>
    </Grid>
</Window>

is throwing non-blocking error:

Ambiguous type reference. A type named 'StaticExtension' occurs in at least two namespaces, 'System.Windows.Markup' and 'System.Windows.Markup'.

The problem is in attribute Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}". If I remove the attribute, the error is gone. Also the problem is gone is I switch the project to .NET 4.

I understand there is a conflict of namespaces as shown in similar question. But how exactly the XAML can be modified to prevent this?

  • All the code leading to the error was created by work in designer, not by hand.
  • .NET 3.5 (important)
  • VS 2012 Update 4
  • I'm not using ReSharper (as I found in some SO answers, it has known defect regarding this)
  • something similar was reported to Microsoft, but for VS 2012 Update 2
  • steps to reproduce: create new project • in wizard choose .NET 3.5, then "WPF Application" • designer opens • paste the XAML • rebuild all • the error is shown

Answers


Finally, I'm concluding this that it is a specific problem occurring in configuration VisualStudio 2012 + .NET 3.5 + WPF.

It is not a blocking problem, so I can live with it.

__

(If some has better asnwer, feel free to post it and I'll pottentially mark it as the accepted answer instead of this one.)


Need Your Help

Issue with Checkboxes and Javascript, PHP

php javascript jquery mysql checkbox

I am struggling with the following PHP and JavaScript codes to have 2 sets of check-boxes filtering a range of data obtained from a MySQL database.

Metro Stye App Using File as DataSource No Async

c# json asynchronous microsoft-metro

Starting on my first Metro App and I'm hating this Async crap.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.