且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从内容页面中的视图访问控件

更新时间:2023-12-03 09:11:28

使用实例成员引用代替静态引用:

Use an instance member reference instead of a static reference:

  1. 在您的View1类中,将public static Entry txtName;更改为 public Entry txtName;.
  2. Page1类添加新字段View1 _currentView;.
  3. SelectButton()方法的末尾,添加_currentView = view;.
  4. 最后,在OnClick_Save()中,将var s = View1.txtName.Text;更改为var s = _currentView.txtName.Text;.
  1. In your View1 class, change public static Entry txtName; to public Entry txtName;.
  2. Add a new field View1 _currentView; to the Page1 class.
  3. At the end of the SelectButton() method, add _currentView = view;.
  4. And finally, in OnClick_Save(), change var s = View1.txtName.Text; to var s = _currentView.txtName.Text;.