Bryant
Bryant

Reputation: 365

WPF UserControl Not Displaying

I deleted my previous question to rephrase appropriately, since my previous post was neither helpful nor complete, imo.

For clarity: I'm using the Prism framework and abiding by a strict MVVM pattern.

Problem: When I load a UserControl, defined in some module, ModuleA, it does not display in the Shell view. However, if I load my UserControl within an ItemsControl, the elements I have defined appear, but they are all 'squished together'.

In ModuleA, I have the following UserControl:

<UserControl ...
             ...>

...

<Grid>
    ... My Content Here ...
</Grid>
</UserControl>

Now, in my project, I have defined the Shell thusly:

<Window ...
        ...>

...

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="10"/>
        <RowDefinition Height="10"/>
        <RowDefinition Height="10"/>
    </Grid.RowDefinitions>

    <Border Grid.Row="0" .../>

    <UserControl Grid.Row="1" prism:RegionManager.RegionName="ModuleARegion"/>

    <Border Grid.Row="2" .../>

</Grid>
</Window>

Now, in this scenario, everything loads, and ModuleA is recognized, but nothing appears on the screen.

However, if I change the <UserControl Grid.Row="0" prism:RegionManger .../> to <ItemsControl Grid.Row="0" prism:RegionManager .../>, I can see the content I've laid out in my ModuleA UserControl, but the content is all 'squished together'.

Does anyone have any ideas as to why this might be happening?

Upvotes: 1

Views: 1140

Answers (1)

James Lucas
James Lucas

Reputation: 2522

The default region adaptors in Prism don't support UserControl. You need to use ContentControl, ItemsControl or a Selector based control like a ComboBox to get out of the box support or write your own region adaptor.

Note: The region adaptor is used to add and remove controls from regions of a certain type of control when you interact with its regions.

Upvotes: 2

Related Questions