コード例 #1
0
 /// <summary>
 /// Select item
 /// </summary>
 /// <param name="item">Undo item</param>
 internal void Select(UndoItem item)
 {
     int itemIndex = Items.IndexOf(this.ItemContainerGenerator.ItemFromContainer(item));
     for (int i = 0; i < Items.Count; i++)
     {
         UndoItem undoItem = this.ItemContainerGenerator.ContainerFromItem(Items[i]) as UndoItem;
         if (i > itemIndex) undoItem.IsSelected = false;
         else undoItem.IsSelected = true;
     }
     hintTextBlock.Text = HintText + " " + (itemIndex + 1) + " Action";
     if (itemIndex > 0) hintTextBlock.Text += "s";
 }
コード例 #2
0
 /// <summary>
 /// Creates or identifies the element that is used to display the given item.
 /// </summary>
 /// <returns>The element that is used to display the given item.</returns>
 protected override DependencyObject GetContainerForItemOverride()
 {
     UndoItem item = new UndoItem();
     this.AddLogicalChild(item);
     return item;
 }
コード例 #3
0
 /// <summary>
 /// Click on item
 /// </summary>
 /// <param name="item">Undo item</param>
 internal void ItemClick(UndoItem item)
 {
     if (Command != null)
     {
         ICommand command = Command;
         if (command != null)
         {
             object commandParameter = this.ItemContainerGenerator.ItemFromContainer(item);
             IInputElement commandTarget = CommandTarget;
             RoutedCommand routedCommand = command as RoutedCommand;
             if (routedCommand != null)
             {
                 if (commandTarget == null)
                 {
                     commandTarget = this as IInputElement;
                 }
                 if (routedCommand.CanExecute(commandParameter, commandTarget))
                 {
                     routedCommand.Execute(commandParameter, commandTarget);
                 }
             }
             else if (command.CanExecute(commandParameter))
             {
                 command.Execute(commandParameter);
             }
         }
     }
     IsOpen = false;
 }