<Page
    x:Class="StockPortfolio.HistoricalTradeMainPage"
    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"
    mc:Ignorable="d"
    x:Name="pageRoot"     xmlns:c1fg="using:C1.Xaml.FlexGrid"
    xmlns:c1tile="using:C1.Xaml.Tile"
    xmlns:c1="using:C1.Xaml"
    xmlns:local="using:StockPortfolio"
    RequestedTheme="Light"
   >

    <Grid Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="56"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="100"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
       
        <local:HeaderPage Visibility="Visible"/>
        <Border Grid.Row="1" Background="#FFEDEDED">
            <Grid>
                <StackPanel Orientation="Horizontal">
                    <Path Height="32" Width="32" Margin="20 0 0 0" VerticalAlignment="Center" Data="M2.3626099,4.055696 C2.7749274,4.0572982 3.1461689,4.1598258 3.3802159,4.4126482 C4.0277925,5.1121783 4.0129013,5.4725938 3.9938798,6.391921 L3.9938798,36.091122 L4.2066398,36.043842 C8.0528564,35.221184 14.373047,35.085327 22.5,37.95092 C30.626953,35.085327 36.947144,35.221184 40.793362,36.043842 L41.006123,36.091122 L41.006123,6.3919196 C40.987099,5.4725938 40.972206,5.1121783 41.619785,4.4126482 C42.45195,3.5137229 45.018528,4.5148258 44.999065,5.1968217 L44.999065,37.952763 L44.999985,37.955627 L44.999985,39.126827 C45.005363,39.975769 43.556091,40.693535 42.531628,40.32386 C40.426746,39.564323 35.022133,37.814011 22.5,42 C9.9778709,37.814011 4.573256,39.564323 2.4683735,40.32386 C1.4439085,40.693535 -0.0053622052,39.975769 1.4919346E-05,39.126827 L1.4919346E-05,37.955627 L0.00093357591,37.952766 L0.00093357591,5.1968217 C-0.013054229,4.7066374 1.3089093,4.0516014 2.3626099,4.055696 z M33.422558,0.0009542405 C35.24612,0.016040623 36.837742,0.20785359 37.832417,0.42234066 L38,0.4603602 L38,33.387119 L37.892441,33.362915 C34.442463,32.636154 29.71471,32.96352 24.230867,34.611851 L23.999994,34.682953 L23.999994,2.1520827 L24.061659,2.1114509 C26.699711,0.44157395 30.383282,-0.024189515 33.422558,0.0009542405 z M11.577444,0.0009542405 C14.616719,-0.02418978 18.300289,0.44157371 20.938343,2.1114509 L20.999994,2.1520741 L20.999994,34.682949 L20.769135,34.611855 C15.285291,32.96352 10.557538,32.636154 7.1075583,33.362915 L6.9999981,33.387119 L6.9999981,0.46036017 L7.1675854,0.42233998 C8.1622581,0.20785329 9.7538776,0.016040336 11.577444,0.0009542405 z"  Fill="#FF76AF3C" Stretch="Uniform"  />
                    <TextBlock x:Name="pageTitle" Text="Historical Trade" VerticalAlignment="Center" Margin="10 0 0 0" FontFamily="Segoe WP" FontWeight="Light" FontSize="22" Foreground="#FF76AF3C"/>
               </StackPanel>
            </Grid>
        </Border>
        <Grid Grid.Row="2" Margin="10 0 0 0">
            <Grid.RowDefinitions>
                <RowDefinition Height="50"/>
                <RowDefinition Height="50"/>               
            </Grid.RowDefinitions>
            <StackPanel Margin="10,0,0,0" Orientation="Horizontal">
                <Rectangle Width="30" Height="30" VerticalAlignment="Center" Fill="#d60000"/>
                <TextBlock VerticalAlignment="Center" FontSize="14" Margin="10,0,0,0" Text="Holdings"/>
                <TextBlock VerticalAlignment="Center" FontSize="14" Margin="10,0,0,0" x:Name="holding"/>
            </StackPanel>
            <StackPanel Margin="10,0,0,0"  Grid.Row="1" Orientation="Horizontal">
                <Rectangle Width="30" Height="30" VerticalAlignment="Center" Fill="#f8e000"/>
                <TextBlock VerticalAlignment="Center" FontSize="14" Margin="10,0,0,0" Text="Sold out"/>
                <TextBlock VerticalAlignment="Center" FontSize="14" Margin="10,0,0,0" x:Name="holded"/>
            </StackPanel>
        </Grid>
        <Pivot Grid.Row="3" Name="HistoricalTradeList" Margin="5" Padding="0" >
            <Pivot.HeaderTemplate>
                <DataTemplate>
                    <Grid Background="{Binding HeaderBrush}">
                        <TextBlock Text="{Binding StockSymbol}" FontSize="22" Margin="5"/>
                    </Grid>
                  
                </DataTemplate>
            </Pivot.HeaderTemplate>
            <Pivot.ItemTemplate>
                <DataTemplate>
                    <c1fg:C1FlexGrid Margin="-15" ItemsSource="{Binding HistoricalStocks}"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch"                           
                                         HeadersVisibility="Column"
                                         AutoGenerateColumns="False"
                                         HorizontalScrollBarVisibility="Disabled"
                                         SelectionMode="Row" 
                                         GridLinesVisibility="None"      
                                         
                                         AlternatingRowBackground="DarkGray"
                                         HeaderGridLinesBrush="#666666" >

                        <c1fg:C1FlexGrid.Columns>
                            <c1fg:Column Header="Price" Binding="{Binding Stock.LastTrade}" Width="40"/>
                            <!--<c1fg:Column Header="LastTradeDate" Binding="{Binding CurrentStockQuote.LastTradeDate}" Width="150"/>-->
                            <c1fg:Column  Header="Gain/Gain%"  Width="110">
                                <c1fg:Column.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal" >
                                            <FontIcon Glyph="{Binding Stock.Change, Converter={StaticResource doubleToGlyph}}" Foreground="{Binding Stock.Change, Converter={StaticResource doubleToBrush}}"/>
                                            <TextBlock Margin="3,0,0,0" Foreground="{Binding Stock.Change, Converter={StaticResource doubleToBrush}}" HorizontalAlignment="Center" VerticalAlignment="Center">
                                   <Run Text="{Binding Stock.Change}"/>
                                   <Run Text="("/>
                                   <Run Text="{Binding Stock.PercentChange}"/>
                                    <Run Text=")"/>
                                            </TextBlock>
                                        </StackPanel>

                                    </DataTemplate>
                                </c1fg:Column.CellTemplate>
                            </c1fg:Column>

                            <c1fg:Column Header="TradeTime" Binding="{Binding TradeTime,Converter={StaticResource DateTimeToStringConverter}}" Width="70"/>
                            <c1fg:Column Header="Count"  Width="50">
                                <c1fg:Column.CellTemplate>
                                    <DataTemplate>
                                        <Grid >
                                            <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding TradeCount}"/>
                                        </Grid>
                                    </DataTemplate>
                                </c1fg:Column.CellTemplate>
                            </c1fg:Column>
                            <c1fg:Column Header="TradeType" Binding="{Binding TradeType}" Width="65"/>

                        </c1fg:C1FlexGrid.Columns>
                    </c1fg:C1FlexGrid>
                </DataTemplate>
            </Pivot.ItemTemplate>
        </Pivot>
        
      
    </Grid>
</Page>
