简体   繁体   中英

How to get data from TextBox, which located on the other page?

I have MainPaqe.cs ( MainPaqe.xaml ) and Periodic_Request.cs ( Periodic_Request.xaml ), in addition, Periodic_Request.xaml has TextBox with name TxtBlock_numRequest and Combobox with name CmbBox_lvlPriority with possible 3 options.

The problem is how get user written numbers or strings from TextBox and Combobox in the MainPaqe.cs . I need to get all this information after pressing button .

Someone has advised to use MVVM , but honestly I can`t understand it. This is why I need your help.

MVVM is an architectural design pattern which facilitates the Separation of Concerns design pattern. It is highly advantageous to make use of the MVVM pattern when developing your WPF applications although not compulsory. Implementing the MVVM pattern in your application can require a little more effort and thought, at least when first using it, than is required when using WPF the old WinForms code-behind way.

1) If you want to go down the MVVM route, take a look at the EventAggregator and Mediator\\Message Bus patterns. These allow classes to communicate with one another without them requiring direct knowledge of one another.

2) Alternatively if you are happy to continue using the WinForms route, take a look at the EventHandler<T> delegate. This will allow you to raise an event in one class which can be detected by another class .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM