Click here to Skip to main content
15,892,059 members
Articles / Desktop Programming / WPF

WPF TreeListView Control

Rate me:
Please Sign up or sign in to vote.
4.90/5 (71 votes)
23 Aug 2012Apache3 min read 444.8K   24.4K   203  
This article describes the usage of custom WPF TreeListView control comparing with basic TreeView
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:tree="clr-namespace:Aga.Controls.Tree;assembly=Aga.Controls">

	<Style TargetType="{x:Type tree:TreeListItem}">
		<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
	</Style>

	<Style TargetType="{x:Type tree:TreeListItem}" x:Key="TreeListItemNodeStyle">
		<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
		<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate>
					<ContentPresenter Content="{TemplateBinding ContentControl.Content}" 
										  ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" 
										  HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" 
										  VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" 
										  SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
					<ControlTemplate.Triggers>
						<Trigger Property="UIElement.IsEnabled" Value="False">
							<Setter Property="TextElement.Foreground">
								<Setter.Value>
									<DynamicResource ResourceKey="{x:Static SystemColors.GrayTextBrushKey}" />
								</Setter.Value>
							</Setter>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

</ResourceDictionary>

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 Apache License, Version 2.0


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

Comments and Discussions