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
  • 1 View
  • 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

Haven't found a solution to this problem yet, have tried some things... I have
I found a nice bit of code to add some 'normal' text links (i.e.
I found a nice script to import xml using powershell http://slash4.de/tutorials/Automatic_mediawiki_page_import_powershell_script Currently I don't
just was reading this article http://highscalability.com/blog/2010/3/23/digg-4000-performance-increase-by-sorting-in-php-rather-than.html And found this nice article http://wiki.apache.org/cassandra/DataModel I just
I'm looking for nice loading indicators for Silverlight. I found a few, but all
I've found very nice solution of retrieving images from db/blob thanks to How to
So I've looked around StackOverflow a lot and found a nice solution to my
I did do some googling and searching on this site but did not find
I've been digging the web in quest of finding nice, androidish solution for this
I know the question already has a solution (eg. this question ) but I

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.