Metallic Skeleton
Metallic Skeleton

Reputation: 689

Non-Modal Window in WPF

In my WPF application, Need to show a Non-modal window. I am using MVVM Light framework. People are suggesting different libraries to do so but is there any suitable control to do that using MVVM Light or using WPF native library?

Need to keep that non-modal window always on top.

Thanks.

Upvotes: 3

Views: 3160

Answers (1)

M.B.
M.B.

Reputation: 1082

To create a non-modal window you won't have to use a framework. The WPF library has enough possibilities to create it.

The quickest solution is to create a new Xaml Window and within the properties of the Xaml Window code, you van specify the TopMost priority, and set it to true.

<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="NonModalWindow" Height="300" Width="300" TopMost="True">
    <Grid>
        <!---- Some element defined in your window ---->
    </Grid>
</Window>

Once you have created this window it is only a matter of calling it.

new NonModalWindow().Show();

And if you do want to make it into a Modal window you can use to following code.

new NonModalWindow().ShowDialog(); // wooah a contradiction in the code

Upvotes: 6

Related Questions