예제 #1
0
        private void AssociatedObjectOnMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (sender == null)
            {
                return;
            }

            var possibleParent = XamlHelpers.FindParent <ListBoxItem>(sender as DependencyObject);

            if (possibleParent == null)
            {
                return;
            }

            var newEvent =
                new MouseButtonEventArgs(e.MouseDevice, e.Timestamp, e.ChangedButton, e.StylusDevice)
            {
                RoutedEvent = UIElement.MouseDownEvent, Source = sender
            };

            possibleParent.RaiseEvent(newEvent);
        }
예제 #2
0
        private void AssociatedObjectOnPreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (sender == null)
            {
                return;
            }

            var possibleParent = XamlHelpers.FindParent <ListBox>(sender as DependencyObject);

            if (possibleParent == null)
            {
                return;
            }

            var newEvent =
                new KeyEventArgs(e.KeyboardDevice, e.InputSource, e.Timestamp, e.Key)
            {
                RoutedEvent = UIElement.KeyDownEvent, Source = sender
            };

            e.Handled = true;

            possibleParent.RaiseEvent(newEvent);
        }