///////////////////////////////////////////////////////////////////////////////////////////////////// // NON-PUBLIC PROCEDURES ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Occurs before an item is selected. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">The <c>RoutedEventArgs</c> that contains data related to this event.</param> private void OnTreeListBoxItemSelecting(object sender, TreeListBoxItemEventArgs e) { if (true.Equals(this.CanBlockNames)) { var model = e.Item as TreeNodeModel; if ((model != null) && (!string.IsNullOrEmpty(model.Name))) { e.Cancel = ("ABCDE".IndexOf(model.Name[0].ToString(), StringComparison.OrdinalIgnoreCase) != -1); } } }
/// <summary> /// Occurs before the default action is executed for an item. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">The <c>TreeListBoxItemEventArgs</c> that contains the event data.</param> private void OnTreeListBoxItemDefaultActionExecuting(object sender, TreeListBoxItemEventArgs e) { var model = e.Item as CheckableTreeNodeModel; if ((model != null) && (model.IsCheckable)) { e.Cancel = true; // Toggle the checked state model.IsChecked = !model.IsChecked; } }
///////////////////////////////////////////////////////////////////////////////////////////////////// // NON-PUBLIC PROCEDURES ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Occurs before the default action is executed for an item. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">The <c>TreeListBoxItemEventArgs</c> that contains the event data.</param> private void OnTreeListBoxItemDefaultActionExecuting(object sender, TreeListBoxItemEventArgs e) { var model = e.Item as CheckableTreeNodeModel; if ((model != null) && (model.IsCheckable) && (model.Children.Count == 0)) { e.Cancel = true; // Toggle the checked state if (model.IsChecked == true) { model.IsChecked = false; } else { model.IsChecked = true; } } }