<UserControl x:Class="Silverlight_Binding_TreeView.Page"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:local="clr-namespace:Silverlight_Binding_TreeView"
		xmlns:core="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
		xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
		Width="400">
	<UserControl.Resources>
		<local:OrganizationsDataSource x:Key="OrganizationsDataSource" />
		<local:CheckStateConverter x:Key="CheckStateConverter" />

		<core:ContainerBindingCollection x:Name="TreeViewBindingsCollection">
			<core:ContainerBinding PropertyName="IsExpanded"
					Binding="{Binding Expanded, Mode=TwoWay}" />
			<core:ContainerBinding PropertyName="IsSelected"
					Binding="{Binding Selected, Mode=TwoWay}" />
			<core:ContainerBinding PropertyName="CheckState"
					Binding="{Binding Checked, Mode=TwoWay, Converter={StaticResource CheckStateConverter}}" />
		</core:ContainerBindingCollection>

		<core:HierarchicalDataTemplate x:Key="EmployeeTemplate"
				core:ContainerBinding.ContainerBindings="{StaticResource TreeViewBindingsCollection}">
			<TextBlock Text="{Binding Name}" />
		</core:HierarchicalDataTemplate>

		<core:HierarchicalDataTemplate x:Key="DepartmentTemplate" ItemsSource="{Binding Employees}"
				ItemTemplate="{StaticResource EmployeeTemplate}"
				core:ContainerBinding.ContainerBindings="{StaticResource TreeViewBindingsCollection}">
			<TextBlock Text="{Binding Name}" />
		</core:HierarchicalDataTemplate>

		<core:HierarchicalDataTemplate x:Key="OrganizationTemplate"
				core:ContainerBinding.ContainerBindings="{StaticResource TreeViewBindingsCollection}"
				ItemsSource="{Binding Departments}"
				ItemTemplate="{StaticResource DepartmentTemplate}">
			<Grid>
				<TextBlock Text="{Binding Name}" FontWeight="Bold" FontSize="14" />
			</Grid>
		</core:HierarchicalDataTemplate>

	</UserControl.Resources>
	<StackPanel>
		<telerik:RadTreeView ItemsSource="{Binding Source={StaticResource OrganizationsDataSource}}"
				ItemTemplate="{StaticResource OrganizationTemplate}" ItemsOptionListType="CheckList"
				IsOptionElementsEnabled="True">
		</telerik:RadTreeView>
	</StackPanel>
</UserControl>
