1

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.

chuckp
  • 313
  • 1
  • 2
  • 15

1 Answers1

0

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.

Haukinger
  • 10,420
  • 2
  • 15
  • 28
  • Thank you very much for your reply! I've been able to show a WPF-based window that takes advantage of the Prism- framework, but specifically, when I attempt to declare a RegionManager as shown above, I get the error. I have spent time searching to see if there was an example of a "proper" method of integrating Prism use into a WinForms app, but I have not found any. Regards! – chuckp Mar 19 '19 at 13:29
  • For the region manager, you'll have to register the region adapter for the content control. You should find that registration in the bootstrapper somewhere. – Haukinger Mar 19 '19 at 13:32