<local:DependencyCustomListView x:Class="Dependencies.DependencyExportList"
        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:properties="clr-namespace:Dependencies.Properties"
        xmlns:local="clr-namespace:Dependencies"
        xmlns:util="clr-namespace:Wpf.Util"
        mc:Ignorable="d" 
        d:DesignHeight="300" d:DesignWidth="300"
                                
        Style="{StaticResource DependencyCustomListViewStyle}"
        SearchListFilter="Name"
        CopyHandler="ExportCopyHandler"
    >
    
    <local:DependencyCustomListView.CommandBindings>
        <CommandBinding Command="local:DependencyExportList.CopyValuesCommand" Executed="ExportListCopySelectedValues"></CommandBinding>
    </local:DependencyCustomListView.CommandBindings>
    
    <local:DependencyCustomListView.Resources>
        <ContextMenu x:Key="ItemContextMenu">
            <MenuItem Header = "Copy"
                                Command="local:DependencyExportList.CopyValuesCommand"
                                InputGestureText="Ctrl+C"  
                                IsEnabled="True"/>
            <MenuItem HeaderStringFormat= "Copy {0:s}"
                                Header = "{Binding DataContext.Name, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid}}"
                                Command="{Binding Path=DataContext.CopyValue, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Grid},AncestorLevel=1 }}"
                                CommandParameter ="{Binding DataContext.Name, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid }}"
                                InputGestureText="Ctrl+Maj+C"  
                                IsEnabled="True"/>
            <MenuItem Header="Select All" 
                                Command="ApplicationCommands.SelectAll" 
                                IsEnabled="True"/>
            <Separator Height="3" Margin="-1,0,0,0"/>
            <MenuItem Header="_Undecorate C++ Functions" Height="26" InputGestureText="F10" IsCheckable="True" IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=Undecorate, Mode=TwoWay }"/>
            <Separator Height="3" Margin="-1,0,0,0"/>
            <MenuItem Header="Lookup Export function on MSDN"  
                            Command="{Binding Path=DataContext.QueryExportApi, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Grid},AncestorLevel=1 }}"
                            CommandParameter ="{Binding DataContext , RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid}}"
                            InputGestureText="Alt+Enter"  
                            IsEnabled="True" />
        </ContextMenu>
    </local:DependencyCustomListView.Resources>
   

    <local:DependencyCustomListView.View>
        <GridView AllowsColumnReorder="true">
            <GridViewColumn Header="E" Width="40" util:GridViewSort.PropertyName="Type" HeaderContainerStyle="{StaticResource LeftAlignHeader}">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <Image Width="30" Height="14" Source="{Binding IconUri}"/>
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
            <GridViewColumn Header="Ordinal" Width="140" util:GridViewSort.PropertyName="Ordinal" HeaderContainerStyle="{StaticResource LeftAlignHeader}">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Ordinal, StringFormat={}{0} (0x{0:x04}) }" TextAlignment="Right" HorizontalAlignment="Right"/>
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
            <GridViewColumn Header="Hint" Width="140" util:GridViewSort.PropertyName="Hint" HeaderContainerStyle="{StaticResource LeftAlignHeader}">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Hint, StringFormat={}{0} (0x{0:x04}), TargetNullValue='N/A' }" TextAlignment="Right" />
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
            <GridViewColumn Header="Function" Width="250" DisplayMemberBinding="{Binding Name}" util:GridViewSort.PropertyName="Name" HeaderContainerStyle="{StaticResource LeftAlignHeader}"/>
            <GridViewColumn Header="VirtualAddress" Width="250" DisplayMemberBinding="{Binding VirtualAddress}" util:GridViewSort.PropertyName="VirtualAddress" HeaderContainerStyle="{StaticResource LeftAlignHeader}"/>
            <GridViewColumn Header="Demangler" Width="250" DisplayMemberBinding="{Binding Demangler}" util:GridViewSort.PropertyName="Name" HeaderContainerStyle="{StaticResource LeftAlignHeader}"/>
        </GridView>
    </local:DependencyCustomListView.View>
</local:DependencyCustomListView>
 