Click here to Skip to main content
15,891,375 members
Articles / Desktop Programming / WPF

A Versatile TreeView for WPF

Rate me:
Please Sign up or sign in to vote.
4.95/5 (107 votes)
7 Feb 2008CPOL15 min read 641.1K   18.6K   303  
A strongly typed enhancement of the regular WPF TreeView control.
<Window x:Class="Hardcodet.Wpf.Samples.AboutDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="About"
        Height="305"
        Width="455"
        WindowStartupLocation="CenterOwner"
        WindowStyle="None"
        AllowsTransparency="True"
        ShowInTaskbar="False"
        Background="#00000000">

  <Window.Resources>

  </Window.Resources>
  
  <!-- main border -->
  <Border x:Name="MainBorder"
          Hyperlink.RequestNavigate="OnNavigationRequest"
          Width="450"
          Height="300"
          BorderThickness="0"
          CornerRadius="12,12,12,12">
    <Border.Background>
      <LinearGradientBrush StartPoint="0.126,-0.197"
                           EndPoint="0.874,1.197">
        <GradientStop Offset="0"
                      Color="#FF615E5A" />
        <GradientStop Offset="1"
                      Color="#FF535353" />
        <GradientStop Offset="0.284"
                      Color="#FFE0E0E0" />
        <GradientStop Offset="0.365"
                      Color="#FFFFFFFF" />
      </LinearGradientBrush>
    </Border.Background>
    <Grid>
      <Grid.RowDefinitions>
        <RowDefinition Height="50" />
        <RowDefinition Height="100" />
        <RowDefinition Height="*" />
        <RowDefinition Height="80" />
      </Grid.RowDefinitions>
      <Border x:Name="HeaderBorder"
              Grid.Row="0"
              Background="#384F4F4F"
              BorderThickness="0"
              CornerRadius="12,12,0,0" />
      <StackPanel Grid.Row="0"
                  Orientation="Horizontal">
        <Image Source="/Images/FolderLogo.png"
               Width="48"
               Height="48"
               Margin="20,0,0,0" />
        <TextBlock x:Name="HeaderText"
                   Margin="8,0,0,0"
                   VerticalAlignment="Center"
                   FontSize="30"
                   Foreground="#FF434343"
                   Text="WPF TreeView Control">
               <TextBlock.BitmapEffect>
                  <OuterGlowBitmapEffect GlowColor="#FFFFFFFF"
                                         Opacity="0.24" />
               </TextBlock.BitmapEffect>
            </TextBlock>
      </StackPanel>


      <!-- version information etc -->
      <StackPanel Grid.Row="1"
                  Margin="30,20,0,0">
        <TextBlock Text="hardcodet.net TreeView for WPF" />
        <TextBlock>
          <TextBlock Text="Version" />
          <TextBlock x:Name="txtVersion" />
          (CPOL)
        </TextBlock>
        <TextBlock>
          <TextBlock Text="© 2008 Philipp Sumi" />
          <LineBreak />
          <Hyperlink NavigateUri="http://www.hardcodet.net?ref=WpfTreeView">http://www.hardcodet.net/</Hyperlink>
        </TextBlock>
      </StackPanel>

      <Border Grid.Row="2"
              BorderThickness="0,1,0,0"
              BorderBrush="#FFB6B3B3">
        
        <!-- license information etc -->
        <StackPanel Grid.Row="1"
                    Margin="30,15,0,0">
          <TextBlock>
            Credits for the beautiful icons I used for the sample application
            belong to Everaldo Coelho's <Hyperlink NavigateUri="http://www.everaldo.com/?ref=hardcodet.net">Crystal Clear</Hyperlink>
            and Mark James' <Hyperlink NavigateUri="http://www.famfamfam.com/lab/icons/silk/?ref=hardcodet.net">Silk Icons</Hyperlink>.
          </TextBlock>
        </StackPanel>
      </Border>


      <Border x:Name="FooterBorder"
              Grid.Row="3"
              Background="#384F4F4F"
              BorderThickness="0"
              CornerRadius="0,0,12,12">

        <TextBlock TextWrapping="Wrap"
                   Margin="30,5,120,10"
                   VerticalAlignment="Bottom">
          This library is free software; you can redistribute it and/or
          modify it under the terms of the Code Project Open License
          (CPOL) as published at <Hyperlink NavigateUri="http://www.codeproject.com/info/cpol10.aspx">The Code Project</Hyperlink>.
        </TextBlock>
        
      </Border>

      <Button x:Name="btnOk"
              Click="btnOk_Click"
              Width="80"
              Height="24"
              Grid.Row="3"
              Margin="0,0,10,10"
              HorizontalAlignment="Right"
              VerticalAlignment="Bottom"
              IsDefault="True"
              Content="OK" />
      
      

    </Grid>
  </Border>
</Window>

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
Architect I'm a gun for hire
Switzerland Switzerland
Philipp is an independent software engineer with great love for all things .NET.
He lives in Winterthur, Switzerland and his home on the web is at http://www.hardcodet.net.

Comments and Discussions