private void OnExpanderClick(object sender, RoutedEventArgs e) { bool opened = !IsExpanded; UserInitiatedExpansion |= opened; IsExpanded = opened; }