c# - WPF how to access MainPage elements from Popup Page -
I am creating a WPF app that requires a numeric input from the user. I am using the navigation window and I An "Ok_Outside_Numpad" code> button is clicked, the numpad disappears and the main page is reactivated. The code is as follows: Two questions: Already a "OK" button inside How to obtain user numeric input when Thank you! Note that I'm new to WPF, not sure my view is any good any ideas are welcome! The correct approach is But before reading that article and before learning about MVVM, you can make some changes to your code. It works. Can not access the main page elements on the host page, because there is no reference to the men page on the host page. As you have thought, you can pass the menopp to the constructor of Then you can access the mainpage elements from the pop-up page. But clicking on the popup button is easy to add event handlers, because the event handler is defined in the main window, its main configuration has access to all the controls (Remember to delete the event handler set in MyNumpad.) page is created in which there is a numeric keypad, the app requires numerical input more than once. Inspired by this, I want to put a
popup inside a
frame inside the
page as follows:
& Lt; Grid name = "main display" & gt; & Lt; Popup name = "popup dialog" placement target = "{bining elementname = an input box placement =" center "> gt; stackpayel & gt; frame source =" mynumpad.xaml "/> gt; & lt; button click = "OK_Outside_Click">
private Zero OK_Outside_Click (Object Sender, RoutedEventArgs e) {popupDialog.IsOpen = Wrong; mainDisplay. IsEnabled = true;}
MyNumpad.xaml . Is it possible to click
mainDisplay and
popupDialog
Ok_Inside_Numpad button? I
MyNumpad Code> Can I pass the variable for the constructor?
gets out of MyNump ad ?
view s (NavigationWindows and MyNumpad.xaml) Can be sent to
ViewModel (or many view models). With data binding, you just set a false value to close the popup (since the popup's ison property is linked to that value). It does not matter where the control is from, because you do not have to manipulate the controls in your code.
MyNumpad (in the code, and remember to modify the MyNumpad's constructor).
Public MainWindow () {InitializeComponent (); Mimeampad numpad = new MyNumpad (this); Frame1.Nagigate (numpad); }
string strNumber; Public Manvindo () {Initialization (); MyNumpad numpad = New MyNumpad (); Numpad.button1.AddHandler (Button ClickClick Event, New Routing Documents Handler ((S, E) => Suppose User Input is a text box in the page to accept Stronmember = numpad.InputTextBox.Text; PopupDialog.IsOpen = false; MainDisplay.IsEnabled = true;}), false); Frame1.Nagigate (numpad); }
Comments
Post a Comment