Click here to Skip to main content
15,895,142 members
Articles / Desktop Programming / WPF

Navigating the different modules through a TreeView in Prism.

Rate me:
Please Sign up or sign in to vote.
4.38/5 (4 votes)
31 May 2012CPOL10 min read 34.4K   2.2K   20  
Describes using TreeView navigation in the standard PRISM.
<UserControl x:Class="Independent_Module.Views.View1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:prism="http://www.codeplex.com/prism"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignHeight="160" d:DesignWidth="160">

    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#FF7B97D4" />
                <GradientStop Color="#FF244C8D" Offset="1" />
            </LinearGradientBrush>
        </Grid.Background>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="0" Grid.RowSpan="1" Grid.ColumnSpan="2" Text="View 1" TextWrapping="Wrap" FontSize="16" Foreground="#FF2F3806" Margin="4"/>

        <Button Grid.Row="0" Grid.Column="1" Content="Cmd" Width="35" Margin="4" HorizontalAlignment="Right"
                prism:Click.Command="{Binding Command1}" />

        <TextBlock Grid.Row="1" Grid.ColumnSpan="2" Text="{Binding CurrentItem.Name}" TextWrapping="Wrap" FontSize="12" FontWeight="Bold" Foreground="#FF2F3806" Margin="4"/>

        <ListBox x:Name="DataItemListBox" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"
                 ItemsSource="{Binding Path=DataItemsCV}" Margin="6" >
            <ListBox.BorderBrush>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFAEB9A3"/>
                    <GradientStop Color="#FF83A985" Offset="0.375"/>
                    <GradientStop Color="#FF719778" Offset="0.379"/>
                    <GradientStop Color="#FF61846E" Offset="1"/>
                </LinearGradientBrush>
            </ListBox.BorderBrush>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Text="{Binding Path=Name}"/>
                        <TextBlock Text="{Binding Path=Description}"/>
                        <TextBlock Text="{Binding Path=Id}" FontSize="6"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>        
        </ListBox>

    </Grid>

</UserControl>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
freelancer
Poland Poland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions