Can't Derive From SharpGL.WPF.OpenGLControl

Jun 11, 2012 at 4:23 PM

I'm not sure if this is a WPF issue or a SharpGL issue, but...

When I create a class (TestGlControl) derived from SharpGL.WPF.OpenGLControl and try to instantiate an instance of my class, at run time I receive this error:

"The component 'MyTest.TestGlControl' does not have a resource identified by the URI '/SharpGL.WPF;component/openglcontrol.xaml'"

The derived class does nothing but derive from SharpGL.WPF.OpenGLControl.

Any suggestions or info would be appreciated.

Jun 11, 2012 at 8:10 PM

Try going to your App.xaml and seeing if you have a URI to openglctrl.xaml - if so, change it to testglcontrol.xaml and see if that helps!

There is a URI in the App.xaml of every WPF application which identifies the XAML to open up initially - this error you typically get when you have renamed a default class from a template project - let me know if this helps!

Jun 12, 2012 at 3:14 PM

Thanks for the reply...

This is likely my WPF ignorance coming through, but I don't see a URI in my App.xaml for openglctrl.xaml.  I also did not derive my TestGlControl class using a xaml file--I simply added the class definition to the code-behind for the Window1 (I'm prototyping for now, so I kept the default window class name).

If I try to add a class derived from UserControl and change the base class in the XAML to an OpenGLControl, I get this error:

'SharpGL.WPF.OpenGLControl' cannot be the root of a XAML file because it was defined using XAML.

From a little reading, it seems that you can't inherit XAML, so if you want to allow OpenGLControl to be useful to others as a base class for inheritance, you might need to make sure it does not include its own XAML file (ugh! gotta love WPF).

Perhaps you could put all the .cs code in an OpenGLBaseControl (with no .xaml), derive OpenGLControl from it without adding any code but including a XAML, and then allow users to derive their own contorls from the base control as well.  Just a thought.

I'd love to find out that I'm wrong about this.  If you (or someone) could create a small project in which you derive a simple class from OpenGLControl and then successfully create a new member of that class, I'd greatly appreciate knowing how it's done.