注意:我不想全局声明DataDisplay,因为每次单击按钮我都需要多个窗口实例。
代码示例:
private void applyBtn_Click(object sender, EventArgs e)
{
..
DataDisplay dd = new DataDisplay();
//This will create multiple instances of the DataDisplay screen with individual query
..
}
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
..
dd.dataGrid.Items.Refresh();
//Refresh data for each instance of DataDiaplay
..
}
答案 0 :(得分:0)
你需要使它成为一个类级别的字段,在任何方法之外,它包含你的对象的集合,例如:
private List<DataDisplay> allDisplayData = new List<DataDisplay>();
private void applyBtn_Click(object sender, EventArgs e)
{
allDisplayData.Add(new DataDisplay());
}
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
foreach (var dd in allDisplayData)
{
dd.dataGrid.Items.Refresh();
}
}