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); } }
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(); } }
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); }
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); }
protected override void OnAttached() { AssociatedObject.PreviewMouseWheel += AssociatedObjectOnPreviewMouseWheel; _scrollViewer = XamlHelpers.FindChild <ScrollViewer>(AssociatedObject); }