RegionManager & Page

Topics: Prism v2 - WPF 3.5
Jan 29, 2010 at 4:47 PM
Edited Jan 29, 2010 at 4:48 PM

Hi,

Still struggling to get Prism working with Pages.  My initial problem was solved here:http://compositewpf.codeplex.com/Thread/View.aspx?ThreadId=82288 (i.e I added the VisualTreeHelper code)  but I'm still having problems :-{

I'm using this code:

<UserControl x:Class="LLNet.Modules.Pages.Views.MainFrame"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cal="http://www.codeplex.com/CompositeWPF">
    <StackPanel>
        <Frame>
            <Frame.Content>
                <Page>
                    <StackPanel>
                        <TextBlock><Hyperlink NavigateUri="RegionTestPage.xaml">Testing RTP</Hyperlink></TextBlock>
                    </StackPanel>
                </Page>
            </Frame.Content>
        </Frame>
    </StackPanel>
</UserControl>

with this page:

<Page x:Class="LLNet.Modules.Pages.Views.RegionTestPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cal="http://www.codeplex.com/CompositeWPF" >
    <StackPanel>
        <ContentControl x:Name="One" cal:RegionManager.RegionName="RegionOne" ></ContentControl>
        <ContentControl x:Name="Two" cal:RegionManager.RegionName="RegionTwo" ></ContentControl>
    </StackPanel>
</Page>

First time into the page works OK.  On the second time the RegionManager.Add(region) blows up because the region name is already in the list.  Seems OK when there's only one region on the page (it's RegionTwo that errors).  Looks like it's hanging on to a reference somewhere but I haven't found it yet. Any clues?