1
votes

I am attempting to integrate a (Prism 7) WPF Window into an existing WinForms app.

My window is defined as:

<Window x:Class="ESC.SV.UI.RAndDClient.Views.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:ESC.SV.UI.RAndDClient"
    xmlns:core="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:prism="http://www.codeplex.com/prism"
    xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
    prism:ViewModelLocator.AutoWireViewModel="True"
    mc:Ignorable="d"
    Title="{Binding Title}" Height="450" Width="800">
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <dxb:BarContainerControl Grid.Row="0">
        <dxb:ToolBarControl Caption="Main Toolbar"  BarItemHorizontalIndent="10">
            <dxb:BarButtonItem Content="View 1" Glyph="{dx:DXImage Image=Forward_16x16.png}" Command="{Binding ExecuteView1Command}"/>
            <dxb:BarButtonItem Content="View 2" Glyph="{dx:DXImage Image=Backward_16x16.png}" Command="{Binding ExecuteView2Command}"/>
        </dxb:ToolBarControl>
    </dxb:BarContainerControl>

    <ContentControl prism:RegionManager.RegionName="ViewsRegion" Grid.Row="1" VerticalAlignment="Top"/>

</Grid>

When I launch the WinForms app and go to show this window, I get the following error message:

Views Region Error Message

... which explains to override ConfigureRegionAdapterMappings method in the bootstrapper, but when I go to create a BootStrapper class that inherits from UnityBootstrapper, it says that this is now obsolete. I know that App is supposed to inherit from PrismApplication, but does this apply to a WinForms application as well?

Any advice on how to deal with this situation is greatly appreciated.

1

1 Answers

0
votes

I know that App is supposed to inherit from PrismApplication, but does this apply to a WinForms application as well?

Prism is a WPF-application framework (and UWP and Xamarin). It does not support WinForms. That being said, you can use parts of Prism individually, of course, even without any GUI (the event aggregator, for example, would work fine in a windows service).

What do you want to use from the prism library? Basically, for each feature, you have to look what the bootstrapper does to initialize and configure it and then adapt that initialization and configuration to your app.