<?xml version="1.0" encoding="utf-8"?>
<UserControl x:Class="InvExplorer.AllPortfoliosView" mc:Ignorable="d" d:DesignHeight="500" d:DesignWidth="600" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:InvExplorer">

  <Grid x:Name="LayoutRoot">

    <!-- portfolios -->
    <Grid>
      <Grid.RowDefinitions>
        <RowDefinition Height="auto" />
        <RowDefinition />
      </Grid.RowDefinitions>

      <!-- title -->
      <Border Padding="4 12">
        <TextBlock Text="all portfolios" Style="{StaticResource _stTitle}" />
      </Border>

      <!-- commands -->
      <Border Background="Black" HorizontalAlignment="Right">
        <StackPanel Orientation="Horizontal">
          <TextBlock Text="+/-" Style="{StaticResource _stTitle}" />
          <TextBox Name="_txtAddPortfolio" Style="{StaticResource _stAddBox}" />
          <HyperlinkButton Content="add" Command="{Binding AddPortfolioCommand}" CommandParameter="{Binding Text, ElementName=_txtAddPortfolio}" />
          <HyperlinkButton Content="copy" Command="{Binding CopyPortfolioCommand}" CommandParameter="{Binding Text, ElementName=_txtAddPortfolio}" />
          <HyperlinkButton Content="remove selected" Command="{Binding RemovePortfolioCommand}" CommandParameter="{Binding SelectedItems, ElementName=_fgPortfolios}" />
        </StackPanel>
      </Border>

      <!-- grid -->
      <c1:C1FlexGrid Name="_fgPortfolios" Grid.Row="1" FrozenColumns="1" ItemsSource="{Binding PortfoliosView}">
        <c1:C1FlexGrid.Columns>
          <c1:Column Binding="{Binding Name, Mode=TwoWay }" Width="120" FontWeight="Bold" />
          <c1:Column Binding="{Binding CostBasis, StringFormat='#,##0.00;; '}" GroupAggregate="Sum" HeaderHorizontalAlignment="Right" />
          <c1:Column Binding="{Binding MarketValue, StringFormat='#,##0.00;; '}" Header="Mkt Value" GroupAggregate="Sum" HeaderHorizontalAlignment="Right" />
          <c1:Column Binding="{Binding Gain, StringFormat='#,##0.00;; '}" GroupAggregate="Sum" HeaderHorizontalAlignment="Right">
            <c1:Column.CellTemplate>
              <DataTemplate>
                <TextBlock Text="{Binding Gain, StringFormat='#,##0.00;; '}" Foreground="{Binding Gain, Converter={StaticResource _cvtNumberColor}}" Style="{StaticResource _tbCell}" />
              </DataTemplate>
            </c1:Column.CellTemplate>
          </c1:Column>
          <c1:Column Binding="{Binding GainPercent}" Header="%" HeaderHorizontalAlignment="Right">
            <c1:Column.CellTemplate>
              <DataTemplate>
                <TextBlock Text="{Binding GainPercent, StringFormat='#,##0.00%;; '}" Foreground="{Binding Gain, Converter={StaticResource _cvtNumberColor}}" Style="{StaticResource _tbCell}" />
              </DataTemplate>
            </c1:Column.CellTemplate>
          </c1:Column>
          <c1:Column Width="*" AllowResizing="False" />
        </c1:C1FlexGrid.Columns>
        <c1:C1FlexGrid.ColumnFooterRows>
          <c1:GroupRow />
        </c1:C1FlexGrid.ColumnFooterRows>
      </c1:C1FlexGrid>

    </Grid>
  </Grid>
</UserControl>