rtlayzell
rtlayzell

Reputation: 608

Windows 8 Custom Message Dialog without XAML

I want to create a custom MessageDialog which in terms of its interface is exactly the same as the provided MessageDialog except for one thing; The Content property acts like that of a ContentControl so I can place custom UI elements in it.

Though I cannot for the life of me figure out how the developers were able to create a class that could be 'shown' in the UI without specifying that it inherits from any sort of control in the framework.

How is it possible to create a regular class and specify its 'Template' in code?

Thank you

Upvotes: 0

Views: 615

Answers (1)

Shawn Kendrot
Shawn Kendrot

Reputation: 12465

You can accomplish this by creating a Popup, set it's Child. and then open it. You can create any XAML controls in code, so this is not an issue.

Popup popup = new Popup { Child = CreateXamlControlInCode() };
popup.IsOpen = true;

For step by step instructions, see this blog post.

Upvotes: 2

Related Questions