WindowsFormsHost control not displaying in Prism Region

198 Views Asked by At

I am using the pdf viewer on this link

https://archive.codeplex.com/?p=wpfpdfviewer

It is displayed properly in the window and everything works as expected. But when I added my view to region, it not displaying, other user components in my view displaying correctly, only PdfViewer not displaying.

I prepared a sample code that outlines this scenario.

Here is PdfViewer Control

<UserControl x:Class="Akbank.Treasury.Client.WPF.Controls.PdfViewer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:Akbank.Treasury.Client.WPF.Controls"
             mc:Ignorable="d"
             Name="pdfControl"
             d:DesignHeight="500"
             d:DesignWidth="900">

    <Grid>

        <WindowsFormsHost x:Name="pdfHost">
            <local:WinFormPdfHost>

            </local:WinFormPdfHost>
        </WindowsFormsHost>

    </Grid>
</UserControl>

And this is My View

 <UserControl x:Class="Treasury.Common.Views.Common.Document.DocumentView"
                 xmlns:TControls="clr-namespace:Akbank.Treasury.Client.WPF.Controls;assembly=Akbank.Treasury.Client.WPF.Controls"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008">

        <StackPanel Orientation="Vertical">

            <Label Content="some content" />
            <TextBox Text="some content" />
            <TControls:PdfViewer Width="500"
                                 Height="500"
                                 x:Name="pdfViewer" />
        </StackPanel>

    </UserControl>

This works

        Window window = new Window();
        window.Content = myView;
        window.Show();

This does not work, other components displaying but Pdf control not displaying.

        RegionManager.AddToRegion("MainRegion", myView);
0

There are 0 best solutions below