<mah:MetroWindow x:Class="TelerikSortingError.MainWindow"
                 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:local="clr-namespace:TelerikSortingError"
                 xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
                 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                 x:Name="root"
                 Title="MainWindow"
                 Width="800"
                 Height="450"
                 mc:Ignorable="d">

	<TabControl x:Name="tabControl" DataContext="{Binding ElementName=root}">
		<TabControl.Resources>
			<CollectionViewSource x:Key="SortedVariants"
			                      Filter="SortedVariants_Filter"
			                      Source="{Binding ListOfItems}">
				<CollectionViewSource.SortDescriptions>
					<scm:SortDescription Direction="Ascending" PropertyName="VariantName" />
				</CollectionViewSource.SortDescriptions>
			</CollectionViewSource>
		</TabControl.Resources>

		<TabItem Header="Working">
			<telerik:RadGridView x:Name="radgrid1"
			                     telerik:StyleManager.Theme="Fluent"
			                     AutoGenerateColumns="False"
			                     CanUserFreezeColumns="False"
			                     CanUserSearch="True"
			                     CanUserSearchInHiddenColumns="False"
			                     GroupRenderMode="Flat"
			                     IsFilteringAllowed="True"
			                     IsReadOnly="True"
			                     IsSearchingDeferred="False"
			                     ItemsSource="{Binding Path=ListOfItems}"
			                     PinnedRowsPosition="Top"
			                     RowIndicatorVisibility="Collapsed"
			                     SearchMode="MatchAllTerms"
			                     SelectionMode="Single"
			                     ShowGroupPanel="False"
			                     ShowSearchPanel="False">
				<telerik:RadGridView.Columns>

					<!--<telerik:GridViewPinRowColumn />-->

					<telerik:GridViewDataColumn Width="*"
					                            DataMemberBinding="{Binding Name}"
					                            Header="VariantID" />
					<telerik:GridViewDataColumn Width="*"
					                            DataMemberBinding="{Binding Description}"
					                            Header="Fabrikat" />


					<telerik:GridViewDataColumn Width="*"
					                            DataMemberBinding="{Binding Vintage}"
					                            Header="Årgang">
						<telerik:GridViewDataColumn.FilteringControl>
							<local:CustomGridFilter Aargang="{Binding ElementName=root, Path=VintageYear, Mode=TwoWay}" />
						</telerik:GridViewDataColumn.FilteringControl>
					</telerik:GridViewDataColumn>

					<telerik:GridViewDataColumn Width="*"
					                            DataMemberBinding="{Binding ModelserieNavn}"
					                            Header="Serienavn" />
				</telerik:RadGridView.Columns>
			</telerik:RadGridView>
		</TabItem>

		<TabItem Header="Not Working">
			<telerik:RadGridView x:Name="radgrid2"
			                     telerik:StyleManager.Theme="Fluent"
			                     AutoGenerateColumns="False"
			                     CanUserFreezeColumns="False"
			                     CanUserSearch="True"
			                     CanUserSearchInHiddenColumns="False"
			                     GroupRenderMode="Flat"
			                     IsFilteringAllowed="True"
			                     IsReadOnly="True"
			                     IsSearchingDeferred="False"
			                     ItemsSource="{Binding Source={StaticResource SortedVariants}}"
			                     PinnedRowsPosition="Top"
			                     RowIndicatorVisibility="Collapsed"
			                     SearchMode="MatchAllTerms"
			                     SelectionMode="Single"
			                     ShowGroupPanel="False"
			                     ShowSearchPanel="False">

				<telerik:RadGridView.Columns>

					<telerik:GridViewPinRowColumn />

					<telerik:GridViewDataColumn Width="*"
					                            DataMemberBinding="{Binding Name}"
					                            Header="Name" />

					<telerik:GridViewDataColumn Width="*"
					                            DataMemberBinding="{Binding Description}"
					                            Header="Description" />

					<telerik:GridViewDataColumn Width="*"
					                            DataMemberBinding="{Binding Vintage}"
					                            Header="Årgang">
						<telerik:GridViewDataColumn.FilteringControl>
							<local:CustomGridFilter Aargang="{Binding ElementName=root, Path=VintageYear, Mode=TwoWay}" />
						</telerik:GridViewDataColumn.FilteringControl>
					</telerik:GridViewDataColumn>


				</telerik:RadGridView.Columns>
			</telerik:RadGridView>
		</TabItem>

	</TabControl>
</mah:MetroWindow>
