I'm trying to design via wpf in window forms app project but it keep saying some assembly references are missing

성주원 5 Reputation points
2024-01-06T08:36:29.4966667+00:00

I've created window forms app project and made a toy project

I tried to design application using xaml so I added Net MAUI Content Page(XAML), but on the design page, instead of showing design page, it shows that some assembly refernces are missing. You can fix this by building to restore the NuGet cache.

Things I've tried:

  1. Checked installed nuget and reinstalled them all but shows the same.
  2. I tried deleting bin and obj files and building several times but it wouldn't be solved
  3. Tried creating new project and create XAML, didn't worked
  4. I checked SDK files, which I had 6 and 8 installed
  5. I went into nuget package option and checked all of the options in package restore section and re-tried building
Developer technologies | Windows Forms
Developer technologies | Windows Presentation Foundation
{count} vote

1 answer

Sort by: Most helpful
  1. Andy De George 95 Reputation points Microsoft Employee
    2024-02-02T22:14:12.02+00:00

    You can't mix .NET MAUI XAML and WinForms together. You can, however, use WPF XAML and WinForms. You need to edit your project file to enable both. You can do that in the project properties or by hand-editing the project file.

    What's shown first is based on the template you used to create the project. If you created a Windows Forms project, then the first thing shown is a Windows Form window. If you created a WPF project, then the thing shown is a WPF window. For each of those, there is a specific user control that allows you to show WPF content inside of a Windows Forms window, and a control that shows Windows Forms content in a WPF window.

    However, why would you want to mix them? Generally this is a scenario where someone has something complex built in one app and needs to use it in another. If you're just playing around, you should stick to one or the other for the whole project. You can find some information here: https://stackoverflow.com/questions/71374091/is-it-ok-to-enable-both-winforms-and-wpf-for-a-net-6-0-application

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.