I’m taking a whack at WPF and trying to learn as I go. I’d appreciate any advice offered.
I’ve got a Window that has a Page attached to it (through a Frame on the Window). When you press a button on the Page, I want a custom window to pop up to present several custom options and be displayed in a manner of my choosing (I’m thinking right now I want it to be a grid but that may change as I go on). When selected, the modal window will disappear and return to the calling method (button press from the Page) the value of the selected choice.
I don’t want the standard windows dialog box with the options of yes, no, okay, cancel, or anything like that. This is truly just a custom popup that returns a value to the caller when the user makes their selection on the popup.
Create a new
Windowsubclass, which you can layout however you like. Then in your button click event handler, display it modally usingmyModalWindow.ShowDialog();. You can then have a property on the window class which you can access after it closes in order to access result data, i.e.:If you really want to have something returned from a method, I suppose you could create your own public method on your window class which internally calls
ShowDialog()and then returns a value.