I recently started using C# and WPF for one of my projects.
Is there a quick way of getting an input from the user? I have not been able to find one for WPF projects.
I don't want have to create another window, add OK and Cancel buttons, and add event handlers for everything. I can do it, but I wanted to know a simpler way of doing it.
AFAIK, that was possible in win forms. You can get user input with just one single line of code. Can I do it in WPF as well?
If you add the Microsoft.VisualBasic dll to your application, you can use the InputBox method to get a single value from the user.
Microsoft.VisualBasic.Interaction.InputBox("Prompt here",
"Title here",
"Default data",
-1,-1);
(Put -1,-1 in for the XPos,YPos to get it centred on the screen)
If your talking about basic yes/no input then there is a wpf MessageBox that works in pretty much the same way as the winforms one - see System.Windows.MessageBox
Is that what you are thinking of?
Also, all winforms classes can still be used in WPF apps, you just need to add a reference to the appropriate assembly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With