我有選項卡控件,它有很多選項卡項目,我正在檢查數據網格項目計數,同時關閉選項卡項目。第一次它工作正常(我的意思是在第一次迭代)。關閉一個標籤項後,在第二次迭代中,sellDtg爲空。有誰知道它爲什麼會發生?我擔心這是UI問題,佈局沒有被刷新。請幫助我或顯示方向。Visual Tree Finder在搜索數據網格時返回空值
while (tc.HasItems)
{
TabItem ti = tc.SelectedItem as TabItem;
if (ti.Header == "Продажа")
{
Microsoft.Windows.Controls.DataGrid sellDtg = FindChild<Microsoft.Windows.Controls.DataGrid>(tc, "SellDataGrid");
if (sellDtg.Items.Count > 0)
{
Sell sl = new Sell();
if (Sell.basketfromSellDateListBox == false)
{
sl.ClearBasket(sellDtg);
Sell.ClearFromSellBasket((int)sellDtg.Tag);
}
}
}
if (ti != null)
tc.Items.Remove(ti);
}
在此先感謝!
是TabControl中的DataGrid – 2013-03-26 18:30:37
是的,當然在標籤項 – 2013-03-26 18:31:29