How do I work with WIndows Forms in WPF? In my WPF program I created a Windows Form class. In this Form, I placed an OK button and I went into the properties of the button and set the DialogResult to OK. Now, I am calling this Dialog (Window Form) from the MainWindow.xaml.cs:
Code
DialogResult dres;
dres =
form.ShowDialog();
if (dres != DialogResult.OK)
return;
The compiler is complaining:
SQL
Error 3'System.Nullable' does not contain a definition
for'OK'andno extension method'OK'
accepting a first argument of type
'System.Nullable' could be found (are you missing a using directive
or an assembly reference?)
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
PJ MartinsRank #2,548 · 548 reputationPosted May 26, 2010, 11:22 AM EDT
✓ Accepted answer0
Make sure that your dres is System.Windows.Forms.DialogResult and not System.Windows.Window.DialogResult
Alternatively try
if (form.ShowDialog() != DialogResult.OK) return;
PJ MartinsRank #2,548 · 548 reputationPosted May 26, 2010, 11:22 AM EDT
Alternatively try
if (form.ShowDialog() != DialogResult.OK) return;
William Thompson155 reputationPosted May 26, 2010, 11:38 AM EDT
This worked: DialogResult dres;
dres = form.ShowDialog();
if (dres != System.Windows.Forms.DialogResult.OK) return;