Пример #1
0
        public object Convert(object value, Type targetType, object parameter, ConverterCulture culture)
        {
            try
            {
                string streamName = value.ToString();

                Stream xamlStream = null;
                Task.Run(async() =>
                {
                    xamlStream = await FileUtility.OpenApplicationStreamAsync(streamName);
                }).Wait();

                return(XamlHelpers.GenerateXamlFromText(xamlStream));
            }
            catch
            {
                return(null);
            }
        }
Пример #2
0
        private void AssociatedObjectOnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            _scrollViewer ??= XamlHelpers.FindChild <ScrollViewer>(AssociatedObject);

            if (_scrollViewer == null)
            {
                return;
            }

            e.Handled = true;

            if (e.Delta > 0)
            {
                _scrollViewer.LineUp();
            }
            if (e.Delta < 0)
            {
                _scrollViewer.LineDown();
            }
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
0
 protected override void OnAttached()
 {
     AssociatedObject.PreviewMouseWheel += AssociatedObjectOnPreviewMouseWheel;
     _scrollViewer = XamlHelpers.FindChild <ScrollViewer>(AssociatedObject);
 }