private void btnClose_Click(object sender, RoutedEventArgs e) { selectItem.IsSelected = false; PageItem itemInfo = ItemPageData.FirstOrDefault((p) => p.IsChecked); itemInfo.IsChecked = false; Button btn = sender as Button; PageItem pageInfo = btn.Tag as PageItem; if (pageInfo != null) { int index = ItemPageData.IndexOf(pageInfo); if (index == 0 && ItemPageData.Count > 1) { ItemPageData[1].CRNum = "20,0,0,20"; if (pageInfo.IsChecked) { ItemPageData[1].IsChecked = true; ItemPageData[1].BackColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF49A9FF")); } } ItemPageData.Remove(pageInfo); } if (pageInfo != itemInfo) { System.Threading.ThreadPool.QueueUserWorkItem((p) => { Thread.Sleep(100); this.Dispatcher.Invoke(new Action(() => { itemInfo.IsChecked = true; })); }); } else if (ItemPageData.Count > 0) { //ItemPageData[0].IsChecked = true; //ItemPageData[0].BackColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF49A9FF")); CheckedPageItem(ItemPageData[0]); } if (ItemPageData.Count == 0) { mainPage.Content = null; bdrMenu.Visibility = Visibility.Hidden; bgImg.Visibility = Visibility.Hidden; } }