Mike Eason
Mike Eason

Reputation: 9723

Create a class library that will work on all windows platforms

I have a Class Library Project that I would like to make use of on the Windows Phone and Silverlight Apps (Windows 8.1). Effectively turn it into a Class Libary (Portable).

My Class Library has a Window base class (inherits from System.Windows.Window), however this is not available in portable class libraries.

To make this simple:

1) Is it possible to create a universal class library that will allow me to use it on the windows desktop, as well as windows 8.1 and windows phone 8.1?

2) How can I add a class that inherits from System.Windows.Window in a portable class library? Do I need to use pre-processor directives? How would I go about referencing System.Windows?

Am I going about this in the right way? Is there a better solution?

Upvotes: 0

Views: 352

Answers (1)

Patrick Hofman
Patrick Hofman

Reputation: 157136

You can't. A PCL only allows a specific subset of the .NET framework. Depending on your configuration, this is more or less of the entire framework.

What you can't do, in any way, is including assemblies and types that are not compatible with the PCL, like in this case System.Windows.Window.

So the answer is: you can't do that. Create a new assembly for the parts that are UI based.

Upvotes: 1

Related Questions