System.Windows.Markup.XamlParseException. I encountered this exception below, while trying to compile an XAML code

0

Please can someone be of help. I encountered this exception below, while trying to compile an XAML code

System.Windows.Markup.XamlParseException HResult=0x80131501 Message='Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '40' and line position '22'. Source=PresentationFramework StackTrace: at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri) at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri) at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri) at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream) at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator) at Master_Page_core.MainWindow.InitializeComponent() in C:\Users\deepa\source\repos\Master_Page_core\Master_Page_core\MainWindow.xaml:line 1

This exception was originally thrown at this call stack: [External Code]

Inner Exception 1: IOException: Cannot locate resource 'newfolder1/sidebar.jpg'.

this is the image of error occuring . Click here to see image .

this is xaml code

<Grid.Background>
  <ImageBrush ImageSource="NewFolder1/sidebar.jpg" Stretch="UniformToFill"></ImageBrush>
  </Grid.Background>

I show similar post on this error but it was not helpfull . they asked to include the folder in the project but the Folder containing images is already included in the project.

c#
xaml
asked on Stack Overflow Apr 15, 2020 by Deepak Jha • edited Apr 15, 2020 by Deepak Jha

2 Answers

0

Have you tried? <ImageBrush ImageSource="NewFolder1/sidebar.jpg" Stretch="UniformToFill" />

answered on Stack Overflow Apr 15, 2020 by ChrisBD
0

Try editing your source code from Visual Studio "View -> Properties" section.
When you will select your Grid from XAML, you will be able to go to Properties and choose the ImageBrush source from there:

enter image description here

It's good if the image file you are mentioning will be listed there. Please choose the file from the drop-down and make sure that "Build Action" for the file is set to "Resource" and "Copy to Output Directory" is set either "Copy always" or "Copy ifnewer".

answered on Stack Overflow Apr 15, 2020 by Arsen Khachaturyan

User contributions licensed under CC BY-SA 3.0