<Page
    x:Class="Filter.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Filter"
    xmlns:c1fg="using:C1.Xaml.FlexGrid"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>
        <local:ViewModel x:Key="_viewModel" />
        <local:AmountConverter x:Key="_cvtAmount" BinSize="1000" />
    </Page.Resources>
    
    <Grid 
        DataContext="{StaticResource _viewModel}"
        Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="2*" />
        </Grid.RowDefinitions>

        <Grid>
            <TextBlock
                VerticalAlignment="Bottom" Margin="20" Foreground="Orange">
                <Run FontSize="34">ComponentOne CollectionView Demo</Run>
                <LineBreak/>
                <Run FontSize="30">filter and sort Northwind Invoices</Run>
            </TextBlock>
            <ProgressBar 
                VerticalAlignment="Bottom" 
                Background="Transparent" Foreground="Red"
                IsIndeterminate="True" ShowPaused="{Binding FinishedLoading}" />
        </Grid>

        <local:FilterControl 
            Grid.Row="1"
            Margin="20 20 20 10"
            CollectionView="{Binding Invoices}"
            LayoutMode="Automatic" >
            <local:FilterControl.Conditions>
                <local:FilterCondition PropertyName="Country" />
                <local:FilterCondition PropertyName="City" />
                <local:FilterCondition PropertyName="Salesperson" />
                <local:FilterCondition PropertyName="ExtendedPrice" Header="Amount" Converter="{StaticResource _cvtAmount}" />
            </local:FilterControl.Conditions>
        </local:FilterControl>

        <local:ChartingGrid 
            Grid.Row="2"
            AutoGenerateColumns="False"
            Margin="20 10 20 20"
            HeadersVisibility="Column"
            HeaderGridLinesBrush="#80ffffff"
            ColumnHeaderForeground="Orange"
            SelectionMode="ListBox"
            SelectionBackground="Orange"
            SelectionForeground="Black"
            CursorBackground="Orange"
            CursorForeground="Black"
            ItemsSource="{Binding Invoices}">
            <local:ChartingGrid.Columns>
                <c1fg:Column Binding="{Binding OrderDate}" Width="*" Format="d"/>
                <c1fg:Column Binding="{Binding CustomerName}" Width="2*"/>
                <c1fg:Column Binding="{Binding Country}" Width="*"/>
                <c1fg:Column Binding="{Binding City}" Width="*"/>
                <c1fg:Column Binding="{Binding Salesperson}" Width="2*"/>
                <c1fg:Column Binding="{Binding ProductName}" Width="2*"/>
                <c1fg:Column Binding="{Binding Quantity}" Width="*"/>
                <c1fg:Column Binding="{Binding ExtendedPrice}" Header="Amount" Width="*" Format="c2"/>
            </local:ChartingGrid.Columns>
        </local:ChartingGrid>
    </Grid>
</Page>
