private void CollapseAll(Expander selectedExpander) { _isManualCollapseOrExpand = true; try { // Collapse all expanders. foreach (var expander in _listBox.GetVisualDescendants().OfType <Expander>()) { expander.IsExpanded = false; expander.Focusable = true; } // Clear list box selection _listBox.SelectedItem = null; // Move focus to expander which contained the selected property selectedExpander?.Focus(); selectedExpander?.BringIntoView(); } finally { _isManualCollapseOrExpand = false; } }
private void Collapse(Expander expander) { if (expander == null) { return; } _isManualCollapseOrExpand = true; try { expander.IsExpanded = false; expander.Focusable = true; if (_listBox != null) { _listBox.SelectedItem = null; } expander.Focus(); expander.BringIntoView(); } finally { _isManualCollapseOrExpand = false; } }
private void Expander_Expanded(object sender, RoutedEventArgs e) { Expander exp = sender as Expander; exp.BringIntoView(); }