Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4059210
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:10:44+00:00 2026-05-20T15:10:44+00:00

I found a nice solution on this webiste http://www.thesilvermethod.com/Default.aspx?Id=ModalDialogManagerAsimpleapproachtodealingwithmodaldialogsinMVVM But had to do some

  • 0

I found a nice solution on this webiste http://www.thesilvermethod.com/Default.aspx?Id=ModalDialogManagerAsimpleapproachtodealingwithmodaldialogsinMVVM

But had to do some changes to get it integrated into my code. Along the way I get some small problems mostly because there are certain parts of the code I’m not getting completely.

How I did it was to bind the ModalDialogManager to a MainWindow property of the Type IDialogViewModel. I then have a WindowsManager class that handles putting the right instance inside this property. One such is EditDialogViewModel that exposes a EditableViewModel to this DialogManager. I set the EditDialog view as a DataTemplate for this EditDialogViewModel but when I show it the new window only shows a part of it.

Here is the View:

<UserControl.Resources>

    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>

            <ResourceDictionary Source="EditDataTemplates.xaml" />

        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

</UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="7*" />
            <RowDefinition Height="2*" />
            <RowDefinition Height="1*" />
        </Grid.RowDefinitions>

        <ContentControl Content="{Binding Path=ViewModel}" />

        <TextBlock Text="{Binding Path=ViewModel.Error}" />

        <UniformGrid Grid.Row="2" Columns="2">

            <Button Command="{Binding SaveCommand}" />

            <Button Command="{Binding CancelCommand}" />

        </UniformGrid>

    </Grid>
</UserControl>

But the new Dialog window only shows the ContentControl bound to the ViewModel property of EditDialogViewModel (it holds the ViewModel being edited).

My guess is it has something to do with this code in the ModelDialogManager:

 void Show()
    {
        if (_window != null) Close();

        Window w = new Window();
        _window = w;
        w.Closing += w_Closing;
        w.Owner = GetParentWindow(this);

        w.DataContext = this.DataContext;
        w.SetBinding(Window.ContentProperty, ""); //This code here does something I don't fully understand

        w.Title = Title;
        w.Icon = Icon;
        w.Height = DialogHeight;
        w.Width = DialogWidth;
        w.ResizeMode = DialogResizeMode;
        w.ShowDialog();
    }

He is applying the binding there but I guess it’s only the first ContentControl that gets bound or something. It’s quite tricky.

Another problem is that the mouse just doesn’t work inside the Modal Dialog. I can tab into the textboxes but not click into them.

Is there a way to fix this or a better method to handle Modal Dialog boxes in WPF?

EDIT

Ok I’m going to admit it. I’m a huge idiot. This was so simple I just couldn’t see it. I had set Height and Width on the UserControl to a fixed value while I was still messing around with it being a Window. So in actuality it was showing the whole thing, there just wasn’t room. I have no idea why the mouse didn’t work at that point but now it works perfectly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:10:45+00:00Added an answer on May 20, 2026 at 3:10 pm

    Answering “a better method to handle Modal Dialog boxes in WPF?” there is a new control called Child Window in the WPF Extended Toolkit that addresses your Modal Dialog pains.

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this link http://artis.imag.fr/~Xavier.Decoret/resources/glsl-mode/ , but there isn't a lot of description around
I found several controlsets for that nice looking ribbons (DotNetBar, DivElements, ...), but all
The only nice way I've found is: import sys import os try: os.kill(int(sys.argv[1]), 0)
Found some old code, circa VS 2003. Now I have just VS 2008 (SP1)
I found this open-source library that I want to use in my Java application.
I found What are mvp and mvc and what is the difference but it
I found the ad on this site to Krypton controls ( and here's another
I found a question here about blogs on software development, but I would like
Found the following in an Oracle-based application that we're migrating (generalized) : SELECT Table1.Category1,
I found a bug in the Contains statement in Linq (not sure if it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.