<UserControl x:Class="MainShell.Recipe.View.RecipeView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:MainShell.Recipe.View"
             xmlns:mw="http://www.maxwell-gp.com/"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid Margin="-40,0,0,0" Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <mw:SideMenu ItemsSource="{Binding MenuItemWraps}"
                         SelectedItem="{Binding SelectedMenuItem, Mode=TwoWay}" 
                         PreviewMouseLeftButtonDown="SideMenu_PreviewMouseLeftButtonDown"
                         Grid.Row ="0" Width="150" 
                         ExpandMode="Accordion"
                         AutoSelect="True"
                         >
                <mw:SideMenu.ItemContainerStyle>
                    <Style TargetType="{x:Type mw:SideMenuItem}" BasedOn="{StaticResource SideMenuItemHeaderAccordionBaseStyle}">
                        <Setter Property="Header" Value="{Binding Header}" />
                        <Setter Property="Tag" Value="{Binding Tag}" />
                    </Style>
                </mw:SideMenu.ItemContainerStyle>
            </mw:SideMenu>
           
        </Grid>

        <Grid  Grid.Column="1">
            <GroupBox Width="200" x:Name="groupList" Header="{DynamicResource RecipeList}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <ListBox x:Name="recipeList" SelectedItem="{Binding CurrentScreen.SelectedRecipeWrap, Mode=TwoWay}" Style="{StaticResource recipeListBoxStyle}"
PreviewMouseLeftButtonDown="RecipeList_PreviewMouseLeftButtonDown"
ItemsSource="{Binding CurrentScreen.RecipeWraps}"
d:ItemsSource="{d:SampleData ItemCount=5}"/>
                    <Border DataContext="{Binding ElementName=recipeList, Path=SelectedItem}" BorderThickness="1" BorderBrush="AliceBlue" Grid.Row="1">
                        <ScrollViewer>
                            <StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="创建时间："/>
                                    <TextBlock TextWrapping="Wrap" Text="{Binding CreateTime, Converter={StaticResource DateTimeToStringConverter}}"/>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="修改时间："/>
                                    <TextBlock TextWrapping="Wrap" Text="{Binding ModifiedTime, Converter={StaticResource DateTimeToStringConverter}}"/>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="描述："/>
                                </StackPanel>
                            </StackPanel>
                        </ScrollViewer>
                    </Border>
                    <Border Grid.Row="2">
                        <local:RecipeButtonGroupView DataContext="{Binding CurrentScreen}" />
                    </Border>
                </Grid>
            </GroupBox>
            <ToggleButton x:Name="toggleBtn"  HorizontalAlignment="Right" Style="{StaticResource ToggleBtnSideBarStyle}"
                          IsChecked="{Binding IsRecipePanelHidden, Mode=TwoWay}">
               
                <ToggleButton.Triggers>
                    <EventTrigger RoutedEvent="ToggleButton.Checked">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetName="groupList" Storyboard.TargetProperty="(FrameworkElement.Width)" To="0" Duration="0:0:0.2"/>
                                <ThicknessAnimation Storyboard.TargetName="toggleBtn"
                    Storyboard.TargetProperty="(FrameworkElement.Margin)"
                    To="-30,0,0,0" Duration="0:0:0.2"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                    <EventTrigger RoutedEvent="ToggleButton.Unchecked">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetName="groupList" Storyboard.TargetProperty="(FrameworkElement.Width)" To="200" Duration="0:0:0.2"/>
                                <ThicknessAnimation Storyboard.TargetName="toggleBtn"
Storyboard.TargetProperty="(FrameworkElement.Margin)"
To="0,0,0,0" Duration="0:0:0.2"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </ToggleButton.Triggers>
            </ToggleButton>
        </Grid>
        <ContentControl Margin="5,0" Grid.Column="2" mw:View.Model="{Binding CurrentScreen}"/>
    </Grid>
</UserControl>
