Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The component does not have a resource identified by the uri

I want to create a Generic DataGrid to use on all my Views/UserControls.

This is my structure:

Class Library called "Core":

Class called "ViewBase":

public class ViewBase : UserControl {     public ViewBase()     {     }         //Rest of Methods and Properties } 

Class Library called "Controls":

UserControl Called "GridView":

XAML:

    <vb:ViewBase x:Class="Controls.GridView"              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"               xmlns:vb="clr-namespace:Core;assembly=Core">      <Grid>         <DataGrid></DataGrid>     </Grid>      </vb:ViewBase> 

Code Behind:

using Core;  public partial class GridView : ViewBase {     public GridView ()     {         InitializeComponent();     } } 

Then is the WPF Aplication called "WPFApp":

Class called "View":

using Controls;  public class View : GridView {     public View()     {         InitializeComponent();     } } 

My whole idea is to use GridView where i need a DataGrid.

When i run the application i get this error:

"The component 'WpfApp.View' does not have a resource identified by the URI '/Controls;component/GridView.xaml'." 

What am i doing wrong?

Is this the correct approach or am i way off?

like image 893
Willem Avatar asked Oct 04 '11 10:10

Willem


1 Answers

Frustratingly, I had exactly this error and spent forever trying to work out the cause. For me, it was once working but then I made some very minor changes to the XAML of the derived control, and the compiler started giving that error message. Short solution, cutting out many hours of trying to figure it out: shut down Visual Studio and re-opened it, recompiled, problem magically went away! (This is VS2012 Pro) Just added this in case anyone reading is going round in circles trying to find a non-existent problem with their code. Might be worth trying the "IT Crowd solution" first.

like image 144
HughHughTeotl Avatar answered Oct 15 '22 20:10

HughHughTeotl