I'm having the following exception: 'System.Windows.Markup.XamlParseException' in PresentationFramework.dll
I looked for it and have found this thread here
Apparently the CTRL+ALT+E
method and checking all the exceptions didn't solve my problem - or I used it incorrectly. I checked all the exceptions and it lead me to the InitializedComponent()
function of my MainWindow and that was it. Any ideas? I'm sending all my XAML
code: MainWindow
<Window x:Class="DPCKOU_prog3hf_pong.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DPCKOU_prog3hf_pong"
mc:Ignorable="d"
Title="PongGame" Height="406" Width="717"
Loaded="Window_Loaded"
KeyDown="Window_KeyDown"
>
<Canvas Background="{StaticResource fieldBGSP}">
<Rectangle Canvas.Left="{Binding Path=Pad.Area.X}"
Canvas.Top="{Binding Path=Pad.Area.Y}"
Width="{Binding Path=Pad.Area.Width}"
Height="{Binding Path=Pad.Area.Height}"
Fill="{StaticResource RectangleFill}"/>
<Ellipse Canvas.Left="{Binding Path=Ball.Area.X}"
Canvas.Top="{Binding Path=Ball.Area.Y}"
Width="{Binding Path=Ball.Area.Width}"
Height="{Binding Path=Ball.Area.Height}"
Fill="{StaticResource EllipseFill}"/>
</Canvas>
</Window>
and my App.xaml
:
<Application x:Class="DPCKOU_prog3hf_pong.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DPCKOU_prog3hf_pong"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
StartupUri="MainWindow.xaml">
<Application.Resources>
<SolidColorBrush x:Key="RectangleFill" Color="#FF0F4228"/>
<SolidColorBrush x:Key="EllipseFill" Color="#FF207CBB"/>
<ImageBrush x:Key="fieldBGMP" ImageSource="pack://application:,,,/texturesExport/background.png"/>
<ImageBrush x:Key="fieldBGSP" ImageSource="pack://application:,,,/texturesExport/pong_ingameSP.png"/>
</Application.Resources>
</Application>
I get the error at the lone >
sign just before Canvas
. In the editor the background image shows up just fine. No clue what could cause the issue.
I updated my code with the pack uri
method.
Are the images' build actions set to resource? Also you may try using pack uri for image sources, in this case it would be pack://application:,,,/texturesExport/background.png
Provided that you have no code in the *.xaml.cs file, the issue probably has to do with properly evaluating the ImageSource properties.
Comment out both ImageBrushes and see if that causes the exceptions to disappear.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.