1

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
Community
  • 1
  • 1
miroxlav
  • 11,796
  • 5
  • 58
  • 99
  • above code does not reproduce the mentioned error. – pushpraj Sep 28 '14 at 03:42
  • @pushpraj - for me it does. I have added *steps to reproduce* at the bottom of the question. I have successfujlly tested them right now. In which VS and .NET version did you try that? – miroxlav Sep 28 '14 at 11:21
  • I am using VS2013 with .net 4.5, perhaps that is the reason. let me try if I can find VS2012 somewhere. – pushpraj Sep 28 '14 at 13:25
  • @pushpraj - first, simply start the project in .NET 3.5 (it can be selected in the wizard), maybe you will see the problem in VS2013 as well – miroxlav Sep 28 '14 at 13:53
  • nope, not reproducible in VS2013. – pushpraj Sep 28 '14 at 14:34

1 Answers1

0

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.)

miroxlav
  • 11,796
  • 5
  • 58
  • 99