Using WPF dll's in UWP app
Asked Answered
B

2

5

I'm writing a UWP app, and for some reason I'm unable to reference PresentationFramework.dll. It contains some WPF controls I want to use (specifically, System.Windows.Controls.DataGrid, but they aren't available under Universal Windows >> Extensions in the reference manager. Why is this, and how can I fix it?

Backplate answered 27/12, 2015 at 4:0 Comment(0)
F
19

TL;DR: You can't use WPF controls in UWP.

WPF and UWP are two totally different APIs with a different .NET framework. While WPF has access to the full .NET Framework, UWP has a much more limited API. If you want to read more on the different platforms and compilers, this msdn blog post is a good entry point.

enter image description here

You are thus unable to add any standard dlls as a reference to an UWP app. If you want to share code between WPF and UWP, you'll have to use a Portable Class Library, in which you target the platforms you need.

enter image description here

And as the XAML namespaces for WPF and UWP are different as well, you won't find many portable controls. So for UWP development you'll need to use UWP controls (equivalent to their WPF counterparts). Bonus tip: if you're looking for 3rd party controls, you can also look for 'winrt' controls as winrt was used for Windows 8/8.1, but it's the same technology.

Frenchy answered 27/12, 2015 at 9:8 Comment(4)
Could you please add a link to the Microsoft page with the overview figure?Cleland
@Cleland added a link to the .net 2015 msdn article. I think that's one of the more detailed entrypoints to a large list of info.Frenchy
XAML Islands exists now.Weismannism
XAML Islands is the reverse, it allows using uwp in wpf not wpf in uwp. The benefits of uwp are netnative, you lose this if you do the reverse.Dishrag
F
0

I know this is an old question. Not even going to research what came out when. There is a DataGrid for UWP as part of the community toolkit:

https://learn.microsoft.com/en-us/windows/communitytoolkit/controls/datagrid

It's really frustrating though, because it doesn't seem to do a few things that the WPF version does, and these are the few things I needed it do do.

Microsoft really needs to come up with a new naming conventions for its 114 different frameworks and platforms. Controls should be named DataGridWpf, DataGridUwp, etc.

It's super hard to search for examples of the UWP DataGrid control and find thousands of examples for the WPF version. Just my two cents. And for the record, it seems like there are about 5 active links to examples on the UWP version. Arrg.

/And for added fun, Telerik and DevExpress have UWP data grid controls, which they also call DataGrids.

Franni answered 28/1, 2021 at 0:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.