How do I replace Windows form DialogResult in wpf?

1

I have this code:

DialogResult dr = ofd1.ShowDialog();

Moving to WPF does not work. I searched the internet and found nothing yet, that satisfies me. How do I replace in WPF?

Note: ofd1 is a OpenDialog

    
asked by anonymous 03.03.2016 / 13:58

3 answers

0

Use MessageResult

MessageBoxResult result = MessageBox.Show("Questão", "Título", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
    // Fazer algo
}
    
03.03.2016 / 14:02
0

So it worked:

Nullable<bool> result = ofd1.ShowDialog();

            if(result == true)
            {
                try
                {
                    LocalizacaoZip = ofd1.FileName;
                    nome_arquivo_zip = System.IO.Path.GetFileNameWithoutExtension(ofd1.FileName);
                }
                catch (SecurityException ex)
                {

                }
                catch(Exception ex)
                { }
            }
    
03.03.2016 / 14:33
0

How do you compare the OpenFileDialog result? The code below works perfectly for me ..

using System;
using System.Windows.Forms;
    namespace TesteWpf {
        class Program {
            [STAThread]
            static void Main(string[] args) {

                using (OpenFileDialog ofd = new OpenFileDialog()) {
                    if (ofd.ShowDialog() == DialogResult.OK) {    
                    }
                }    
            }
        }
    }
    
03.03.2016 / 14:45