<Window x:Class="GridViewInsidePanelBar.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:GridViewInsidePanelBar"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"
        Title="MainWindow">

    <Window.DataContext>
        <local:MainViewModel />
    </Window.DataContext>

    <Window.Resources>
        <DataTemplate x:Key="TabItemTemplate">
            <StackPanel VerticalAlignment="Center" Orientation="Horizontal">
                <TextBlock Text="{Binding Header}" />
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="SpellRefCostAPCTemplate">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <telerik:RadGridView x:Name="SpellDataGrid"
                                     Grid.Row="0"
                                     AutoGenerateColumns="False"
                                     CanUserInsertRows="True"
                                     IsSynchronizedWithCurrentItem="True"
                                     ItemsSource="{Binding ContentData}"
                                     SelectionMode="Extended"
                                     SelectionUnit="FullRow"
                                     ShowInsertRow="True">
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column1}" Header="Column1" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column2}" Header="Column2" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column3}" Header="Column3" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column4}" Header="Column4" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column5}" Header="Column5" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column6}" Header="Column6" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column7}" Header="Column7" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column8}"
                                                    Header="Column8"
                                                    IsVisible="False" />
                    </telerik:RadGridView.Columns>
                </telerik:RadGridView>

                <telerik:RadDataPager x:Name="SpellDataPager"
                                      Grid.Row="1"
                                      AutoEllipsisMode="Both"
                                      BorderThickness="1,0,1,1"
                                      DisplayMode="FirstLastPreviousNext"
                                      IsTotalItemCountFixed="False"
                                      NumericButtonCount="10"
                                      PageSize="40"
                                      Source="{Binding Items,
                                                       ElementName=SpellDataGrid}" />
            </Grid>

        </DataTemplate>

        <DataTemplate x:Key="ActivityRefCostAPCTemplate">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <telerik:RadGridView x:Name="ActivityDataGrid"
                                     Grid.Row="0"
                                     AutoGenerateColumns="False"
                                     CanUserInsertRows="True"
                                     IsSynchronizedWithCurrentItem="True"
                                     ItemsSource="{Binding ContentData}"
                                     SelectionMode="Extended"
                                     SelectionUnit="FullRow"
                                     ShowInsertRow="True">
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column1}" Header="Column1" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column2}" Header="Column2" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column3}" Header="Column3" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column4}" Header="Column4" />
                    </telerik:RadGridView.Columns>
                </telerik:RadGridView>

                <telerik:RadDataPager x:Name="ActivityDataPager"
                                      Grid.Row="1"
                                      AutoEllipsisMode="Both"
                                      BorderThickness="1,0,1,1"
                                      DisplayMode="FirstLastPreviousNext"
                                      IsTotalItemCountFixed="False"
                                      NumericButtonCount="10"
                                      PageSize="40"
                                      Source="{Binding Items,
                                                       ElementName=ActivityDataGrid}" />
            </Grid>

        </DataTemplate>
        <local:DataFileTemplateSelector x:Key="dataFileTemplateSelector"
                                        Template1="{StaticResource SpellRefCostAPCTemplate}"
                                        Template2="{StaticResource ActivityRefCostAPCTemplate}" />
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <telerik:RadRibbonView>
            <telerik:RadRibbonTab Header="Tab 1">
                <telerik:RadRibbonGroup Header="Group 1">
                    <telerik:RadRibbonButton Command="telerik:RadGridViewCommands.CommitEdit" Text="Save insert/edit" />
                    <telerik:RadRibbonButton Command="telerik:RadGridViewCommands.Delete" Text="Delete" />
                </telerik:RadRibbonGroup>
            </telerik:RadRibbonTab>
        </telerik:RadRibbonView>
        <telerik:RadTabControl x:Name="tabControl"
                               Grid.Row="1"
                               ContentTemplateSelector="{StaticResource dataFileTemplateSelector}"
                               ItemsSource="{Binding Tabs}"
                               ItemTemplate="{StaticResource TabItemTemplate}"
                               OverflowMode="Wrap"
                               SelectedItem="{Binding CurrentTab,
                                                      Mode=TwoWay}" />
    </Grid>
</Window>
