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 3668504
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:07:50+00:00 2026-05-19T02:07:50+00:00

In a WPF application I have to get one line of info from user

  • 0

In a WPF application I have to get one line of info from user and I wan’t to use a Modal Dialog. However there seems to be no preset dialog for this. What’s a simple and easy way to do this. I find it somwhat complicated trying to find this out with the many versions of Dialogs and such.

Already I have had to use OpenFileDialog and SaveFileDialog. What is the different between version of these like Microsoft.Win32 and System.Windows.Form ?

  • 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-19T02:07:51+00:00Added an answer on May 19, 2026 at 2:07 am

    There’s nothing special you need to do to show a modal dialog in WPF. Just add a Window to your project (let’s say the class name is MyDialog), and then do:

    var dialog = new MyDialog();
    dialog.ShowDialog();
    

    Window.ShowDialog takes care of showing the window in a modal manner.

    Example:

    public class MyDialog : Window {
        public MyDialog() {
            this.InitializeComponent();
            this.DialogResult = null;
        }
    
        public string SomeData { get; set; } // bind this to a control in XAML
        public int SomeOtherData { get; set; } // same for this
    
        // Attach this to the click event of your "OK" button
        private void OnOKButtonClicked(object sender, RoutedEventArgs e) {
            this.DialogResult = true;
            this.Close();
        }
    
        // Attach this to the click event of your "Cancel" button
        private void OnCancelButtonClicked(object sender, RoutedEventArgs e) {
            this.DialogResult = false;
            this.Close();
        }
    }
    

    In your code somewhere:

    var dialog = new MyDialog();
    // If MyDialog has properties that affect its behavior, set them here
    var result = dialog.ShowDialog();
    
    if (result == false) {
        // cancelled
    }
    else if (result == true) {
        // do something with dialog.SomeData here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have WPF Application where I have One main form and other user controls
In my wpf application I have several user controls, one of them is a
I try to get the following done: A WPF application where i have multiple
I have a WPF application that's crashing once I get it onto machines that
I was just battling with a multi-window wpf application yesterday trying to get one
I am developing wpf application in C#. I have one button on which I
I have a WPF application which has a main window composed from several custom
I have an MVVM-based WPF application that relies on Caliburn.Micro . In one view,
Any help with this one greatly appreciated... I have a WPF application, and I
I have a WPF application with two PasswordBoxes, one for the password and another

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.