<?xml version="1.0" encoding="utf-8"?>
<UserControl x:Class="MainTestApplication.MainPage" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" FontSize="13" FontFamily="Segoe UI" 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" xmlns:c="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml" xmlns:local="clr-namespace:MainTestApplication">

  <!-- page background -->
  <UserControl.Background>
    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
      <GradientStop Color="Black" Offset="0" />
      <GradientStop Color="#FFB63636" Offset="1" />
    </LinearGradientBrush>
  </UserControl.Background>

  <!-- border around the main content -->
  <Grid Margin="0">

    <Border BorderBrush="Black" BorderThickness="1">
      <Border.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
          <GradientStop Color="#FF8CA7C5" Offset="1" />
          <GradientStop Color="#FFC6D9EF" />
        </LinearGradientBrush>
      </Border.Background>
    </Border>
    <Border BorderBrush="#FFA3AEB9" BorderThickness="1" Height="36" Margin="10,10,10,0" VerticalAlignment="Top" CornerRadius="2">
      <Border.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
          <GradientStop Color="#FFD6E3F1" Offset="1" />
          <GradientStop Color="#FFEBF3FC" />
        </LinearGradientBrush>
      </Border.Background>
      <Border BorderBrush="#FFEEF5FB" BorderThickness="1" Margin="0" CornerRadius="1">
        <StackPanel Margin="0,0,-6,-4" Orientation="Horizontal">
          <Image Source="Resources/C1.Silverlight.FlexGrid.png" Stretch="Fill" Width="32" Margin="4,0,4,4" />
          <TextBlock Margin="0,2,0,4" TextWrapping="Wrap" Text="ComponentOne FlexGrid® for Silverlight" FontSize="18.667" Foreground="#FF4976AD" Width="576" />
        </StackPanel>
      </Border>
    </Border>

    <!-- main content -->
    <Grid x:Name="LayoutRoot" Margin="10,50,10,10">

      <!-- styles used by controls in this app -->
      <Grid.Resources>
        <Style x:Key="gridStyle" TargetType="Control">
          <Setter Property="Margin" Value="8" />
          <Setter Property="BorderBrush" Value="#FFA3AEB9" />
          <Setter Property="BorderThickness" Value="1" />
        </Style>
        <Style x:Key="textBorderStyle" TargetType="Border">
          <Setter Property="Margin" Value="8" />
          <Setter Property="BorderBrush" Value="#FFA3AEB9" />
          <Setter Property="BorderThickness" Value="1" />
        </Style>
        <Style x:Key="excelBlue" TargetType="c1:C1FlexGrid">
          <Setter Property="Margin" Value="8" />
          <Setter Property="BorderBrush" Value="#FFA3AEB9" />
          <Setter Property="BorderThickness" Value="1" />
          <Setter Property="GridLinesVisibility" Value="All" />
          <Setter Property="ShowMarquee" Value="True" />
          <Setter Property="RowBackground" Value="Transparent" />
          <Setter Property="AlternatingRowBackground" Value="Transparent" />
          <Setter Property="CursorBackground" Value="Transparent" />
          <Setter Property="EditorBackground" Value="Transparent" />
          <Setter Property="TopLeftCellBackground" Value="#FFA9C4E9" />
          <Setter Property="RowHeaderBackground" Value="#FFE4ECF7" />
          <Setter Property="RowHeaderSelectedBackground" Value="#FFFFD58D" />
          <Setter Property="GridLinesBrush" Value="#FFD0D7E5" />
          <Setter Property="HeaderGridLinesBrush" Value="#FF9EB6CE" />
          <Setter Property="SelectionBackground" Value="#FFEAECF5" />
          <Setter Property="ColumnHeaderSelectedBackground">
            <Setter.Value>
              <LinearGradientBrush EndPoint="0,1">
                <GradientStop Color="#FFF8D79B" Offset="0" />
                <GradientStop Color="#FFF1C263" Offset="1" />
              </LinearGradientBrush>
            </Setter.Value>
          </Setter>
          <Setter Property="ColumnHeaderBackground">
            <Setter.Value>
              <LinearGradientBrush EndPoint="0,1">
                <GradientStop Color="#FFF6FAFB" Offset="0" />
                <GradientStop Color="#FFD5DDEA" Offset="1" />
              </LinearGradientBrush>
            </Setter.Value>
          </Setter>
        </Style>
      </Grid.Resources>

      <c:TabControl>

        <!-- Grouping -->
        <c:TabItem Header="Grouping" Foreground="#FF325989">
          <Grid>

            <Grid.RowDefinitions>
              <RowDefinition Height="auto" />
              <RowDefinition Height="*" />
              <RowDefinition Height="auto" />
            </Grid.RowDefinitions>

            <StackPanel Orientation="Horizontal" Grid.ColumnSpan="2">
              <TextBlock Text=" Find Name:" VerticalAlignment="Center" Foreground="#FF325989" />
              <TextBox x:Name="_txtFind" VerticalAlignment="Center" Margin="4,4,0,4" Width="120" TextChanged="_txtFind_TextChanged" />
              <CheckBox x:Name="_chkShowGroups" Content="Show Groups" IsChecked="true" VerticalAlignment="Center" Margin="4" Click="_chkShowGroups_Click" Foreground="#FF325989" />
              <CheckBox x:Name="_chkGroupByInitial" Content="Group Countries by Initials" IsChecked="true" VerticalAlignment="Center" Margin="4" Click="_chkGroupByInitial_Click" Foreground="#FF325989" />
              <CheckBox x:Name="_chkAllowMerging" Content="Merge Cells" IsChecked="false" VerticalAlignment="Center" Margin="4" Click="_chkAllowMerging_Click" Foreground="#FF325989" />
              <CheckBox x:Name="_chkKeepCurrentVisible" Content="Keep current visible" VerticalAlignment="Center" Margin="4" Click="_chkKeepCurrentVisible_Click" Foreground="#FF325989" />
              <CheckBox x:Name="_chkFreezePanes" Content="Freeze Panes" VerticalAlignment="Center" Margin="4" Click="_chkFreezePanes_Click" Foreground="#FF325989" />
            </StackPanel>
              
            <c1:C1FlexGrid x:Name="_flexGroup" Grid.Row="1" Style="{StaticResource gridStyle}" AllowMerging="All" MinColumnWidth="10" MaxColumnWidth="300" BorderThickness="1" />

            <Border Grid.Row="2" Style="{StaticResource textBorderStyle}" Background="#FFF4F6F9">
                <TextBlock Text="This demo shows how the C1FlexGrid supports ICollectionView data grouping. It also shows how you can use the AllowMerging property to merge adjacent cells that have the same content." TextWrapping="Wrap" Margin="10,5" Foreground="#FF4976AD" />
            </Border>
          </Grid>
        </c:TabItem>

        <!-- Unbound -->
        <c:TabItem Header="Unbound" Foreground="#FF325989">
          <Grid>
            <Grid.RowDefinitions>
              <RowDefinition Height="auto" />
              <RowDefinition Height="*" />
              <RowDefinition Height="auto" />
            </Grid.RowDefinitions>

            <c1:C1FlexGrid x:Name="_flexUnbound" Grid.Row="1" Style="{StaticResource gridStyle}" AllowMerging="All" MinColumnWidth="10" MaxColumnWidth="300" />
            
            <Border Grid.Row="2" Grid.ColumnSpan="2" Style="{StaticResource textBorderStyle}">
              <TextBlock Text="In addition to working with IEnumerable data sources, the C1FlexGrid also supports an unbound mode, where cell values are stored in the grid itself and are accessed using familiar indexing notation. This demo also shows how you can set up merged multi-cell row and column headers." TextWrapping="Wrap" Margin="10,5" Foreground="#FF4976AD" />
            </Border>
          </Grid>
        </c:TabItem>

        <!-- SelectionMode -->
        <c:TabItem Header="SelectionMode" Foreground="#FF325989">
          <Grid>

            <Grid.RowDefinitions>
              <RowDefinition Height="auto" />
              <RowDefinition Height="*" />
              <RowDefinition Height="auto" />
            </Grid.RowDefinitions>

            <StackPanel Orientation="Vertical">
              <StackPanel Orientation="Horizontal" Grid.ColumnSpan="2" Margin="8,0,0,0">
                <TextBlock Text="SelectionMode: " VerticalAlignment="Center" Foreground="#FF325989" />
                <ComboBox x:Name="_cmbSelectionMode" VerticalAlignment="Center" SelectedIndex="1" SelectionChanged="_cmbSelectionMode_SelectionChanged">
                  <ComboBoxItem Content="Cell" />
                  <ComboBoxItem Content="CellRange" />
                  <ComboBoxItem Content="Row" />
                  <ComboBoxItem Content="RowRange" />
                  <ComboBoxItem Content="ListBox" />
                </ComboBox>
                <CheckBox x:Name="_chkAllowMergingSelMode" Content="Merge Cells" IsChecked="false" VerticalAlignment="Center" Margin="4" Click="_chkAllowMergingSelMode_Click" Foreground="#FF325989" />
              </StackPanel>
              <TextBlock x:Name="_lblSelState" />
            </StackPanel>

            <c1:C1FlexGrid x:Name="_flexSelectionMode" Grid.Row="1" Style="{StaticResource excelBlue}" AllowMerging="All" MinColumnWidth="10" MaxColumnWidth="300" SelectionChanged="_flexSelectionMode_SelectionChanged" />

            <Border Grid.Row="2" Grid.ColumnSpan="2" Style="{StaticResource textBorderStyle}">
              <TextBlock Text="The C1FlexGrid has a rich selection model controlled by the SelectionMode property. You can set the selection mode to single cell, cell range (block of adjacent cells), single row, row range, or list box (not necessarily contiguous). Regardless of the selection mode, the C1FlexGrid always returns the selected cells as a CellRange object so you can easily monitor and work with the selected data." TextWrapping="Wrap" Margin="10,5" Foreground="#FF4976AD" />
            </Border>
          </Grid>
        </c:TabItem>

        <!-- iTunes (custom cells/tree/search/filter/Linq) -->
        <c:TabItem Header="iTunes" Foreground="#FF325989">

          <Grid>
            <Grid.RowDefinitions>
              <RowDefinition Height="Auto" />
              <RowDefinition Height="*" />
              <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <StackPanel Orientation="Vertical">
              <Grid>
                <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="Auto" />
                  <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Horizontal">
                  <CheckBox x:Name="_chkOwnerDraw" VerticalAlignment="Center" Content="Custom Cells " IsChecked="true" Click="_chkOwnerDraw_Click" Foreground="#FF325989" />

                  <TextBlock Text="  Show: " VerticalAlignment="Center" Foreground="#FF325989" />
                  <Button x:Name="_btnShowArtists" Content="Artists" VerticalAlignment="Center" Width="80" Click="_btnShowArtists_Click" />
                  <Button x:Name="_btnShowAlbums" Content="Albums" VerticalAlignment="Center" Width="80" Click="_btnShowAlbums_Click" />
                  <Button x:Name="_btnShowSongs" Content="Songs" VerticalAlignment="Center" Width="80" Click="_btnShowSongs_Click" />
                </StackPanel>

                <local:SearchBox Grid.Column="1" x:Name="_srchTunes" HorizontalAlignment="Right" />

              </Grid>
              <StackPanel Orientation="Horizontal" Margin="8,0,0,0">
                <TextBlock Text="Media Library: " Foreground="#FF325989" />
                <TextBlock x:Name="_txtSongs" Text="Songs" VerticalAlignment="Center" Foreground="#FF325989" />
              </StackPanel>
            </StackPanel>
              
            <!-- show songs in a FlexGrid -->
            <c1:C1FlexGrid x:Name="_flexiTunes" Grid.Row="1" Style="{StaticResource gridStyle}" IsReadOnly="true" AreRowGroupHeadersFrozen="False" HeadersVisibility="Column" GridLinesVisibility="None" Background="White" RowBackground="White" AlternatingRowBackground="White" GroupRowBackground="White" MinColumnWidth="30" SelectionMode="ListBox" SelectionBackground="#a0eaeff4" CursorBackground="#ffeaeff4" AutoGenerateColumns="False">
              <c1:C1FlexGrid.Columns>
                <c1:Column Binding="{Binding Name}" Header="Title" AllowDragging="False" Width="300" />
                <c1:Column Binding="{Binding Duration}" HorizontalAlignment="Right" />
                <c1:Column Binding="{Binding Size}" HorizontalAlignment="Right" />
                <c1:Column Binding="{Binding Rating, Mode=TwoWay}" HorizontalAlignment="Left" Width="200" />
              </c1:C1FlexGrid.Columns>
            </c1:C1FlexGrid>

            <Border Grid.Row="2" Grid.ColumnSpan="2" Style="{StaticResource textBorderStyle}">
              <TextBlock Text="This demo displays a library of about 10,000 songs grouped by artist and album. It includes a search box that allows users to find songs, albums, or artists quickly and easily. The filtering is done on the data view. This demo showcases the C1FlexGrid's CellFactory interface used for customizing cells. We use custom cells to display images next to the artists, albums, songs, collapse/expand icons, and ratings. We can easily create custom cells by inheriting the ICellFactory interface and providing the FrameworkElement objects used to represent the cells." TextWrapping="Wrap" Margin="10,5" Foreground="#FF4976AD" />
            </Border>
          </Grid>
        </c:TabItem>

        <!-- Financial -->
        <c:TabItem Header="Financial" Foreground="#FF325989">
          <Grid>
            <Grid.RowDefinitions>
              <RowDefinition Height="auto" />
              <RowDefinition Height="*" />
              <RowDefinition Height="auto" />
            </Grid.RowDefinitions>

            <StackPanel Orientation="Vertical" Grid.ColumnSpan="2">
              <StackPanel Orientation="Horizontal">
                <CheckBox x:Name="_chkOwnerDrawFinancial" Content="Custom Cells" IsChecked="False" Margin="5" VerticalAlignment="Center" Click="_chkOwnerDrawFinancial_Click" Foreground="#FF325989" />
                <CheckBox x:Name="_chkAutoUpdate" Content="Auto Update" IsChecked="True" Margin="5" VerticalAlignment="Center" Click="_chkAutoUpdate_Click" Foreground="#FF325989" />
                <TextBlock Text="  Update Interval: " VerticalAlignment="Center" Foreground="#FF325989" />
                <ComboBox x:Name="_cmbUpdateInterval" SelectedIndex="2" Width="140" VerticalAlignment="Center" SelectionChanged="_cmbUpdateInterval_SelectionChanged">
                  <ComboBoxItem Content="1000 ms" />
                  <ComboBoxItem Content="500 ms" />
                  <ComboBoxItem Content="100 ms" />
                  <ComboBoxItem Content="50 ms" />
                  <ComboBoxItem Content="5 ms" />
                  <ComboBoxItem Content="1 ms" />
                </ComboBox>
                <TextBlock Text="  Batch Size: " VerticalAlignment="Center" />
                <ComboBox x:Name="_cmbBatchSize" SelectedIndex="1" Width="140" VerticalAlignment="Center" SelectionChanged="_cmbBatchSize_SelectionChanged">
                  <ComboBoxItem Content="500 items" />
                  <ComboBoxItem Content="100 items" />
                  <ComboBoxItem Content="10 items" />
                  <ComboBoxItem Content="1 item" />
                </ComboBox>
              </StackPanel>
              <StackPanel Orientation="Horizontal" Margin="8,0,0,0">
                <TextBlock Text="Financial Info: " VerticalAlignment="Center" Foreground="#FF325989" />
                <TextBlock x:Name="_txtCompanies" Text="Companies" VerticalAlignment="Center" Foreground="#FF325989" />
              </StackPanel>
            </StackPanel>
              
            <local:SearchBox Grid.Column="1" x:Name="_srchCompanies" VerticalAlignment="Top" HorizontalAlignment="Right" />
            <c1:C1FlexGrid x:Name="_flexFinancial" Grid.Row="1" Style="{StaticResource excelBlue}" IsReadOnly="true" MinColumnWidth="10" MaxColumnWidth="300" AutoGenerateColumns="False">
              <c1:C1FlexGrid.Columns>
                <c1:Column Binding="{Binding Symbol}" Width="100" />
                <c1:Column Binding="{Binding Name}" Width="250" />
                <c1:Column Binding="{Binding Bid}" Width="150" Format="n2" HorizontalAlignment="Right" />
                <c1:Column Binding="{Binding Ask}" Width="150" Format="n2" HorizontalAlignment="Right" />
                <c1:Column Binding="{Binding LastSale}" Width="150" Format="n2" HorizontalAlignment="Right" />
                <c1:Column Binding="{Binding BidSize}" Width="100" Format="n0" HorizontalAlignment="Right" />
                <c1:Column Binding="{Binding AskSize}" Width="100" Format="n0" HorizontalAlignment="Right" />
                <c1:Column Binding="{Binding LastSize}" Width="100" Format="n0" HorizontalAlignment="Right" />
                <c1:Column Binding="{Binding Volume}" Width="100" Format="n0" HorizontalAlignment="Right" />
                <c1:Column Binding="{Binding QuoteTime}" Width="100" Format="hh:mm:ss" HorizontalAlignment="Center" />
                <c1:Column Binding="{Binding TradeTime}" Width="100" Format="hh:mm:ss" HorizontalAlignment="Center" />
              </c1:C1FlexGrid.Columns>
            </c1:C1FlexGrid>

            <Border Grid.Row="3" Style="{StaticResource textBorderStyle}">
              <TextBlock Text="This demo shows a financial application with real time data updates, flashing cells, and sparklines. It highlights C1FlexGrid's performance. Check the Custom Cells checkbox to see how we display flashes and sparklines for a better user experience. This is accomplished using the C1FlexGrid's CellFactory interface for easily customizing cells." TextWrapping="Wrap" Margin="10,5" Foreground="#FF4976AD" />
            </Border>
          </Grid>
        </c:TabItem>

        <!-- Editing -->
        <c:TabItem Header="Editing" Foreground="#FF325989">
          <Grid>
            <Grid.RowDefinitions>
              <RowDefinition Height="*" />
              <RowDefinition Height="auto" />
            </Grid.RowDefinitions>

            <c1:C1FlexGrid x:Name="_flexEdit" Style="{StaticResource excelBlue}" MinColumnWidth="10" MaxColumnWidth="300">
            </c1:C1FlexGrid>

            <Border Grid.Row="1" Grid.ColumnSpan="2" Style="{StaticResource textBorderStyle}">
              <TextBlock Text="The C1FlexGrid supports Excel-style editing. Just type values into cells and use the enter or arrow keys to move to the next one. Or press F2 and enter full-edit mode, where arrow keys navigate within the editor. Auto-complete and value-mapped columns are also built-in: simply create a ColumnValueConverter and assign it to the columns ValueConverter property and you're done. Transactioned edits are supported too. The Customer class used here implements IEditableObject, so you can undo changes by pressing the Escape key before you move to a new row. (Note: the gray columns are read-only)." TextWrapping="Wrap" Margin="10,5" Foreground="#FF4976AD" />
            </Border>
          </Grid>
        </c:TabItem>
      </c:TabControl>
    </Grid>
  </Grid>
</UserControl>