<UserControl x:Class="TaskIt.Modules.Tasks.Views.TreeView"
    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:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"               
    xmlns:dragDrop="clr-namespace:Telerik.Windows.Controls.DragDrop;assembly=Telerik.Windows.Controls"      
    xmlns:telerikTreeView="clr-namespace:Telerik.Windows.Controls.TreeView;assembly=Telerik.Windows.Controls.Navigation" 
    xmlns:Core="clr-namespace:TaskIt.Modules.Tasks.Core" 
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
    xmlns:CustomControls="clr-namespace:CustomControls;assembly=CustomControls" 
    mc:Ignorable="d"               
    d:DesignHeight="300" d:DesignWidth="400">

    <UserControl.Resources>
        <Core:TreeViewNodeDataTemplateSelector x:Key="TreeViewDataTemplateSelector" />
    </UserControl.Resources>

    <Border Style="{StaticResource PageContentContainerStyle}">
        <Grid>
            <telerik:RadDockPanel>
                <telerik:RadDockPanel Style="{StaticResource ToolbarContainerStyle}" telerik:RadDockPanel.Dock="Top">
                    <Rectangle Height="22"/>
                </telerik:RadDockPanel>
                <CustomControls:ClippingBorder Style="{StaticResource PageContentInnerContainerStyle}" Padding="0,8,8,8" telerik:RadDockPanel.Dock="Bottom">
                    <telerikNavigation:RadTreeView x:Name="tvwTree" ItemsSource="{Binding TreeViewData, Mode=TwoWay}" ItemTemplateSelector="{StaticResource TreeViewDataTemplateSelector}"
                    SelectedItem="{Binding SelectedItem, Mode=TwoWay}" dragDrop:RadDragAndDropManager.AllowDrop="True">
                        <telerikNavigation:RadTreeView.ItemContainerStyle>
                            <Style TargetType="telerikNavigation:RadTreeViewItem">
                                <Setter Property="dragDrop:RadDragAndDropManager.AllowDrop" Value="True" />
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                                <Setter Property="VerticalContentAlignment" Value="Center"/>
                                <Setter Property="CheckState" Value="Off"/>
                                <Setter Property="BorderThickness" Value="1"/>
                                <Setter Property="Padding" Value="1 0 5 0"/>
                                <Setter Property="IsDropAllowed" Value="True"/>
                                <Setter Property="ItemsOptionListType" Value="Default"/>
                                <Setter Property="IsEnabled" Value="True"/>
                                <Setter Property="MinHeight" Value="24"/>
                                <Setter Property="Template" Value="{StaticResource TreeViewItemDefaultTemplate}"/>
                                <Setter Property="ItemsPanel">
                                    <Setter.Value>
                                        <ItemsPanelTemplate>
                                            <telerikTreeView:TreeViewPanel VerticalAlignment="Bottom"/>
                                        </ItemsPanelTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </telerikNavigation:RadTreeView.ItemContainerStyle>
                        <telerikNavigation:RadContextMenu.ContextMenu >
                            <telerikNavigation:RadContextMenu x:Name="cmTreeView" IsOpen="{Binding IsContextMenuAvailable, Mode=TwoWay}" Opened="TreeViewContextMenuOpened">
                                <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandNew}" Icon="{Binding IconNew}" Command="{Binding NewCommand}" Visibility="{Binding IsNewContextItemAvailable, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                                <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandEdit}" Icon="{Binding IconEdit}" Command="{Binding EditCommand}" Visibility="{Binding IsEditContextItemAvailable, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                                <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandDelete}" Icon="{Binding IconDelete}" Command="{Binding DeleteTreeViewItemCommand}" Visibility="{Binding IsDeleteContextItemAvailable, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                            </telerikNavigation:RadContextMenu>
                        </telerikNavigation:RadContextMenu.ContextMenu>
                    </telerikNavigation:RadTreeView>
                </CustomControls:ClippingBorder>
            </telerik:RadDockPanel>
        </Grid>
    </Border>

</UserControl>
