简体   繁体   English

将WPF网格更新/重置为其初始状态

[英]Update/Reset the WPF grid to its initial state

I am implementing a user interface which collects the data which will be saved into a database. 我正在实现一个用户界面,该界面收集将保存到数据库中的数据。 There are text boxes, combo boxes and status bar (including a progress bar) all in the Grid control of window. 在窗口的“网格”控件中都有文本框,组合框和状态栏(包括进度栏)。 After a bunch of information is uploaded, I want to reset/update all the controls to their initial states (eg textboxes should be empty or progress bar should be hidden until the time it is invoked to be visible etc.) or in the case of the uploading trial of an existing file only status bar should be reset to its initial state. 上传一堆信息后,我想将所有控件重置/更新为其初始状态(例如,文本框应为空或进度条应隐藏,直到调用它可见为止),或者仅现有文件的上传试用版状态栏应重置为初始状态。

(this.InitializeComponent() didn't work.) (this.InitializeComponent()无效。)

Similar topics: Resetting a winform's elements to initialized state (C#/.Net) 相似主题: 将Winform的元素重置为初始化状态(C#/。Net)

Resetting all fields to initial state in C#.NET WinForms application 在C#.NET WinForms应用程序中将所有字段重置为初始状态

If you are using MVVM you can set the DataContext of the view with a new instance of the type you are using as a ViewModel. 如果使用的是MVVM,则可以使用要用作ViewModel的类型的新实例来设置视图的DataContext。

If you are using code-behind pattern then you can just create a new instance of the UserControl. 如果使用的是代码隐藏模式,则可以仅创建UserControl的新实例。 (If the controls are currently in a Window, move them into a new UserControl and put the UserControl in the Window) (如果控件当前在窗口中,请将其移至新的UserControl并将UserControl放入窗口中)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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