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