加入了特殊的風格融入XAML形式這樣簡單曖昧類型引用(我剝了下來所有不必要的標籤)X:靜態的XAML樣式屬性導致對「System.Windows.Markup」
<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>
是投擲非阻塞錯誤:
Ambiguous type reference. A type named 'StaticExtension' occurs in at least two namespaces, 'System.Windows.Markup' and 'System.Windows.Markup'.
問題出在屬性Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
。如果我刪除該屬性,則錯誤消失。另外問題不存在了,我將項目切換到.NET 4.
我知道存在名稱空間衝突,如similar question中所示。但是如何修改XAML來防止這種情況?
- 導致錯誤的所有代碼都是由設計師工作而不是手工創建的。
- .NET 3.5(重要)
- VS 2012更新4
- 我不使用ReSharper的(正如我在一些所謂的答案發現,它已已知缺陷關於這一點)
- 類似的東西was reported to Microsoft,但要重現了VS 2012 更新2個
- 步驟:創建嚮導新項目•選擇.NET 3.5,則「WPF應用程序」•設計師開啓•粘貼XAML•重建全部•錯誤顯示
上面的代碼不會重現提到的錯誤。 – pushpraj 2014-09-28 03:42:37
@pushpraj - 對我來說確實如此。我在問題的底部添加了*步驟來重現*。我現在已經成功地測試了它們。在哪個VS和.NET版本中你嘗試過? – miroxlav 2014-09-28 11:21:00
我使用VS2013與.net 4.5,也許這就是原因。讓我試試如果我能找到VS2012某處。 – pushpraj 2014-09-28 13:25:21