<UserControl x:Class="TaskIt.Modules.Tasks.Views.Grid"
    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:telerikGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" 
    xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"              
    xmlns:Infrastructure="clr-namespace:TaskIt.Infrastructure;assembly=TaskIt.Infrastructure" 
    xmlns:Views="clr-namespace:TaskIt.Modules.Tasks.Views" 
    mc:Ignorable="d"    
    d:DesignHeight="300" d:DesignWidth="400">

    <UserControl.Resources>
        <Infrastructure:DataContextProxy x:Key="DataContextProxy" />
    </UserControl.Resources>

    <Grid>
        <TextBlock Text="{Binding ResourceNoItemsMessage}" Style="{StaticResource MessageLabelStyle}"
                   Visibility="{Binding HasTasks, Converter={StaticResource InvertedBooleanToVisibilityConverter}}"/>
        <telerikGridView:RadGridView x:Name="grdData" ItemsSource="{Binding Tasks}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                   Visibility="{Binding HasTasks, Converter={StaticResource BooleanToVisibilityConverter}}"
                   RowDetailsVisibilityChanged="GridRowDetailsVisibilityChanged">
            <telerikGridView:RadGridView.Columns>
                <telerikGridView:GridViewToggleRowDetailsColumn/>
                <telerikGridView:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" Width="4*"/>
                <telerikGridView:GridViewDataColumn Header="Priority" DataMemberBinding="{Binding Priority.Name}" Width="*"/>
                <telerikGridView:GridViewDataColumn Header="Context" DataMemberBinding="{Binding Context.Name}" IsVisible="{Binding IsNotFilteredByContext}" Width="*"/>
                <telerikGridView:GridViewDataColumn Header="Project" DataMemberBinding="{Binding Project.Name}" IsVisible="{Binding IsNotFilteredByProject}" Width="*"/>
                <telerikGridView:GridViewDataColumn Header="Contact" DataMemberBinding="{Binding Contact.Name}" IsVisible="{Binding IsNotFilteredByContact}" Width="*"/>
                <telerikGridView:GridViewDataColumn Header="Category" DataMemberBinding="{Binding TaskCategory.Name}" IsVisible="{Binding IsNotFilteredByCategory}" Width="*"/>
                <telerikGridView:GridViewDataColumn Header="Due" DataMemberBinding="{Binding DueDate}" DataFormatString="{}{0:d}" Width="*"/>
            </telerikGridView:RadGridView.Columns>
            <telerikGridView:RadGridView.RowDetailsTemplate>
                <DataTemplate>
                    <Views:RowDetailTabs ViewModelProxy="{Binding ViewModel, Source={StaticResource DataContextProxy}}" Margin="8"/>
                </DataTemplate>
            </telerikGridView:RadGridView.RowDetailsTemplate>
            <telerikNavigation:RadContextMenu.ContextMenu>
                <telerikNavigation:RadContextMenu Opened="GridContextMenuOpened">                    
                    <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandEdit}" Icon="{Binding IconEdit}" Command="{Binding EditCommand}"/>
                    <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandDelete}" Icon="{Binding IconDelete}" Command="{Binding DeleteCommand}" CommandParameter="{Binding SelectedItem, Mode=TwoWay}"/>
                    <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandMarkCompleted}" Icon="{Binding IconMarkCompleted}" Command="{Binding MarkCompletedCommand}"/>
                    <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandMoveTo}" Visibility="{Binding IsMoveToCommandAvailable, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandMoveToInbox}" Icon="{Binding IconInbox}" Command="{Binding MoveToCommand}" CommandParameter="{Binding TaskCategoryInbox}" Visibility="{Binding IsMoveToInboxCommandAvailable, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                        <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandMoveToActions}" Icon="{Binding IconActions}" Command="{Binding MoveToCommand}" CommandParameter="{Binding TaskCategoryActions}" Visibility="{Binding IsMoveToActionsCommandAvailable, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                        <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandMoveToWaiting}" Icon="{Binding IconWaiting}" Command="{Binding MoveToCommand}" CommandParameter="{Binding TaskCategoryWaiting}" Visibility="{Binding IsMoveToWaitingCommandAvailable, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                        <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandMoveToSomeday}" Icon="{Binding IconSomeday}" Command="{Binding MoveToCommand}" CommandParameter="{Binding TaskCategorySomeday}" Visibility="{Binding IsMoveToSomedayCommandAvailable, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                        <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandMoveToTicklers}" Icon="{Binding IconTicklers}" Command="{Binding MoveToCommand}" CommandParameter="{Binding TaskCategoryTicklers}" Visibility="{Binding IsMoveToTicklersCommandAvailable, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                        <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandMoveToReference}" Icon="{Binding IconReference}" Command="{Binding MoveToCommand}" CommandParameter="{Binding TaskCategoryReference}" Visibility="{Binding IsMoveToReferenceCommandAvailable, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                    </telerikNavigation:RadMenuItem>
                    <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandSendTo}" Visibility="{Binding IsSendToCommandAvailable, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandSendToTwitter}" Icon="{Binding IconTwitter}" Command="{Binding SendToTwitterCommand}"/>
                        <telerikNavigation:RadMenuItem Header="{Binding ResourceCommandSendToFacebook}" Icon="{Binding IconFacebook}" Command="{Binding SendToFacebookCommand}"/>
                    </telerikNavigation:RadMenuItem>
                </telerikNavigation:RadContextMenu>
            </telerikNavigation:RadContextMenu.ContextMenu>
        </telerikGridView:RadGridView>
    </Grid>

</UserControl>
