<Page x:Class="FlexGridSamples.Financial"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="using:FlexGridSamples"
             xmlns:c1="using:C1.Xaml.FlexGrid">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Vertical" Grid.ColumnSpan="2">
            <StackPanel Orientation="Horizontal" >
                <CheckBox x:Name="_chkOwnerDrawFinancial" Content="Custom Cells" IsChecked="True" Margin="0 0 10 0" VerticalAlignment="Center" Click="_chkOwnerDrawFinancial_Click"/>
                <CheckBox x:Name="_chkAutoUpdate" Content="Auto Update" IsChecked="True" Margin="0 0 10 0" VerticalAlignment="Center" Click="_chkAutoUpdate_Click"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Margin="0 20">
                <TextBlock x:Name="_txtUpdateInterval" Text="Update Interval:" Margin="0 0 5 0" FontSize="16" VerticalAlignment="Center"/>
                <ComboBox x:Name="_cmbUpdateInterval" SelectedIndex="2" Width="100" VerticalAlignment="Center" SelectionChanged="_cmbUpdateInterval_SelectionChanged">
                    <ComboBoxItem Content="10 sec"/>
                    <ComboBoxItem Content="1 sec"/>
                    <ComboBoxItem Content="500 ms"/>
                </ComboBox>
                <TextBlock x:Name="_txtBatchSize" Text="Batch Size:" Margin="20 0 5 0" VerticalAlignment="Center" FontSize="16"/>
                <ComboBox x:Name="_cmbBatchSize" SelectedIndex="1" Width="100" Padding="5 5 0 5" VerticalAlignment="Center" SelectionChanged="_cmbBatchSize_SelectionChanged">
                    <ComboBoxItem Content="500 items"/>
                    <ComboBoxItem Content="100 items"/>
                    <ComboBoxItem Content="10 items"/>
                    <ComboBoxItem Content="1 item"/>
                </ComboBox>
                <TextBlock x:Name="_txtHeadersVisibility" Text="Headers Visibility:" Margin="20 0 5 0" VerticalAlignment="Center" FontSize="16" Visibility="Collapsed"/>
                <ComboBox x:Name="_cmbHeadersVisibility" SelectedIndex="0" Width="100" Padding="5 5 0 5" VerticalAlignment="Center" SelectionChanged="_cmbHeadersVisibility_SelectionChanged" Visibility="Collapsed">
                    <ComboBoxItem Content="All"/>
                    <ComboBoxItem Content="Column"/>
                    <ComboBoxItem Content="Row"/>
                    <ComboBoxItem Content="None"/>
                </ComboBox>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock x:Name="_txtFinancial" Text="Financial Info: " VerticalAlignment="Center"/>
                <TextBlock x:Name="_txtCompanies" Text="Companies" VerticalAlignment="Center"/>
            </StackPanel>
        </StackPanel>
        <local:SearchBox x:Name="_srchCompanies" VerticalAlignment="Top" HorizontalAlignment="Right" />
        <c1:C1FlexGrid x:Name="_flexFinancial"
                       Grid.Row="1" 
                       MinColumnWidth="10" 
                       MaxColumnWidth="300"
                       AutoGenerateColumns="False"
                       BorderThickness="1"
                       CellContentChanging="_flexFinancial_CellContentChanging">
            <c1:C1FlexGrid.Columns>
                <c1:Column x:Name="SymbolColumn" Binding="{Binding Symbol}" Width="100"/>
                    <c1:Column x:Name="NameColumn" Binding="{Binding Name}" Width="250"/>
                <c1:Column x:Name="BidColumn" Binding="{Binding Bid}" Width="150" Format="n2"/>
                <c1:Column x:Name="AskColumn" Binding="{Binding Ask}" Width="150" Format="n2"/>
                <c1:Column x:Name="LastSaleColumn" Binding="{Binding LastSale}" Width="150" Format="n2"/>
                <c1:Column x:Name="BidSizeColumn" Binding="{Binding BidSize}" Width="100" Format="n0"/>
                <c1:Column x:Name="AskSizeColumn" Binding="{Binding AskSize}" Width="100" Format="n0"/>
                <c1:Column x:Name="LastSizeColumn" Binding="{Binding LastSize}" Width="100" Format="n0"/>
                <c1:Column x:Name="VolumeColumn" Binding="{Binding Volume}" Width="100" Format="n0"/>
                <c1:Column x:Name="QuoteTimeColumn" Binding="{Binding QuoteTime}" Width="100" Format="hh:mm:ss"/>
                <c1:Column x:Name="TradeTimeColumn" Binding="{Binding TradeTime}" Width="100" Format="hh:mm:ss"/>
            </c1:C1FlexGrid.Columns>
        </c1:C1FlexGrid>
        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's window size -->
            <VisualStateGroup>
                <VisualState x:Name="WideLayout">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="540" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                    </VisualState.Setters>
                </VisualState>

                <VisualState x:Name="NarrowLayout">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="0" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="_chkOwnerDrawFinancial.FontSize" Value="10" />
                        <Setter Target="_chkOwnerDrawFinancial.Margin" Value="0 0 5 0" />
                        <Setter Target="_chkAutoUpdate.FontSize" Value="10" />
                        <Setter Target="_chkAutoUpdate.Margin" Value="0 0 5 0" />
                        <Setter Target="_txtUpdateInterval.FontSize" Value="10" />
                        <Setter Target="_cmbUpdateInterval.FontSize" Value="10" />
                        <Setter Target="_cmbUpdateInterval.Width" Value="80" />
                        <Setter Target="_txtBatchSize.FontSize" Value="10" />
                        <Setter Target="_cmbBatchSize.FontSize" Value="10" />
                        <Setter Target="_cmbBatchSize.Width" Value="80" />
                        <Setter Target="_txtHeadersVisibility.FontSize" Value="10" />
                        <Setter Target="_cmbHeadersVisibility.FontSize" Value="10" />
                        <Setter Target="_cmbHeadersVisibility.Width" Value="60" />
                        <Setter Target="_txtFinancial.FontSize" Value="10" />
                        <Setter Target="_txtCompanies.FontSize" Value="10" />
                        <Setter Target="_flexFinancial.FontSize" Value="10" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</Page>
