using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using Telerik.Windows.Controls;namespace MainWindowInBackground{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { RadWindow l_hostWindow = new RadWindow() { Owner = System.Windows.Application.Current.MainWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner, Content = "Test" }; l_hostWindow.Show(); MessageBox.Show("MessageBox", "MessageBox", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); } }}I try to use the PdfViewer in an addin (using the .net managed addin framework), hosted in a winform host application. When I open a pdf file I get this exception:
at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Utils.Helper.get_Dispatcher() in c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Documents\Fixed\Core\FormatProviders\Pdf\Utils\Helper.cs:line 25
at Telerik.Windows.Documents.Fixed.FixedDocumentStreamSource.<>c__DisplayClass8.<LoadDocument>b__6() in c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Documents\Fixed\FixedDocumentViewers\Fixed\FixedDocumentStreamSource.cs:line 180
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
I suspect the helper class is using Application.Current.Dispatcher. Application.Current is null in our environment.
Is there a work around for this problem so I can use the viewer in an addin?
Thank you,
Fonger.
FrameworkElementFactory slider = new FrameworkElementFactory(typeof(RadSlider));slider.SetBinding(RadSlider.ValueProperty, new Binding(path) { Mode = BindingMode.TwoWay });slider.SetValue(RadSlider.MinimumProperty, 0);slider.SetValue(RadSlider.MaximumProperty, 100);slider.SetValue(Grid.ColumnProperty, 1);