Building .NET Core 3 Apps with Infragistics Ultimate UI for WPF

Brian Lagunas / Monday, November 12, 2018

I have been getting a lot of questions lately asking if Infragistics Ultimate UI for WPF will support for the upcoming .NET Core 3 platform.  My answer to that question is a resounding YES! In fact, you don’t even need to wait until we have an official .NET Core 3 build of our Ultimate UI for WPF controls.  You can use them now!

Convert your WPF App to .NET Core 3

The first step in creating a .NET Core WPF app with .NET Core 3 is to install .NET Core 3.

Now it’s time to start coding!

Open up Visual Studio 2017 and create a new WPF application and name it MyFirstCore3App.

When the project loads, unload the project by right-clicking the project and selecting “Unload Project”.  Once the project is unloaded, right click the project again and select “Edit MyFirstCore3App.csproj”.

Delete everything in the csproj file by selecting all the text (CTRL+A) and deleting it. Now, let’s add the new SDK style XML markup and convert the project to a .NET Core 3 project format.

IMPORTANT: Pay special attention to line 10. Every XAML file in your app must be manually added to the csproj file as Page. Otherwise, you will get a compile error.

Now, let’s reload the project by right-clicking the project and selected “Reload Project”. Once the project loads, delete the Properties folder and the app.config file. Your project should look something like this:

Notice that the “xaml.cs” files are no longer nested underneath their parent. This is a known issue in the tooling and will be fixed by the time .NET Core 3 is ready for RTM.

Feel free to build and run the app to see your beautiful .NET Core 3 WPF application running. It’s a blank Window now, but we’ll fix that.

Adding Infragistics Ultimate UI for WPF

Now that you have your .NET Core 3 WPF app up and running, let’s add an Infragistics Ultimate UI for WPF control to it.  We’ll keep it simple and just add the xamBusyIndicator. Let’s add the Infragistics.WPF NuGet package to our project using either the  NuGet Package Manager (right-click project and select Manage NuGet Packages), or just manually type it in the csproj file (right-click project and select Edit MyFirstCore3App.csproj ). I will add it manually since it’s so easy to do it that way.

For instructions on how to use the Infragistics local or licensed NuGet feed read the NuGet Feeds topic.

Now, let’s update our MainWindow.xaml to add an instance of the xamBusyIndicator control. That’s pretty straight forward. Add a namespace of “xmlns:ig="http://schemas.infragistics.com/xaml” and then define the control as follows.

You’ll notice right away that you have no designer support, and you’ll have blue squiggles everywhere in your XAML file.  This is to be expected because .NET Core 3 does not have any designer support yet.

Set some properties on the xamBusyIndicator control and then hit F5 to run the app.

Now, I know what you’re thinking, “Brian, that is amazing. Infragistics already has builds of their WPF controls for .NET Core 3.” Actually, that’s no the case. We don’t have any special builds targeting .NET Core 3.  Currently, it is possible to use .NET 4.5 controls in a .NET Core 3 application.  So this means, that you can still use the existing Infragistics Ultimate UI for WPF controls in your .NET Core 3 app with no real changes.  However, there are some issues you might run into that I will discuss next.

Known Issues

Since .NET Core 3 is in a very early preview state, this means a lot of things won’t work exactly how you want them to.  While the Microsoft .NET Core team is working hard to fix these issues, you are bound to find gremlins every now and then.

The biggest and most common issue you will run into is the following build error:

Error MC1000: Unknown build error, 'Inheritance security rules violated by type: [Control Name]. Derived types must either match the security accessibility of the base type or be less accessible.

If you ever run into this error, thi smeans you will have to define the control in code-behind and add it to the visual tree at runtime.

Let’s take the xamDiagram control for example:

Add a reference to the “Infragistics.WPF.Diagram” NuGet package and then update your MainPage.xaml to look like this.

Now attempt to build the application. EXCEPTION!!!!

To get around this issue, simple ump into your code-behind (MainWindow.xaml.cs) and create the xamDiagram control in code and add it to the Grid.Children collection.  Let’s modify our XAML a bit by giving our Grid a name so we can access it in the code-behind and add some columns so we can throw in a toolbox for the diagram control too.

Now, jump to the code behind and add a new toolbox as well as the xamDiagram control.

Run the application and now it works as expected.

How about Converting a “Real” Application?

I already know what you’re thinking… “this is pretty freaking cool, but what about a real production application. You know, an app with complex views, lots of custom controls, an app that is built using Prism. You know… a real application”.  Well, it’s 100% possible. I actually converted the Infragistics WPF sample called IG Outlook to be 100% .NET Core 3.  If you’re curious what a larger app with lots of moving parts looks like running on .NET Core 3, you can get the source code to IG Outlook for .NET Core 3 here:

https://github.com/Infragistics/IgOutlook-NetCore3

Give it a try! You can search for the TODO’s to see the workarounds that I had to use in order to get various controls to work with .NET Core 3.  I’ll keep this sample up to date as bugs are fixed in .NET Core 3.

The Future of Infragistics Ultimate UI for WPF

As you have probably already guessed, Infragistics is committed to our desktop customers which include both WPF and WinForms.  We will continue to invest in these technologies and move our controls forward. We expect to ship .NET Core 3 versions of our WPF and WinForm controls as soon as .NET Core 3 is ready.  You may even see some early previews over the next few months. Keep an eye out on our blogs and YouTube channel.  If you have any questions, please don’t hesitate to contact me via email at blagunas@infragistics.com or via twitter (@brianlagunas).