1

I am new in WPF C#.

I want to use a MessageDialog, but I can't instantiate it because I can't find its namespace reference.

Please note that I can use a MessageBox.

I take a screenshot here:

enter image description here

What should I look to solve the problem?


Update I tried to use a ModalWindow as suggested by some user who deleted his answer, but I have the same problem.

enter image description here

8
  • 2
    WPF and WinForms are different, you shouldn't be using stuff from the System.Windows.Forms namespace (and not even reference the library). WPF has its own MessageBox Commented Apr 12, 2018 at 10:35
  • 1
    Also, not sure what MessageDialog is supposed to be, but it's not part of the .NET Framework. Do you mean the UWP MessageDialog class? Commented Apr 12, 2018 at 10:37
  • I see it from here. Commented Apr 12, 2018 at 10:39
  • As was said in another palce, MessageDialog is from UWP. Wich while Similar to WPF, has a totally different target Framework. The closest equivalent to the WindowsForms MessageBox in WPF is MessageBox (msdn.microsoft.com/en-us/library/ms602949.aspx) Commented Apr 12, 2018 at 10:41
  • Why not just use System.Windows.MessageBox.Show("..."); ? Commented Apr 12, 2018 at 10:44

1 Answer 1

1

MessageDialog is a UWP class, so it is only available to Windows 10 Store applications. As far as I know it does not exist in WPF.
The namespace is Windows.UI.Popups.

Sign up to request clarification or add additional context in comments.

5 Comments

You are correct, it's not part of WPF, it's only available to UWP apps. Not sure why the OP is looking for that in WinForms
OK thanks. It was what I needed to understand. However, there was no need to downvote the question, I worked to try to be clear and understandable.
@kitsune: Nobody had any idea what "MessageBox" even is. Nor why you looked for it in the Windows.Forms Namespace.
@kitsune: You had a book-example of a XY Problem (meta.stackexchange.com/questions/66377/what-is-the-xy-problem) You had a problem X (Designs were not respected). Convinced yourself Y (MessageDialog) was the only solution. And thus never explained X
If Windows.IU.Popups namespace is only there for UWP, how do I use something like this in WPF?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.