bonjour
j'aimerais reccup les commandes generées par le scrollbar
j'ai donc une fenêtre sur lakel je colle un scrollbar et je colle le code suivant dans ma fenetre
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
            ExecutedRoutedEventHandler executedRoutedEventHandler = new ExecutedRoutedEventHandler(Window1.CommandHandler);
            CanExecuteRoutedEventHandler canExecuteRoutedEventHandler = new CanExecuteRoutedEventHandler(Window1.OnQueryScrollCommand);
 
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.LineLeftCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.LineRightCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.PageLeftCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.PageRightCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.LineUpCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.LineDownCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.PageUpCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.PageDownCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.ScrollToLeftEndCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.ScrollToRightEndCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.ScrollToEndCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.ScrollToHomeCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.ScrollToTopCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.ScrollToBottomCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.ScrollToHorizontalOffsetCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.ScrollToVerticalOffsetCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.DeferScrollToHorizontalOffsetCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
            CommandManager.RegisterClassCommandBinding(typeof(Window1), new CommandBinding(ScrollBar.DeferScrollToVerticalOffsetCommand, executedRoutedEventHandler, canExecuteRoutedEventHandler));
avec bien sur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
        private static void CommandHandler(object target, ExecutedRoutedEventArgs e)
        {
            MessageBox.Show("Command Handled!");
        }
        private static void OnQueryScrollCommand(object target, CanExecuteRoutedEventArgs args)
        {
            args.CanExecute = true;
        }
seulement je ne capture aucune commande si je rajoute
dans le xaml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
<Button Height="30" HorizontalAlignment="Left" Margin="74,0,0,10" 
                Command="ScrollBar.LineDownCommand"
                Name="button4" VerticalAlignment="Bottom" Width="111" >Button</Button>
j'ai bien l'event du scrollbar generé

a mon avis il doit y avoir kelkun qui bloque la remonté ....

pour info existe t-il un utilitaire pour espionner toutes les commandes ?