你好,我確實有一個問題相當多的人似乎有,但我嘗試了建議的解決方案,他們沒有工作。我有這個代碼,它總是在Window.InitializeComponent()方法中拋出一個異常(消息:「在'System.Windows.Baml2006.TypeConverterMarkupExtension提供值'拋出異常」)。 這是我的XAML代碼:System.Windows.Baml2006.TypeConverterMarkupExtension
<Window x:Class="SimpleMoving.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Name="SquareFighter" Height="392" Width="621" KeyDown="Window_KeyDown" KeyUp="Window_KeyUp" ResizeMode="CanMinimize">
<Canvas Name="MyCanvas">
<Rectangle Name="Box" Height="60" Canvas.Left="17" Stroke="Black" Canvas.Top="172" Width="30">
<Rectangle.Fill>
<ImageBrush ImageSource="pack://application:,,,/Resources/Peanut.png"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle Name="Rec1" Height="30" Canvas.Left="908" Stroke="Black" Canvas.Top="50" Width="30">
<Rectangle.Fill>
<ImageBrush ImageSource="pack://application:,,,/Resources/Rock.png"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle Height="30" Canvas.Left="908" Stroke="Black" Canvas.Top="110" Width="30">
<Rectangle.Fill>
<ImageBrush ImageSource="pack://application:,,,/Resources/Rock.png"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle Height="30" Canvas.Left="908" Stroke="Black" Canvas.Top="169" Width="30">
<Rectangle.Fill>
<ImageBrush ImageSource="pack://application:,,,/Resources/Rock.png"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle Height="30" Canvas.Left="908" Stroke="Black" Canvas.Top="229" Width="30">
<Rectangle.Fill>
<ImageBrush ImageSource="pack://application:,,,/Resources/Rock.png"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle Height="30" Canvas.Left="908" Stroke="Black" Canvas.Top="289" Width="30">
<Rectangle.Fill>
<ImageBrush ImageSource="pack://application:,,,/Resources/Rock.png"/>
</Rectangle.Fill>
</Rectangle>
<Label Name="LevelLabel" Content="Level: 1" Canvas.Left="54" Canvas.Top="10" Height="38" Width="164" FontSize="20"/>
<Label Content="Shoot the squares back using WSDA!" Canvas.Left="180" Width="290" FontSize="16"/>
</Canvas>
</Window>
我不知道該怎麼辦。我希望你能幫忙。
問題出在你的代碼隱藏之後,XAML看起來很好。 – 2014-09-12 20:05:12
但問題產生,因爲我說使用ImageBushes – Tifferan 2014-09-12 20:11:16
我沒有調整我的代碼中的圖像可能會資源文件有問題嗎? – Tifferan 2014-09-12 20:13:32