<UserControl x:Class="ExampleBrowser.MainPage"
    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:oxy="clr-namespace:OxyPlot.Silverlight;assembly=OxyPlot.Silverlight"
    xmlns:local="clr-namespace:ExampleBrowser"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400">
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <local:GroupingItemsControlConverter x:Key="GroupingItemsControlConverter"/>

            <local:GroupingItemsControlConverterParameters x:Key="SimpleGroupingItemsControlConverterParameter">
                <local:GroupingItemsControlConverterParameters.GroupSelector>
                    <local:ExampleInfoGroupSelector/>
                </local:GroupingItemsControlConverterParameters.GroupSelector>

                <local:GroupingItemsControlConverterParameters.GroupHeaderTemplate>
                    <DataTemplate>
                        <ContentControl Content="{Binding}" FontWeight="Bold"/>
                    </DataTemplate>
                </local:GroupingItemsControlConverterParameters.GroupHeaderTemplate>

                <local:GroupingItemsControlConverterParameters.ItemTemplate>
                    <DataTemplate>
                        <ContentControl Content="{Binding Title}" Padding="8 0 0 0"/>
                    </DataTemplate>
                </local:GroupingItemsControlConverterParameters.ItemTemplate>
            </local:GroupingItemsControlConverterParameters>

        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="2*"/>
        </Grid.ColumnDefinitions>
        <Border Background="SkyBlue" Grid.ColumnSpan="2"/>
        <TextBlock Grid.Row="0" Grid.ColumnSpan="2" Grid.Column="0" Text="OxyPlot Example Browser" Foreground="White" Margin="4"/>
        <TextBlock Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" Text="{Binding Version}" Foreground="White" Margin="4"/>
        <ListBox ItemsSource="{Binding Examples, Converter={StaticResource GroupingItemsControlConverter},
                    ConverterParameter={StaticResource SimpleGroupingItemsControlConverterParameter}}"
                 SelectedItem="{Binding SelectedItem, Mode=TwoWay}" Grid.Row="1" Grid.Column="0" BorderThickness="0,0,1,0"/>

        <sdk:TabControl Grid.Column="1" Grid.Row="1" TabStripPlacement="Bottom">
            <sdk:TabItem Header="Plot">
                <oxy:PlotView Model="{Binding SelectedExample.PlotModel}" Controller="{Binding SelectedExample.PlotController}"/>
            </sdk:TabItem>
            <sdk:TabItem Header="Code">
                <TextBox AcceptsReturn="True" FontFamily="Consolas" 
                         Text="{Binding SelectedExample.Code, Mode=OneWay}" BorderThickness="0"
                         VerticalScrollBarVisibility="Auto"
                         />
            </sdk:TabItem>
        </sdk:TabControl>
    </Grid>
</UserControl>
