Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Cannot locate resource at Design Time (WFP Application)

$
0
0

So I created a WPF app, and I have a Ribbon Control.  The Ribbon has image resources, here is an example of the Xaml code snippet in my Ribbon Control:

<BitmapImage x:Key="new" UriSource="pack://application:,,,/Images/Ribbon/layout/new.png" />

Next, I create a simple Window and embed the control in the window like this:

<Window xmlns:WPF="clr-namespace:My_Project.WPF"  x:Class="MainWindow" WindowState="Maximized"
        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:My_Project_WPF"
        mc:Ignorable="d"
        Title="MainWindow" Height="300" Width="1000"><Grid><WPF:Ribbon HorizontalAlignment="Stretch" VerticalAlignment="Top" /></Grid></Window>

When I embed the control within the window, I get the following error in design time only (It works as expected at run time):

Cannot locate resource 'images/ribbon/layout/new.png

Also, if I clean the project, the image will display.  But then when I build the project again, the error displays again.  The following person has the same exact issue that was never solved (https://stackoverflow.com/questions/39894304/ioexception-cannot-locate-resource-at-design-time-only).

Is this a Visual Studio bug, or is there a workaround?



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>