我需要创建一个没有数据库的简单清单系统。 但是,我的表单在隐藏并显示之后会继续重置为默认值。
我尝试重组代码几次,并使用this.visibility代替this.show
with(viewModel) {
showQuery("")
assertTrue(networkState.value?.status == Status.SUCCESS)
with(movies.value!!) {
assertFalse(isEmpty())
assertTrue(size == 1)
assertTrue(this[0]?.voteAverage == voteAverage)
}
}
//我的库存窗口代码
//Code for my main window
public Main()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
AddTransactionWindow AddTransWindow = new AddTransactionWindow();
AddTransWindow.Show();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Inventory OpenInventory = new Inventory();
OpenInventory.Visibility = Visibility.Visible;
this.Visibility = Visibility.Hidden;
}
}
此代码可以更改文本块中的文本,但是在将其隐藏并使其再次可见之后。文本默认为其原始值。
答案 0 :(得分:0)
将OpenInventory声明移至您的表单,如下:
public partial class Form1 : Form
{
private Inventory OpenInventory;
在表单的构造器中实例化OpenInventory:
public Form1()
{
OpenInventory = new Inventory();
从Botton_Click中删除代码。