Author Topic: WPF Windows in a Class Library  (Read 4187 times)

0 Members and 1 Guest are viewing this topic.

wannabe

  • Guest
WPF Windows in a Class Library
« on: August 11, 2009, 05:02:44 PM »
To load custom WPF controls in AutoCAD via the Application.ShowWindow they have to be Window derivates, right? Unfortunately in Visual Studio Express it won't allow the adding of a Window to a class library.

The simple workaround is changing the base class from UserControl to Window. But this keeps resetting itself to UserControl which ideally I am lookin to avoid. Although it only resets itself after its compiled and run, so the application does work.

Any suggestions?

I also had another question but have forgot. Thread to be updated  :-D

Draftek

  • Guest
Re: WPF Windows in a Class Library
« Reply #1 on: August 12, 2009, 08:12:41 AM »
I don't have express, but what is preventing you from making the references to the PresentationCore and PresentationFramework dll's for WPF and Windows.Forms for a window form?

sinc

  • Guest
Re: WPF Windows in a Class Library
« Reply #2 on: August 12, 2009, 12:40:45 PM »
I've used WPF controls in Windows Forms.  I don't remember all the details, since for various reasons I decided to hold off on trying to use WPF.  But I believed it involved adding references to UIAutomationProvider and WindowsFormsIntegration.  Then the WPF user controls are encapsulated ina System.Windows.Forms.Integration.ElementHost.  Much of this is pretty automatic.  Unfortunately, I can't remember the parts I did manually, but it seems like it was relatively simple stuff.

wannabe

  • Guest
Re: WPF Windows in a Class Library
« Reply #3 on: August 12, 2009, 02:59:25 PM »
Just changing the base class of a UserControl to a Window works fine. The only problem is that after a successfult compile and debug, it resets itself back to a UserControl.

This really is no big deal, I just don't like to think I'm missing a trick.

Also, in the 2010 API the Application class has a ShowModalWindow() which takes an instance of a WPF window. It's that easy.
« Last Edit: August 12, 2009, 03:03:08 PM by wannabe »