<UserControl x:Class="VIZ.Package.Module.FieldTreeView"
             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:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
             xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
             xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
             xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
             xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
             xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
             xmlns:storage="clr-namespace:VIZ.Package.Storage;assembly=VIZ.Package.Storage"
             xmlns:resource="clr-namespace:VIZ.Package.Module.Resource;assembly=VIZ.Package.Module.Resource"
             xmlns:local="clr-namespace:VIZ.Package.Module"
             xmlns:domain="clr-namespace:VIZ.Package.Domain;assembly=VIZ.Package.Domain"
             d:DataContext="{d:DesignInstance Type=local:FieldTreeViewModel}" 
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <fcore:Bool2VisibilityConverter x:Key="Bool2VisibilityConverter" TrueVisibility="Visible" FalseVisibility="Visible"></fcore:Bool2VisibilityConverter>
    </UserControl.Resources>

    <Grid>
        <dxg:GridControl ItemsSource="{Binding Path=ControlObject.FieldNodes}" ShowBorder="False"
                         SelectedItem="{Binding Path=SelectedControlField,Mode=TwoWay}">
            <dxg:GridControl.Columns>
                <dxg:GridColumn FieldName="IsCustom" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="50" AllowResizing="False">
                    <dxg:GridColumn.CellTemplate>
                        <DataTemplate>
                            <Image Width="20" Height="20" VerticalAlignment="Center" HorizontalAlignment="Center"
                                   Visibility="{Binding Path=Row.IsCustom,Converter={StaticResource Bool2VisibilityConverter}}"
                                   Source="/VIZ.Package.Module.Resource;component/Icons/icon_custom_32x32.png"></Image>
                        </DataTemplate>
                    </dxg:GridColumn.CellTemplate>
                </dxg:GridColumn>
                <dxg:GridColumn Header="字段" FieldName="FieldIdentifier" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="150" AllowResizing="True"></dxg:GridColumn>
                <dxg:GridColumn Header="类型" FieldName="Type" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="100" AllowResizing="True"></dxg:GridColumn>
                <dxg:GridColumn Header="描述" FieldName="Description" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="*" AllowResizing="True"></dxg:GridColumn>
                <dxg:GridColumn Header="值" FieldName="Value" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="*" AllowResizing="True"></dxg:GridColumn>
            </dxg:GridControl.Columns>
            <dxg:GridControl.View>
                <dxg:TreeListView AllowEditing="False" ShowIndicator="False"  ScrollAnimationMode="EaseInOut" AllowScrollAnimation="True"
                                  IsColumnMenuEnabled="False"
                                  NavigationStyle="Row" ShowVerticalLines="False"
                                  ShowBandsPanel="False"
                                  ShowTotalSummary="False"
                                  ShowFixedTotalSummary="False"
                                  ShowDragDropHint="False"
                                  ShowTargetInfoInDragDropHint="false"
                                  TreeDerivationMode="ChildNodesSelector" ChildNodesPath="Items">
                </dxg:TreeListView>
            </dxg:GridControl.View>
        </dxg:GridControl>

        <dx:WaitIndicator DeferedVisibility="{Binding IsLoading}" Content="Loading..." />
    </Grid>
</UserControl>
