navigation:Frame.UriMapper & Accordion problem : Pls Help

Topics: Prism v2 - Silverlight 3
May 10, 2010 at 6:47 PM

Hi,

I ve a simple Xaml UI and initially included <navigation:Frame.UriMapper> to enforce navigation settimngs. Then i tried using the Accordian control on my xaml and could not succeed.

Then i noticed that both of navigation:frame and Urimapper uses the namespaace system.windows.control of System.Windows.Controls.Navigation assembly.

 The Accordian control uses the same namespace  system.windows.control but of System.Windows.Controls.Layout.Toolkit assemby. When i run the application it says the error like  'Accordian control throws exception... File not found system.windows.control etc..

Below given my xaml for your kind reference.

Please help me how to use the Accordian control along with Navigation frame & Urimapper.

 

Thanks

Devasena

 

-------------------------------------------------------

<UserControl x:Class="ACS_HTS.Shell"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
     xmlns:layoutToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
     xmlns:system="clr-namespace:System;assembly=mscorlib"
    xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
    xmlns:call="clr-namespace:Microsoft.Practices.Composite.Presentation.Regions;assembly=Microsoft.Practices.Composite.Presentation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">

    <StackPanel>
        <StackPanel.Resources>
            <Style x:Key="DemoButton" TargetType="Button">
                <Setter Property="Margin" Value="2" />
                <Setter Property="Foreground" Value="Blue" />
                <Setter Property="Content" Value="Content From Style" />
            </Style>
           
        </StackPanel.Resources>
       
        <Grid x:Name="LayoutRoot" >
           
                <Grid x:Name="grdCntry"  >

                    <Grid.RowDefinitions   >
                   
                        <RowDefinition />
                        <RowDefinition Height="50" />
                </Grid.RowDefinitions> 
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="1024"  />
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>

                <Border x:Name="HeaderBand" VerticalAlignment="Top"  Grid.Row="0" Grid.Column="0" Style="{StaticResource HeaderBand}" />
                <Border x:Name="HeaderMenus" VerticalAlignment="Top"  Grid.Row="1" Grid.Column="0" Style="{StaticResource HeaderMenu}" />   
               
            </Grid>

            <layoutToolkit:Accordion x:Name="acc" Grid.Column="0" >
                <layoutToolkit:AccordionItem Content="item 1" Header="A"  />
                <layoutToolkit:AccordionItem Content="item 2" Header="B -  long header" />
                <system:String>regular string item 3</system:String>
            </layoutToolkit:Accordion>

            <!-- Content -->
        <Border x:Name="ContentBorder"  Margin="0,20,0,0"  >
           
            <navigation:Frame x:Name="ContentFrame"  Height="Auto" HorizontalAlignment="Center">
                   
                    <navigation:Frame.UriMapper>
                    <uriMapper:UriMapper>
                        <uriMapper:UriMapping Uri="" MappedUri="/Views/Tss.xaml"/>
                        <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
                    </uriMapper:UriMapper>

                </navigation:Frame.UriMapper>

            </navigation:Frame>


        </Border>
    </Grid>
    </StackPanel>
</UserControl>
-----------------------------------

 

 

 

Developer
May 18, 2010 at 2:44 PM
Edited May 18, 2010 at 2:50 PM

Hi Devasena,

I haven’t been able to reproduce your issue.

I placed an Accordion control as well as a UriMapper in the same view, and got them working.

My xaml looks like this:

 

<UserControl x:Class="MyModuleAssembly.Views.View1"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:layoutToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
    xmlns:system="clr-namespace:System;assembly=mscorlib"
    xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">

    <Grid x:Name="LayoutRoot" Background="White">

        <layoutToolkit:Accordion x:Name="acc" Grid.Column="0" >
            <layoutToolkit:AccordionItem Content="item 1" Header="A"  />
            <layoutToolkit:AccordionItem Content="item 2" Header="B -  long header" />
            <system:String>regular string item 3</system:String>
        </layoutToolkit:Accordion>
        <Button Width="100" Height="20" Content="Button" Click="Button_Click" />

        <navigation:Frame x:Name="ContentFrame"  Height="Auto" HorizontalAlignment="Center">
                   
                    <navigation:Frame.UriMapper>
                    <uriMapper:UriMapper>
                        <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/MyModuleAssembly;component/Views/{pageName}.xaml"/>
                    </uriMapper:UriMapper>

                </navigation:Frame.UriMapper>

            </navigation:Frame>
        
    </Grid>
</UserControl>

 

and in the code behind, I am using this code:

private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
    this.ContentFrame.Navigate(new Uri("/Home", UriKind.Relative));
}

to check that Uri mappings work.

There should be no problem with using the same namespace in different assemblies. Perhaps you missing the reference to a necessary assemby.

As this problem is not strictly related to Prism, you might get a more specific answer on the Silverlight forums.

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi