private void ListAdd_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (listAdd.SelectedItem == null) { return; } inSelectionChanged = true; ListBoxItem item = (ListBoxItem)listAdd.SelectedItem; IBlock block = BlockManager.NewBlock((IBlock)item.Tag); AddBlock(block); AddTimer.Start(); tbLine.Text = string.Format("{0} lines", listCode.Items.Count); Edited = true; btnDelete.IsEnabled = btnCut.IsEnabled = btnCopy.IsEnabled = btnGroup.IsEnabled = btnUngroup.IsEnabled = false; inSelectionChanged = false; }