<UserControl
    x:Class="FooEditor.UWP.Views.OutlineView"
    x:Name="OutlineWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:prism="using:Prism.Windows.Mvvm"
    xmlns:data="using:WinRTXamlToolkit.Controls.Data"
    xmlns:toolkit="using:WinRTXamlToolkit.Controls"
    xmlns:out="using:FooEditor.UWP.Models"
    prism:ViewModelLocator.AutoWireViewModel="True"
    mc:Ignorable="d" >
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <CommandBar Grid.Row="0">
            <AppBarButton Icon="Refresh" Command="{Binding AnalyzeCommand}"/>
        </CommandBar>
        <toolkit:TreeView x:Name="TreeView" Grid.Row="1" ItemsSource="{Binding Items}">
            <toolkit:TreeView.ItemTemplate>
                <DataTemplate>
                    <data:DataTemplateExtensions.Hierarchy>
                        <data:HierarchicalDataTemplate ItemsSource="{Binding Path=Items}"/>
                    </data:DataTemplateExtensions.Hierarchy>
                    <TextBlock Text="{Binding Path=Header}" RightTapped="TextBlock_RightTapped" DoubleTapped="TextBlock_DoubleTapped">
                        <FlyoutBase.AttachedFlyout>
                            <MenuFlyout>
                                <MenuFlyoutItem Text="切り取り" Command="{Binding DataContext.CutCommand,ElementName=OutlineWindow}" CommandParameter="{Binding}"/>
                                <MenuFlyoutItem Text="コピー" Command="{Binding DataContext.CopyCommand,ElementName=OutlineWindow}" CommandParameter="{Binding}"/>
                                <MenuFlyoutItem Text="子として貼り付け" Command="{Binding DataContext.PasteAsChildCommand,ElementName=OutlineWindow}" CommandParameter="{Binding}"/>
                                <MenuFlyoutSeparator/>
                                <MenuFlyoutItem Text="レベルを一つ上げる" Command="{Binding DataContext.UpLevelCommand,ElementName=OutlineWindow}" CommandParameter="{Binding}"/>
                                <MenuFlyoutItem Text="レベルを一つ下げる" Command="{Binding DataContext.DownLevelCommand,ElementName=OutlineWindow}" CommandParameter="{Binding}"/>
                            </MenuFlyout>
                        </FlyoutBase.AttachedFlyout>
                    </TextBlock>
                </DataTemplate>
            </toolkit:TreeView.ItemTemplate>
        </toolkit:TreeView>
    </Grid>
</UserControl>
