Click here to Skip to main content
15,896,479 members
Articles / Desktop Programming / WPF

WPF: A Nice View BreadCrumb Manager

Rate me:
Please Sign up or sign in to vote.
4.97/5 (80 votes)
16 Mar 2010CPOL20 min read 131.7K   3K   105  
A re-usable breadcrumb control for WPF.
<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:breadCrumbControl="clr-namespace:BreadCrumbControl;assembly=BreadCrumbControl"
    xmlns:local="clr-namespace:WPFBreadCrumbSystem"
	mc:Ignorable="d"
	x:Class="WPFBreadCrumbSystem.ImageControl"
	x:Name="UserControl" 
    HorizontalAlignment="Stretch" 
    VerticalAlignment="Stretch"
	d:DesignWidth="640" d:DesignHeight="480">

    <UserControl.Resources>

        <local:IndexToVisibilityConverter x:Key="IndexToVisibilityConv"/>

        <!-- Image Control Labels -->
        <Style x:Key="imageDetailsLabel" TargetType="{x:Type Label}">
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="FontSize" Value="14" />
            <Setter Property="Foreground" Value="LightGray" />
            <Setter Property="FontFamily" Value="Impact" />
        </Style>



    </UserControl.Resources>
    
    
    <Border Margin="0" BorderThickness="4" Background="Black">
    	<Border.BorderBrush>
    		<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
    			<GradientStop Color="Black" Offset="0"/>
    			<GradientStop Color="#FF343434" Offset="1"/>
    		</LinearGradientBrush>
    	</Border.BorderBrush>
        <Grid Margin="0">

            <Grid.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="Black" Offset="0"/>
                    <GradientStop Color="#FF1E1E1E" Offset="1"/>
                </LinearGradientBrush>
            </Grid.Background>


            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="8"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            
            <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <Image Margin="5" VerticalAlignment="Center" HorizontalAlignment="Center" 
                       Source="../Images/pictures.png" Width="40" Height="40"/>
                <Label HorizontalAlignment="Left" VerticalAlignment="Center" 
                   HorizontalContentAlignment="Left" VerticalContentAlignment="Center"
                   Foreground="LightGray" FontFamily="Impact" FontSize="18.667"
                   Content="Dummy View : Simple Image Browser"/>
            </StackPanel>
         
            <Rectangle Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="4" Margin="5,0,0,0">
            	<Rectangle.Fill>
            		<LinearGradientBrush EndPoint="0.987,-0.036" StartPoint="0.136,0.078">
            			<GradientStop Offset="0.733"/>
            			<GradientStop Color="LightGray"/>
            		</LinearGradientBrush>
            	</Rectangle.Fill>
            </Rectangle>
            
            <Grid x:Name="mainGrid" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                
                
                

                <breadCrumbControl:FrictionScrollViewer Background="Transparent" Grid.Row="0"
                                                    Style="{StaticResource ScrollViewerStyle}" Margin="0">

                    <ListBox x:Name="lst" Background="Transparent" BorderThickness="0" 
                             ItemContainerStyle="{DynamicResource ListBoxItemStyle}">

                        <ListBox.Resources>
                            <Style x:Key="ListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
                                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                                <Setter Property="VerticalContentAlignment" Value="Center"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                            <ContentPresenter 
								                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
								                VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
								                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
								                Content="{TemplateBinding Content}" 
								                ContentTemplate="{TemplateBinding ContentTemplate}"/>
                                            </ControlTemplate>
                                    </Setter.Value>
                                </Setter>

                            </Style>

                        </ListBox.Resources>




                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Horizontal"/>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>

                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Vertical">
                                    <Border x:Name="bord" Background="Transparent" Margin="5">
                                        <Image Height="60" Source="{Binding Path=ImageUrl}" Margin="5"/>
                                    </Border>
                                    <Label x:Name="lbl" Content="€" FontFamily="Wingdings 3" Foreground="Transparent"
                                           Height="Auto" Margin="0,-23,0,0" VerticalContentAlignment="Top"
                                           HorizontalContentAlignment="Center"
                                           FontSize="22" HorizontalAlignment="Center" VerticalAlignment="Top"/>
                                </StackPanel>
                                
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}"  Value="True" >
                                        <Setter TargetName="bord" Property="Background" Value="LightGray" />
                                        <Setter TargetName="lbl" Property="Foreground" Value="LightGray" />
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </ListBox.ItemTemplate>

                    </ListBox>



                </breadCrumbControl:FrictionScrollViewer>
                
                <Grid  Grid.Row="1" DataContext="{Binding ElementName=lst, Path=SelectedItem}" 
                       HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10"
                       Visibility="{Binding ElementName=lst, Path=SelectedIndex, 
                                Converter={StaticResource IndexToVisibilityConv}}">
                    
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="500"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    
                    <StackPanel Orientation="Vertical" Grid.Column="0" HorizontalAlignment="Left"  
                                Margin="20,20,0,0">
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                            <Label Content="Image Name :" Style="{StaticResource imageDetailsLabel}" Width="100"/>
                            <Label Content="{Binding Path=FullFileName}" 
                                   Style="{StaticResource imageDetailsLabel}" Foreground="Orange"/>
                        </StackPanel>

                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" >
                            <Label Content="Image Size :" Style="{StaticResource imageDetailsLabel}" Width="100"/>
                            <Label Content="{Binding Path=FileSize}" 
                                   Style="{StaticResource imageDetailsLabel}" Foreground="Orange"/>
                        </StackPanel>

                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                            <Label Content="Image Date :" Style="{StaticResource imageDetailsLabel}" Width="100"/>
                            <Label Content="{Binding Path=FileDateDetails}" 
                                   Style="{StaticResource imageDetailsLabel}" Foreground="Orange"/>
                        </StackPanel>
                    
                    </StackPanel>
                    
                    
                    <Border Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center"
                            Margin="0,0,30,0" 
                             BorderBrush="LightGray" Height="Auto" Width="Auto" BorderThickness="5">
                        <Image Height="300" Source="{Binding ImageUrl}"/>
                    </Border>
                    
                </Grid>
                


            </Grid>
            
        </Grid>
    </Border>
</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
Software Developer (Senior)
United Kingdom United Kingdom
I currently hold the following qualifications (amongst others, I also studied Music Technology and Electronics, for my sins)

- MSc (Passed with distinctions), in Information Technology for E-Commerce
- BSc Hons (1st class) in Computer Science & Artificial Intelligence

Both of these at Sussex University UK.

Award(s)

I am lucky enough to have won a few awards for Zany Crazy code articles over the years

  • Microsoft C# MVP 2016
  • Codeproject MVP 2016
  • Microsoft C# MVP 2015
  • Codeproject MVP 2015
  • Microsoft C# MVP 2014
  • Codeproject MVP 2014
  • Microsoft C# MVP 2013
  • Codeproject MVP 2013
  • Microsoft C# MVP 2012
  • Codeproject MVP 2012
  • Microsoft C# MVP 2011
  • Codeproject MVP 2011
  • Microsoft C# MVP 2010
  • Codeproject MVP 2010
  • Microsoft C# MVP 2009
  • Codeproject MVP 2009
  • Microsoft C# MVP 2008
  • Codeproject MVP 2008
  • And numerous codeproject awards which you can see over at my blog

Comments and Discussions