<commit_before>﻿<UserControl x:Class="Gama.Atenciones.Wpf.Views.EditarCitasView"
             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:Gama.Atenciones.Wpf.Views"
             xmlns:designData="clr-namespace:Gama.Atenciones.Wpf.DesignTimeData"
             xmlns:CustomControls="clr-namespace:Gama.Atenciones.Wpf.Controls"
             xmlns:Converters="clr-namespace:Gama.Atenciones.Wpf.Converters"
             xmlns:cc="clr-namespace:Gama.Common.CustomControls;assembly=Gama.Common"
             xmlns:coreControls="clr-namespace:Core.Controls;assembly=Core"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:prism="http://prismlibrary.com/"           
             xmlns:coreUtil="clr-namespace:Core.Util;assembly=Core"
             mc:Ignorable="d"
             x:Name="_Root"
             d:DataContext="{d:DesignInstance Type=designData:EditarCitasViewModelDTD, IsDesignTimeCreatable=True}"  
             d:DesignWidth="1499.337" 
             d:DesignHeight="1028.796">
  <UserControl.Resources>
    <Style x:Key="_CircleIconButtonStyle"
      TargetType="cc:CircleIconButton" BasedOn="{StaticResource {x:Type cc:CircleIconButton}}">
      <Setter Property="Opacity" Value="0.5"/>
      <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
          <Setter Property="Opacity" Value="1"/>
          <Setter Property="Cursor" Value="Hand"/>
        </Trigger>
      </Style.Triggers>
    </Style>

    <Converters:DateConverter x:Key="DateConverter"/>

    <coreUtil:TwoParameterCommandConverter x:Key="_TwoParameterCommandConverter"/>

    <ControlTemplate x:Key="_CalendarioCalendarStyle"  TargetType="{x:Type CustomControls:CustomCalendar}">
      <ControlTemplate.Resources>
        <Converters:AppointmentsConverter x:Key="AppointmentsConverter"/>
        <Converters:MonthNameConverter x:Key="MonthNameConverter"/>
      </ControlTemplate.Resources>

      <Border Background="{TemplateBinding Background}"
                  BorderBrush="{TemplateBinding BorderBrush}"
                  BorderThickness="{TemplateBinding BorderThickness}">
        <Grid>
          <Grid.RowDefinitions>
            <RowDefinition Height="10"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
          </Grid.RowDefinitions>
          <Grid>
            <Button x:Name="_ToggleDateFilterButton" 
              Command="{Binding ToggleNavegacionCommand,
                  RelativeSource={RelativeSource AncestorType={x:Type CustomControls:CustomCalendar}}}"
              VerticalAlignment="Top"
              HorizontalAlignment="Right" 
              Panel.ZIndex="9999"
                  Cursor="Hand"
                  ToolTip="Ocultar botones de navegación"
              Margin="0,-23,137,0" 
              BorderThickness="0"
              BorderBrush="Transparent"
              Foreground="Blue"
              Background="Transparent">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource _TwoParameterCommandConverter}">
                  <Binding ElementName="_ToggleDateFilterButton"/>
                  <Binding ElementName="_NavegationStackPanel"/>
                  <Binding ElementName="_Calendario"/>
                  <Binding ElementName="_OtherToggleButton"/>
                </MultiBinding>
              </Button.CommandParameter>
              <Grid>
                <Rectangle Width="20" Height="20" Stroke="Black" >
                  <Rectangle.Fill>
                    <VisualBrush Visual="{StaticResource appbar_3d_3ds}" Stretch="Uniform"/>
                  </Rectangle.Fill>
                </Rectangle>
              </Grid>
              <Button.Style>
                <Style TargetType="Button">
                  <Setter Property="Template">
                    <Setter.Value>
                      <ControlTemplate TargetType="Button">
                        <Border Background="Transparent">
                          <ContentPresenter/>
                        </Border>
                      </ControlTemplate>
                    </Setter.Value>
                  </Setter>
                </Style>
              </Button.Style>
            </Button>

            <StackPanel x:Name="_NavegationStackPanel" Orientation="Horizontal" HorizontalAlignment="Right">
              <!-- Magic CheckBox para cambiar template del calendario -->

              <!-- Botón para cambiar template -->
              <cc:CircleIconButton Click="CircleIconButton_Click" >
                <cc:CircleIconButton.Style>
                  <Style TargetType="cc:CircleIconButton" BasedOn="{StaticResource {x:Type cc:CircleIconButton}}">
                    <Setter Property="Foreground" Value="#645C5C"/>
                    <Setter Property="Icon" Value="{StaticResource appbar_lines_horizontal_4}"/>
                    <Setter Property="Margin" Value="4,-30,0,0"/>
                    <Setter Property="HorizontalAlignment" Value="Right"/>
                    <Setter Property="BorderThickness" Value="0"/>
                    <Setter Property="IconWidth" Value="22"/>
                    <Setter Property="IconHeight" Value="22"/>
                    <Setter Property="Height" Value="35"/>
                    <Setter Property="Width" Value="35"/>
                    <Setter Property="VerticalAlignment" Value="Top"/>
                    <Style.Triggers>
                      <DataTrigger Binding="{Binding ElementName=_ToggleCalendarStyleCheckbox, Path=IsChecked}" Value="True">
                        <Setter Property="Icon" Value="{StaticResource appbar_calendar}"/>
                        <Setter Property="Margin" Value="4,-30,4,0"/>
                      </DataTrigger>
                    </Style.Triggers>
                  </Style>
                </cc:CircleIconButton.Style>
              </cc:CircleIconButton>

              <cc:CircleIconButton x:Name="_SemanaAnteriorButton"
                Command="{Binding SemanaAnteriorCommand,
                    RelativeSource={RelativeSource AncestorType={x:Type CustomControls:CustomCalendar}}}"
                    Icon="{StaticResource appbar_arrow_left}"
                    Margin="0,-40,0,0"/>
              <cc:CircleIconButton  x:Name="_SemanaSiguienteButton"
                Command="{Binding SemanaSiguienteCommand,
                    RelativeSource={RelativeSource AncestorType={x:Type CustomControls:CustomCalendar}}}"
                    Icon="{StaticResource appbar_arrow_right}"
                    Margin="0,-40,0,0" />
            </StackPanel>

            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
            </StackPanel>
          </Grid>

          <!-- Nombres de los días: Lunes, martes...-->
          <ItemsControl Grid.Row="1" Margin="-1,0,0,0"
                ItemsSource="{Binding DayNames, RelativeSource={RelativeSource FindAncestor, 
					        AncestorType={x:Type  CustomControls:CustomCalendar}}}" >
            <ItemsControl.ItemTemplate>
              <DataTemplate>
                <TextBlock TextAlignment="Center" Text="{Binding}" 
                               Foreground="White" FontWeight="Light" FontSize="13"
                               Margin="0"
                               Padding="4">
                  <TextBlock.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                      <GradientStop Color="#FF1B1B1B" Offset="0"/>
                      <GradientStop Color="#1B1B1B" Offset="1"/>
                    </LinearGradientBrush>
                  </TextBlock.Background>
                </TextBlock>
              </DataTemplate>
            </ItemsControl.ItemTemplate>
            <ItemsControl.ItemsPanel>
              <ItemsPanelTemplate>
                <UniformGrid Rows="1" Columns="7" Margin="4,0,4,0"/>
              </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
          </ItemsControl>
          <!--
            Other Toggle Button
          -->
          <Button x:Name="_OtherToggleButton"  Grid.Row="1"
              Command="{Binding ToggleNavegacionCommand,
                  RelativeSource={RelativeSource AncestorType={x:Type CustomControls:CustomCalendar}}}"
              VerticalAlignment="Top"
              HorizontalAlignment="Right" 
                  Visibility="Collapsed"
                  Cursor="Hand"
                  ToolTip="Mostrar botones de navegación"
              Panel.ZIndex="9999"
              Margin="0,-4,2,0" 
              BorderThickness="0"
              BorderBrush="Transparent"
              Foreground="Blue"
              RenderTransformOrigin="0.5,0.5"
              Background="Transparent">
            <Button.CommandParameter>
              <MultiBinding Converter="{StaticResource _TwoParameterCommandConverter}">
                <Binding ElementName="_ToggleDateFilterButton"/>
                <Binding ElementName="_NavegationStackPanel"/>
                <Binding ElementName="_Calendario"/>
                <Binding ElementName="_OtherToggleButton"/>
              </MultiBinding>
            </Button.CommandParameter>
            <Button.RenderTransform>
              <RotateTransform Angle="180" />
            </Button.RenderTransform>
            <Grid>
              <Rectangle Width="20" Height="20" Stroke="Black" >
                <Rectangle.Fill>
                  <VisualBrush Visual="{StaticResource appbar_3d_3ds}" Stretch="Uniform"/>
                </Rectangle.Fill>
              </Rectangle>
              <Rectangle Width="20" 
                           Height="20" 
                           Stroke="#D124CA" 
                           Fill="#83AE3D9A">
              </Rectangle>
            </Grid>
            <Button.Style>
              <Style TargetType="Button">
                <Setter Property="Template">
                  <Setter.Value>
                    <ControlTemplate TargetType="Button">
                      <Border Background="Transparent">
                        <ContentPresenter/>
                      </Border>
                    </ControlTemplate>
                  </Setter.Value>
                </Setter>
              </Style>
            </Button.Style>
          </Button>

          <ItemsControl Grid.Row="2" 
                            ItemsSource="{Binding Days, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged,
                              RelativeSource={RelativeSource FindAncestor, 
					                     AncestorType={x:Type  CustomControls:CustomCalendar}}}">
            <ItemsControl.ItemTemplate>
              <DataTemplate>
                <!-- -->
                <!-- Box -->
                <!-- -->
                <!--<Border BorderBrush="Black" BorderThickness="0.5" Padding="0" Margin="1">-->
                <Border Name="InnerBorder" BorderBrush="Black" BorderThickness="1" Margin="1">
                  <Border.Style>
                    <Style TargetType="{x:Type Border}">
                      <Setter Property="BorderBrush" Value="Black"/>
                      <Style.Triggers>
                        <!--Current Day-->
                        <DataTrigger Binding="{Binding IsToday}" Value="true">
                          <Setter Property="Border.Background">
                            <Setter.Value>
                              <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="#ECB5B5B5" Offset="0"/>
                                <GradientStop Color="#D99D9D9D" Offset="1"/>
                              </LinearGradientBrush>
                            </Setter.Value>
                          </Setter>
                        </DataTrigger>
                      </Style.Triggers>
                    </Style>
                  </Border.Style>

                  <Grid>
                    <Grid.Style>
                      <Style TargetType="Grid">
                        <Style.Triggers>
                          <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" Value="True">
                            <Setter Property="Background" Value="#D9B66373"/>
                          </DataTrigger>
                          <DataTrigger Binding="{Binding IsTargetMonth}" Value="False">
                            <Setter Property="Background" Value="LightGray"/>
                          </DataTrigger>
                        </Style.Triggers>
                      </Style>
                    </Grid.Style>
                    <Grid.RowDefinitions>
                      <RowDefinition Height="Auto"/>
                      <RowDefinition />
                    </Grid.RowDefinitions>

                    <!-- Mes en texto (ENE, FEB, ...) -->
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                      <TextBlock TextAlignment="Left" VerticalAlignment="Center" Background="#FF307DBB"
                                       Padding="4,2,6,4"
                                       Margin="2,-4,0,0"
                                       Foreground="White" 
                                       Text="{Binding Date.Month, Converter={StaticResource MonthNameConverter}}"/>
                    </StackPanel>

                    <!-- -->
                    <!-- Nueva Cita y Día del mes -->
                    <!-- -->
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                      <!-- Nueva Cita -->
                      <!--<cc:CircleIconButton Background="Transparent" FontWeight="Light" BorderThickness="0"
                                    VerticalContentAlignment="Top"
                                    Icon="{StaticResource appbar_add}"
                                    Width="20" Height="20"
                                    IconHeight="8" IconWidth="8"
                                    Margin="0,0,0,0" FontSize="14"
                                    Padding="0"
                                    Command="{Binding DataContext.NuevaCitaCommand,   
                                      RelativeSource={RelativeSource FindAncestor, 
					                              AncestorType={x:Type UserControl}}}" 
                                    CommandParameter="{Binding}">
                          +
                        </cc:CircleIconButton>-->

                      <!-- Día del mes -->
                      <TextBlock TextAlignment="Right" 
                                       Text="{Binding Date, Converter={StaticResource DateConverter}, ConverterParameter=DAY}" 
                                       FontSize="12" Margin="4,2,4,4" >
                        <TextBlock.Style>
                          <Style TargetType="{x:Type TextBlock}">
                            <Style.Triggers>
                              <DataTrigger Binding="{Binding IsTargetMonth}" Value="false">
                                <Setter Property="TextBlock.Foreground" Value="Gray"></Setter>
                              </DataTrigger>
                            </Style.Triggers>
                          </Style>
                        </TextBlock.Style>
                      </TextBlock>
                    </StackPanel>

                    <!-- -->
                    <!-- Lista de Appointments -->
                    <!-- -->
                    <coreControls:UnselectableListBox
                              x:Name="PART_AppointmentsListBox"
                              Grid.Row="1"
                              Background="Transparent"
                              BorderBrush="Transparent"
                              HorizontalContentAlignment="Stretch">
                      <ListBox.ItemsSource>
                        <MultiBinding Converter="{StaticResource AppointmentsConverter}">
                          <Binding RelativeSource="{RelativeSource Mode=FindAncestor,
                                  AncestorType={x:Type  CustomControls:CustomCalendar}}" Path="Appointments"/>
                          <Binding RelativeSource="{RelativeSource Mode=Self}" Path="DataContext"/>
                        </MultiBinding>
                      </ListBox.ItemsSource>
                      <ListBox.ItemTemplate>
                        <DataTemplate>
                          <Border Background="#FFDFE8F5" 
                                        BorderBrush="#FF5177A8" BorderThickness="0,2,0,2" CornerRadius="1" Margin="2">
                            <Grid>
                              <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto"/>
                              </Grid.ColumnDefinitions>

                              <!--                        -->
                              <!-- Contenido de cada cita -->
                              <!--                        -->
                              <Grid>
                                <Grid.ColumnDefinitions>
                                  <ColumnDefinition Width="Auto"/>
                                  <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                  <RowDefinition Height="Auto"/>
                                  <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>

                                <TextBlock Grid.Row="0"
                                            Margin="4,2,4,2" 
                                            HorizontalAlignment="Left" 
                                            VerticalAlignment="Center">
                                            <Run Text="{Binding Hora}"/>
                                            <Run Text=":" />
                                            <Run Text="{Binding Minutos}"/>
                                </TextBlock>

                                <TextBlock Grid.Row="1" Text="{Binding Persona.Nombre}" Margin="4,2,4,2"/>

                                <cc:CircleIconButton
                                              Grid.Column="1"
                                              Icon="{StaticResource appbar_archive}"
                                              Width="24" Height="24"
                                              IconHeight="7" IconWidth="7"
                                              Margin="4,2,4,2"
                                              HorizontalAlignment="Right"
                                              VerticalAlignment="Center"
                                              Padding="2,0,2,0"
                                              BorderThickness="0"
                                              FontSize="14"
                                              Background="#FF3078A5"
                                              Foreground="White"
                                              FontWeight="Bold"
                                              Command="{Binding DataContext.NuevaAtencionCommand, 
                                                RelativeSource={RelativeSource FindAncestor, 
					                                          AncestorType={x:Type UserControl}}}"
                                              CommandParameter="{Binding}"
                                              Style="{StaticResource _CircleIconButtonStyle}"/>
                                <cc:CircleIconButton
                                            Grid.Column="1"
                                            Grid.Row="1"
                                              Icon="{StaticResource appbar_edit}"
                                              Width="24" Height="24"
                                              IconHeight="7" IconWidth="7"
                                              Margin="4,2,4,2" 
                                              HorizontalAlignment="Right"
                                              VerticalAlignment="Center"
                                              Padding="2,0,2,0"
                                              BorderThickness="0"
                                              FontSize="14"
                                              Background="#FF3078A5"
                                              Foreground="White"
                                              FontWeight="Bold"
                                              Command="{Binding DataContext.EditarCitaCommand, 
                                                RelativeSource={RelativeSource FindAncestor, 
					                                          AncestorType={x:Type UserControl}}}"
                                              CommandParameter="{Binding}"
                                              Style="{StaticResource _CircleIconButtonStyle}"/>
                              </Grid>
                            </Grid>
                          </Border>
                        </DataTemplate>
                      </ListBox.ItemTemplate>
                      <ListBox.Resources>
                        <Style TargetType="{x:Type ListBoxItem}">
                          <Setter Property="Template">
                            <Setter.Value>
                              <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                <Border x:Name="_ListBoxItemBorder"
                                          BorderBrush="{TemplateBinding BorderBrush}"
                                          BorderThickness="{TemplateBinding BorderThickness}"
                                          Background="{TemplateBinding Background}"
                                          Padding="{TemplateBinding Padding}"
                                          SnapsToDevicePixels="true">
                                  <ContentPresenter 
                                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                                </Border>
                                <ControlTemplate.Triggers>
                                  <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                      <Condition Property="Selector.IsSelectionActive" Value="False" />
                                      <Condition Property="IsSelected" Value="True" />
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Background" TargetName="_ListBoxItemBorder" Value="#8BB3B6" />
                                  </MultiTrigger>
                                  <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                      <Condition Property="Selector.IsSelectionActive" Value="True" />
                                      <Condition Property="IsSelected" Value="True" />
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Background" TargetName="_ListBoxItemBorder" Value="#8BB3B6" />
                                  </MultiTrigger>
                                </ControlTemplate.Triggers>
                              </ControlTemplate>
                            </Setter.Value>
                          </Setter>
                        </Style>
                      </ListBox.Resources>
                    </coreControls:UnselectableListBox>
                    <Grid.InputBindings>
                      <MouseBinding MouseAction="LeftDoubleClick"
                                            Command="{Binding DataContext.NuevaCitaCommand, RelativeSource={RelativeSource FindAncestor, 
					                              AncestorType={x:Type UserControl}}}" 
                                    CommandParameter="{Binding}"/>
                    </Grid.InputBindings>
                  </Grid>
                </Border>
                <!--</Border>-->
              </DataTemplate>
            </ItemsControl.ItemTemplate>
            <ItemsControl.ItemsPanel>
              <ItemsPanelTemplate>
                <UniformGrid Rows="3" Columns="7"  Margin="2,0,2,0"/>
              </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
          </ItemsControl>
        </Grid>
      </Border>
    </ControlTemplate>

    <ControlTemplate x:Key="_ListadoCalendarStyle"  TargetType="{x:Type  CustomControls:CustomCalendar}">
      <ControlTemplate.Resources>
        <Converters:BinaryImageConverter x:Key="_BinaryImageConverter" />

        <Style x:Key="DGCHeaderStyle" TargetType="DataGridColumnHeader">
          <Setter Property="Height" Value="38"/>
          <Setter Property="Background" Value="LightBlue" />
          <Setter Property="Foreground" Value="Black"/>
          <Setter Property="FontSize" Value="15" />
          <Setter Property="FontWeight" Value="DemiBold"/>
          <Setter Property="Margin" Value="0"/>
        </Style>

        <Style x:Key="DGHeaderStyle" TargetType="{x:Type DataGrid}">
          <Setter Property="ColumnHeaderStyle" Value="{StaticResource DGCHeaderStyle}"/>
          <Setter Property="RowHeaderWidth" Value="0"/>
          <Setter Property="GridLinesVisibility" Value="None"/>
          <Setter Property="AlternatingRowBackground" Value="#B99BA5AB"/>
          <Setter Property="AutoGenerateColumns" Value="False"/>
          <Setter Property="IsReadOnly" Value="True"/>
          <Setter Property="Margin" Value="0"/>
        </Style>

        <DataTemplate x:Key="_EditarButtonCellTemplate">
          <cc:CircleIconButton
                      Icon="{StaticResource appbar_edit}"
                      Width="36"
                      Height="36"
                      IconWidth="13"
                      IconHeight="13"
                      Margin="{StaticResource Margin}"
                      Command="{Binding ElementName=_Root, Path=DataContext.EditarCitaCommand}"
                      CommandParameter="{Binding}">
            <Button.Style>
              <Style TargetType="cc:CircleIconButton" BasedOn="{StaticResource {x:Type cc:CircleIconButton}}">
                <Setter Property="Opacity" Value="0.5"/>
                <Style.Triggers>
                  <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Opacity" Value="1"/>
                    <Setter Property="Cursor" Value="Hand"/>
                  </Trigger>
                </Style.Triggers>
              </Style>
            </Button.Style>
          </cc:CircleIconButton>
        </DataTemplate>

        <DataTemplate x:Key="_IrButtonCellTemplate">
          <cc:CircleIconButton
                      HorizontalAlignment="Left"
                      Icon="{StaticResource appbar_arrow_right}"
                      Width="36"
                      Height="36"
                      IconWidth="13"
                      IconHeight="13"
                      Margin="{StaticResource Margin}"
                      Command="{Binding ElementName=_Root, Path=DataContext.SeleccionarPersonaCommand}"
                      CommandParameter="{Binding}">
            <Button.Style>
              <Style TargetType="cc:CircleIconButton" BasedOn="{StaticResource {x:Type cc:CircleIconButton}}">
                <Setter Property="Opacity" Value="0.5"/>
                <Style.Triggers>
                  <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Opacity" Value="1"/>
                    <Setter Property="Cursor" Value="Hand"/>
                  </Trigger>
                </Style.Triggers>
              </Style>
            </Button.Style>
          </cc:CircleIconButton>
        </DataTemplate>

        <DataTemplate x:Key="_FotoCellTemplate">
          <Ellipse Height="50" Width="50" 
                       Margin="{StaticResource Margin}" HorizontalAlignment="Center">
            <Ellipse.Fill>
              <ImageBrush ImageSource="{Binding Persona.Imagen, Converter={StaticResource _BinaryImageConverter}}" Stretch="Uniform"/>
            </Ellipse.Fill>
          </Ellipse>
        </DataTemplate>
      </ControlTemplate.Resources>
      <Grid>
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto"/>
          <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel x:Name="_DateFilterStackPanel" Orientation="Horizontal" HorizontalAlignment="Right" Visibility="Visible" Grid.Column="1">
          <!--<cc:CircleIconButton
                    Icon="{StaticResource appbar_refresh}"
                    Width="31"
                    Margin="4,-40,0,0"
                    Height="31"
                    IconWidth="12"
                    IconHeight="12"
                    ToolTip="Resetear Fechas"
                    Command="{Binding DataContext.ResetearFechasCommand, ElementName=_Root}">
            <Button.Style>
              <Style TargetType="cc:CircleIconButton" BasedOn="{StaticResource {x:Type cc:CircleIconButton}}">
                <Setter Property="Opacity" Value="0.5"/>
                <Style.Triggers>
                  <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Opacity" Value="1"/>
                    <Setter Property="Cursor" Value="Hand"/>
                  </Trigger>
                </Style.Triggers>
              </Style>
            </Button.Style>
          </cc:CircleIconButton>
          <DatePicker Margin="4,-40,2,0" VerticalAlignment="Center"
                    SelectedDate="{Binding DataContext.FechaDeInicio, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, ElementName=_Root}"
                    ToolTip="Fecha de inicio del filtro (no actúa si está vacío)"/>
          <TextBlock Margin="0,-40,0,0" FontFamily="Courier" FontSize="16" VerticalAlignment="Center">-</TextBlock>
          <DatePicker  Margin="2,-40,4,0" VerticalAlignment="Center" 
                    SelectedDate="{Binding DataContext.FechaDeFin, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, ElementName=_Root}" 
                    ToolTip="Fecha de fin del filtro (no actúa si está vacío)"/>-->

          <!-- Botón para cambiar template -->
          <cc:CircleIconButton 
            Click="CircleIconButton_Click" >
            <cc:CircleIconButton.Style>
              <Style TargetType="cc:CircleIconButton" BasedOn="{StaticResource {x:Type cc:CircleIconButton}}">
                <Setter Property="Foreground" Value="#645C5C"/>
                <Setter Property="Icon" Value="{StaticResource appbar_calendar}"/>
                <Setter Property="Margin" Value="4,-40,4,0"/>
                <Setter Property="HorizontalAlignment" Value="Right"/>
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="IconWidth" Value="23"/>
                <Setter Property="IconHeight" Value="23"/>
                <Setter Property="Height" Value="35"/>
                <Setter Property="Width" Value="35"/>
                <Setter Property="VerticalAlignment" Value="Top"/>
                <!--<Style.Triggers>
                <DataTrigger Binding="{Binding ElementName=_ToggleCalendarStyleCheckbox, Path=IsChecked}" Value="True">
                  <Setter Property="Icon" Value="{StaticResource appbar_calendar}"/>
                  <Setter Property="Margin" Value="4,-40,4,0"/>
                </DataTrigger>
              </Style.Triggers>-->
              </Style>
            </cc:CircleIconButton.Style>
          </cc:CircleIconButton>
        </StackPanel>

        <DataGrid 
          BorderThickness="1"
          Grid.Row="1"
          Margin="6,2,6,2"
          CanUserResizeColumns="False"
          Style="{StaticResource DGHeaderStyle}"
          ItemsSource="{Binding Path=Appointments,
              RelativeSource={RelativeSource Mode=FindAncestor,
                                  AncestorType={x:Type  CustomControls:CustomCalendar}}}">
          <DataGrid.Resources>
            <DataTemplate x:Key="_HeaderTemplate" >
              <TextBlock Text="{Binding}" Margin="{StaticResource Margin}"/>
            </DataTemplate>
          </DataGrid.Resources>
          <DataGrid.CellStyle>
            <Style TargetType="DataGridCell">
              <Setter Property="BorderThickness" Value="0"/>
              <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                  <Setter Property="Background" Value="Transparent" />
                  <Setter Property="Foreground" Value="Black" />
                </Trigger>
              </Style.Triggers>
            </Style>
          </DataGrid.CellStyle>
          <DataGrid.RowStyle>
            <Style TargetType="DataGridRow">
              <Setter Property="BorderThickness" Value="0"/>
              <Setter Property="VerticalContentAlignment" Value="Center"/>
              <Setter Property="FontSize" Value="13"/>
              <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                  <Setter Property="Background" Value="#D95796BE"/>
                  <Setter Property="BorderThickness" Value="0" />
                  <Setter Property="Foreground" Value="Black"/>
                </Trigger>
                <Trigger Property="IsMouseOver" Value="True">
                  <Setter Property="BorderThickness" Value="0"/>
                  <Setter Property="Background" Value="#D972BCE9"/>
                  <Setter Property="Foreground" Value="Black"/>
                </Trigger>
              </Style.Triggers>
            </Style>
          </DataGrid.RowStyle>
          <DataGrid.Columns>
            <DataGridTemplateColumn Header="Foto" 
                                  HeaderTemplate="{StaticResource _HeaderTemplate}" 
                                  CellTemplate="{StaticResource _FotoCellTemplate}"/>

            <DataGridTemplateColumn Header="Fecha" HeaderTemplate="{StaticResource _HeaderTemplate}">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <TextBlock HorizontalAlignment="Left"
                      Width="120"
                      VerticalAlignment="Center"
                      FontSize="14"
                      Text="{Binding Fecha, StringFormat=d}"
                      Padding="{StaticResource Margin}"
                             Margin="{StaticResource Margin}"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

            <DataGridTemplateColumn Header="Hora" HeaderTemplate="{StaticResource _HeaderTemplate}">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <TextBlock HorizontalAlignment="Left" 
                             FontSize="14"
                             VerticalAlignment="Center"
                             Margin="{StaticResource Margin}">
                  <Run Text="{Binding Hora}"/>
                  <Run Text=":"/>
                  <Run Text="{Binding Minutos}"/>
                  </TextBlock>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

            <DataGridTemplateColumn Header="Asistente" HeaderTemplate="{StaticResource _HeaderTemplate}">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <TextBlock Text="{Binding Asistente.Nombre}"
                             FontSize="14" 
                             Margin="{StaticResource Margin}"
                             Padding="{StaticResource Margin}"
                             VerticalAlignment="Center" HorizontalAlignment="Left" />
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

            <DataGridTemplateColumn Header="Sala" Width="*" HeaderTemplate="{StaticResource _HeaderTemplate}">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <TextBlock Text="{Binding Sala}" 
                             Margin="{StaticResource Margin}"
                             Padding="{StaticResource Margin}"
                             FontSize="14"
                             VerticalAlignment="Center" HorizontalAlignment="Left" />
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

            <DataGridTemplateColumn Header="Editar"
                                    HeaderTemplate="{StaticResource _HeaderTemplate}" 
                                    CellTemplate="{StaticResource _EditarButtonCellTemplate}"/>
            <DataGridTemplateColumn Header="Ir"  
                                    HeaderTemplate="{StaticResource _HeaderTemplate}" 
                                    CellTemplate="{StaticResource _IrButtonCellTemplate}"/>
          </DataGrid.Columns>
        </DataGrid>
      </Grid>

    </ControlTemplate>

    <Style x:Key="_EditarCitasCalendarStyle" TargetType="{x:Type CustomControls:CustomCalendar}">
      <Setter Property="Template" Value="{StaticResource _CalendarioCalendarStyle}"/>
      <Style.Triggers>
        <DataTrigger Binding="{Binding ElementName=_ToggleCalendarStyleCheckbox,Path=IsChecked}" Value="True">
          <Setter Property="Template" Value="{StaticResource _ListadoCalendarStyle}"/>
        </DataTrigger>
      </Style.Triggers>
    </Style>
  </UserControl.Resources>

  <Grid Margin="0,39,0,0">
    <!-- Magic CheckBox para cambiar template del calendario --><commit_msg>ajustar márgenes<commit_after>﻿<UserControl x:Class="Gama.Atenciones.Wpf.Views.EditarCitasView"
             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:Gama.Atenciones.Wpf.Views"
             xmlns:designData="clr-namespace:Gama.Atenciones.Wpf.DesignTimeData"
             xmlns:CustomControls="clr-namespace:Gama.Atenciones.Wpf.Controls"
             xmlns:Converters="clr-namespace:Gama.Atenciones.Wpf.Converters"
             xmlns:cc="clr-namespace:Gama.Common.CustomControls;assembly=Gama.Common"
             xmlns:coreControls="clr-namespace:Core.Controls;assembly=Core"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:prism="http://prismlibrary.com/"           
             xmlns:coreUtil="clr-namespace:Core.Util;assembly=Core"
             mc:Ignorable="d"
             x:Name="_Root"
             d:DataContext="{d:DesignInstance Type=designData:EditarCitasViewModelDTD, IsDesignTimeCreatable=True}"  
             d:DesignWidth="1499.337" 
             d:DesignHeight="1028.796">
  <UserControl.Resources>
    <Style x:Key="_CircleIconButtonStyle"
      TargetType="cc:CircleIconButton" BasedOn="{StaticResource {x:Type cc:CircleIconButton}}">
      <Setter Property="Opacity" Value="0.5"/>
      <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
          <Setter Property="Opacity" Value="1"/>
          <Setter Property="Cursor" Value="Hand"/>
        </Trigger>
      </Style.Triggers>
    </Style>

    <Converters:DateConverter x:Key="DateConverter"/>

    <coreUtil:TwoParameterCommandConverter x:Key="_TwoParameterCommandConverter"/>

    <ControlTemplate x:Key="_CalendarioCalendarStyle"  TargetType="{x:Type CustomControls:CustomCalendar}">
      <ControlTemplate.Resources>
        <Converters:AppointmentsConverter x:Key="AppointmentsConverter"/>
        <Converters:MonthNameConverter x:Key="MonthNameConverter"/>
      </ControlTemplate.Resources>

      <Border Background="{TemplateBinding Background}"
                  BorderBrush="{TemplateBinding BorderBrush}"
                  BorderThickness="{TemplateBinding BorderThickness}">
        <Grid>
          <Grid.RowDefinitions>
            <RowDefinition Height="10"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
          </Grid.RowDefinitions>
          <Grid>
            <Button x:Name="_ToggleDateFilterButton" 
              Command="{Binding ToggleNavegacionCommand,
                  RelativeSource={RelativeSource AncestorType={x:Type CustomControls:CustomCalendar}}}"
              VerticalAlignment="Top"
              HorizontalAlignment="Right" 
              Panel.ZIndex="9999"
                  Cursor="Hand"
                  ToolTip="Ocultar botones de navegación"
              Margin="0,-23,137,0" 
              BorderThickness="0"
              BorderBrush="Transparent"
              Foreground="Blue"
              Background="Transparent">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource _TwoParameterCommandConverter}">
                  <Binding ElementName="_ToggleDateFilterButton"/>
                  <Binding ElementName="_NavegationStackPanel"/>
                  <Binding ElementName="_Calendario"/>
                  <Binding ElementName="_OtherToggleButton"/>
                </MultiBinding>
              </Button.CommandParameter>
              <Grid>
                <Rectangle Width="20" Height="20" Stroke="Black" >
                  <Rectangle.Fill>
                    <VisualBrush Visual="{StaticResource appbar_3d_3ds}" Stretch="Uniform"/>
                  </Rectangle.Fill>
                </Rectangle>
              </Grid>
              <Button.Style>
                <Style TargetType="Button">
                  <Setter Property="Template">
                    <Setter.Value>
                      <ControlTemplate TargetType="Button">
                        <Border Background="Transparent">
                          <ContentPresenter/>
                        </Border>
                      </ControlTemplate>
                    </Setter.Value>
                  </Setter>
                </Style>
              </Button.Style>
            </Button>

            <StackPanel x:Name="_NavegationStackPanel" Orientation="Horizontal" HorizontalAlignment="Right">
              <!-- Magic CheckBox para cambiar template del calendario -->

              <!-- Botón para cambiar template -->
              <cc:CircleIconButton Click="CircleIconButton_Click" >
                <cc:CircleIconButton.Style>
                  <Style TargetType="cc:CircleIconButton" BasedOn="{StaticResource {x:Type cc:CircleIconButton}}">
                    <Setter Property="Foreground" Value="#645C5C"/>
                    <Setter Property="Icon" Value="{StaticResource appbar_lines_horizontal_4}"/>
                    <Setter Property="Margin" Value="4,-30,0,0"/>
                    <Setter Property="HorizontalAlignment" Value="Right"/>
                    <Setter Property="BorderThickness" Value="0"/>
                    <Setter Property="IconWidth" Value="22"/>
                    <Setter Property="IconHeight" Value="22"/>
                    <Setter Property="Height" Value="35"/>
                    <Setter Property="Width" Value="35"/>
                    <Setter Property="VerticalAlignment" Value="Top"/>
                    <Style.Triggers>
                      <DataTrigger Binding="{Binding ElementName=_ToggleCalendarStyleCheckbox, Path=IsChecked}" Value="True">
                        <Setter Property="Icon" Value="{StaticResource appbar_calendar}"/>
                        <Setter Property="Margin" Value="4,-30,4,0"/>
                      </DataTrigger>
                    </Style.Triggers>
                  </Style>
                </cc:CircleIconButton.Style>
              </cc:CircleIconButton>

              <cc:CircleIconButton x:Name="_SemanaAnteriorButton"
                Command="{Binding SemanaAnteriorCommand,
                    RelativeSource={RelativeSource AncestorType={x:Type CustomControls:CustomCalendar}}}"
                    Icon="{StaticResource appbar_arrow_left}"
                    Margin="0,-40,0,0"/>
              <cc:CircleIconButton  x:Name="_SemanaSiguienteButton"
                Command="{Binding SemanaSiguienteCommand,
                    RelativeSource={RelativeSource AncestorType={x:Type CustomControls:CustomCalendar}}}"
                    Icon="{StaticResource appbar_arrow_right}"
                    Margin="0,-40,0,0" />
            </StackPanel>

            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
            </StackPanel>
          </Grid>

          <!-- Nombres de los días: Lunes, martes...-->
          <ItemsControl Grid.Row="1" Margin="-1,0,0,0"
                ItemsSource="{Binding DayNames, RelativeSource={RelativeSource FindAncestor, 
					        AncestorType={x:Type  CustomControls:CustomCalendar}}}" >
            <ItemsControl.ItemTemplate>
              <DataTemplate>
                <TextBlock TextAlignment="Center" Text="{Binding}" 
                               Foreground="White" FontWeight="Light" FontSize="13"
                               Margin="0"
                               Padding="4">
                  <TextBlock.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                      <GradientStop Color="#FF1B1B1B" Offset="0"/>
                      <GradientStop Color="#1B1B1B" Offset="1"/>
                    </LinearGradientBrush>
                  </TextBlock.Background>
                </TextBlock>
              </DataTemplate>
            </ItemsControl.ItemTemplate>
            <ItemsControl.ItemsPanel>
              <ItemsPanelTemplate>
                <UniformGrid Rows="1" Columns="7" Margin="4,0,4,0"/>
              </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
          </ItemsControl>
          <!--
            Other Toggle Button
          -->
          <Button x:Name="_OtherToggleButton"  Grid.Row="1"
              Command="{Binding ToggleNavegacionCommand,
                  RelativeSource={RelativeSource AncestorType={x:Type CustomControls:CustomCalendar}}}"
              VerticalAlignment="Top"
              HorizontalAlignment="Right" 
                  Visibility="Collapsed"
                  Cursor="Hand"
                  ToolTip="Mostrar botones de navegación"
              Panel.ZIndex="9999"
              Margin="0,-4,2,0" 
              BorderThickness="0"
              BorderBrush="Transparent"
              Foreground="Blue"
              RenderTransformOrigin="0.5,0.5"
              Background="Transparent">
            <Button.CommandParameter>
              <MultiBinding Converter="{StaticResource _TwoParameterCommandConverter}">
                <Binding ElementName="_ToggleDateFilterButton"/>
                <Binding ElementName="_NavegationStackPanel"/>
                <Binding ElementName="_Calendario"/>
                <Binding ElementName="_OtherToggleButton"/>
              </MultiBinding>
            </Button.CommandParameter>
            <Button.RenderTransform>
              <RotateTransform Angle="180" />
            </Button.RenderTransform>
            <Grid>
              <Rectangle Width="20" Height="20" Stroke="Black" >
                <Rectangle.Fill>
                  <VisualBrush Visual="{StaticResource appbar_3d_3ds}" Stretch="Uniform"/>
                </Rectangle.Fill>
              </Rectangle>
              <Rectangle Width="20" 
                           Height="20" 
                           Stroke="#D124CA" 
                           Fill="#83AE3D9A">
              </Rectangle>
            </Grid>
            <Button.Style>
              <Style TargetType="Button">
                <Setter Property="Template">
                  <Setter.Value>
                    <ControlTemplate TargetType="Button">
                      <Border Background="Transparent">
                        <ContentPresenter/>
                      </Border>
                    </ControlTemplate>
                  </Setter.Value>
                </Setter>
              </Style>
            </Button.Style>
          </Button>

          <ItemsControl Grid.Row="2" 
                            ItemsSource="{Binding Days, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged,
                              RelativeSource={RelativeSource FindAncestor, 
					                     AncestorType={x:Type  CustomControls:CustomCalendar}}}">
            <ItemsControl.ItemTemplate>
              <DataTemplate>
                <!-- -->
                <!-- Box -->
                <!-- -->
                <!--<Border BorderBrush="Black" BorderThickness="0.5" Padding="0" Margin="1">-->
                <Border Name="InnerBorder" BorderBrush="Black" BorderThickness="1" Margin="1">
                  <Border.Style>
                    <Style TargetType="{x:Type Border}">
                      <Setter Property="BorderBrush" Value="Black"/>
                      <Style.Triggers>
                        <!--Current Day-->
                        <DataTrigger Binding="{Binding IsToday}" Value="true">
                          <Setter Property="Border.Background">
                            <Setter.Value>
                              <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="#ECB5B5B5" Offset="0"/>
                                <GradientStop Color="#D99D9D9D" Offset="1"/>
                              </LinearGradientBrush>
                            </Setter.Value>
                          </Setter>
                        </DataTrigger>
                      </Style.Triggers>
                    </Style>
                  </Border.Style>

                  <Grid>
                    <Grid.Style>
                      <Style TargetType="Grid">
                        <Style.Triggers>
                          <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" Value="True">
                            <Setter Property="Background" Value="#D9B66373"/>
                          </DataTrigger>
                          <DataTrigger Binding="{Binding IsTargetMonth}" Value="False">
                            <Setter Property="Background" Value="LightGray"/>
                          </DataTrigger>
                        </Style.Triggers>
                      </Style>
                    </Grid.Style>
                    <Grid.RowDefinitions>
                      <RowDefinition Height="Auto"/>
                      <RowDefinition />
                    </Grid.RowDefinitions>

                    <!-- Mes en texto (ENE, FEB, ...) -->
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                      <TextBlock TextAlignment="Left" VerticalAlignment="Center" Background="#FF307DBB"
                                       Padding="4,2,6,4"
                                       Margin="2,-4,0,0"
                                       Foreground="White" 
                                       Text="{Binding Date.Month, Converter={StaticResource MonthNameConverter}}"/>
                    </StackPanel>

                    <!-- -->
                    <!-- Nueva Cita y Día del mes -->
                    <!-- -->
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                      <!-- Nueva Cita -->
                      <!--<cc:CircleIconButton Background="Transparent" FontWeight="Light" BorderThickness="0"
                                    VerticalContentAlignment="Top"
                                    Icon="{StaticResource appbar_add}"
                                    Width="20" Height="20"
                                    IconHeight="8" IconWidth="8"
                                    Margin="0,0,0,0" FontSize="14"
                                    Padding="0"
                                    Command="{Binding DataContext.NuevaCitaCommand,   
                                      RelativeSource={RelativeSource FindAncestor, 
					                              AncestorType={x:Type UserControl}}}" 
                                    CommandParameter="{Binding}">
                          +
                        </cc:CircleIconButton>-->

                      <!-- Día del mes -->
                      <TextBlock TextAlignment="Right" 
                                       Text="{Binding Date, Converter={StaticResource DateConverter}, ConverterParameter=DAY}" 
                                       FontSize="12" Margin="4,2,4,4" >
                        <TextBlock.Style>
                          <Style TargetType="{x:Type TextBlock}">
                            <Style.Triggers>
                              <DataTrigger Binding="{Binding IsTargetMonth}" Value="false">
                                <Setter Property="TextBlock.Foreground" Value="Gray"></Setter>
                              </DataTrigger>
                            </Style.Triggers>
                          </Style>
                        </TextBlock.Style>
                      </TextBlock>
                    </StackPanel>

                    <!-- -->
                    <!-- Lista de Appointments -->
                    <!-- -->
                    <coreControls:UnselectableListBox
                              x:Name="PART_AppointmentsListBox"
                              Grid.Row="1"
                              Background="Transparent"
                              BorderBrush="Transparent"
                              HorizontalContentAlignment="Stretch">
                      <ListBox.ItemsSource>
                        <MultiBinding Converter="{StaticResource AppointmentsConverter}">
                          <Binding RelativeSource="{RelativeSource Mode=FindAncestor,
                                  AncestorType={x:Type  CustomControls:CustomCalendar}}" Path="Appointments"/>
                          <Binding RelativeSource="{RelativeSource Mode=Self}" Path="DataContext"/>
                        </MultiBinding>
                      </ListBox.ItemsSource>
                      <ListBox.ItemTemplate>
                        <DataTemplate>
                          <Border Background="#FFDFE8F5" 
                                        BorderBrush="#FF5177A8" BorderThickness="0,2,0,2" CornerRadius="1" Margin="2">
                            <Grid>
                              <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto"/>
                              </Grid.ColumnDefinitions>

                              <!--                        -->
                              <!-- Contenido de cada cita -->
                              <!--                        -->
                              <Grid>
                                <Grid.ColumnDefinitions>
                                  <ColumnDefinition Width="Auto"/>
                                  <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                  <RowDefinition Height="Auto"/>
                                  <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>

                                <TextBlock Grid.Row="0"
                                            Margin="4,2,4,2" 
                                            HorizontalAlignment="Left" 
                                            VerticalAlignment="Center">
                                            <Run Text="{Binding Hora}"/>
                                            <Run Text=":" />
                                            <Run Text="{Binding Minutos}"/>
                                </TextBlock>

                                <TextBlock Grid.Row="1" Text="{Binding Persona.Nombre}" Margin="4,2,4,2"/>

                                <cc:CircleIconButton
                                              Grid.Column="1"
                                              Icon="{StaticResource appbar_archive}"
                                              Width="24" Height="24"
                                              IconHeight="7" IconWidth="7"
                                              Margin="4,2,4,2"
                                              HorizontalAlignment="Right"
                                              VerticalAlignment="Center"
                                              Padding="2,0,2,0"
                                              BorderThickness="0"
                                              FontSize="14"
                                              Background="#FF3078A5"
                                              Foreground="White"
                                              FontWeight="Bold"
                                              Command="{Binding DataContext.NuevaAtencionCommand, 
                                                RelativeSource={RelativeSource FindAncestor, 
					                                          AncestorType={x:Type UserControl}}}"
                                              CommandParameter="{Binding}"
                                              Style="{StaticResource _CircleIconButtonStyle}"/>
                                <cc:CircleIconButton
                                            Grid.Column="1"
                                            Grid.Row="1"
                                              Icon="{StaticResource appbar_edit}"
                                              Width="24" Height="24"
                                              IconHeight="7" IconWidth="7"
                                              Margin="4,2,4,2" 
                                              HorizontalAlignment="Right"
                                              VerticalAlignment="Center"
                                              Padding="2,0,2,0"
                                              BorderThickness="0"
                                              FontSize="14"
                                              Background="#FF3078A5"
                                              Foreground="White"
                                              FontWeight="Bold"
                                              Command="{Binding DataContext.EditarCitaCommand, 
                                                RelativeSource={RelativeSource FindAncestor, 
					                                          AncestorType={x:Type UserControl}}}"
                                              CommandParameter="{Binding}"
                                              Style="{StaticResource _CircleIconButtonStyle}"/>
                              </Grid>
                            </Grid>
                          </Border>
                        </DataTemplate>
                      </ListBox.ItemTemplate>
                      <ListBox.Resources>
                        <Style TargetType="{x:Type ListBoxItem}">
                          <Setter Property="Template">
                            <Setter.Value>
                              <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                <Border x:Name="_ListBoxItemBorder"
                                          BorderBrush="{TemplateBinding BorderBrush}"
                                          BorderThickness="{TemplateBinding BorderThickness}"
                                          Background="{TemplateBinding Background}"
                                          Padding="{TemplateBinding Padding}"
                                          SnapsToDevicePixels="true">
                                  <ContentPresenter 
                                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                                </Border>
                                <ControlTemplate.Triggers>
                                  <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                      <Condition Property="Selector.IsSelectionActive" Value="False" />
                                      <Condition Property="IsSelected" Value="True" />
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Background" TargetName="_ListBoxItemBorder" Value="#8BB3B6" />
                                  </MultiTrigger>
                                  <MultiTrigger>
                                    <MultiTrigger.Conditions>
                                      <Condition Property="Selector.IsSelectionActive" Value="True" />
                                      <Condition Property="IsSelected" Value="True" />
                                    </MultiTrigger.Conditions>
                                    <Setter Property="Background" TargetName="_ListBoxItemBorder" Value="#8BB3B6" />
                                  </MultiTrigger>
                                </ControlTemplate.Triggers>
                              </ControlTemplate>
                            </Setter.Value>
                          </Setter>
                        </Style>
                      </ListBox.Resources>
                    </coreControls:UnselectableListBox>
                    <Grid.InputBindings>
                      <MouseBinding MouseAction="LeftDoubleClick"
                                            Command="{Binding DataContext.NuevaCitaCommand, RelativeSource={RelativeSource FindAncestor, 
					                              AncestorType={x:Type UserControl}}}" 
                                    CommandParameter="{Binding}"/>
                    </Grid.InputBindings>
                  </Grid>
                </Border>
                <!--</Border>-->
              </DataTemplate>
            </ItemsControl.ItemTemplate>
            <ItemsControl.ItemsPanel>
              <ItemsPanelTemplate>
                <UniformGrid Rows="3" Columns="7"  Margin="2,0,2,0"/>
              </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
          </ItemsControl>
        </Grid>
      </Border>
    </ControlTemplate>

    <ControlTemplate x:Key="_ListadoCalendarStyle"  TargetType="{x:Type  CustomControls:CustomCalendar}">
      <ControlTemplate.Resources>
        <Converters:BinaryImageConverter x:Key="_BinaryImageConverter" />

        <Style x:Key="DGCHeaderStyle" TargetType="DataGridColumnHeader">
          <Setter Property="Height" Value="38"/>
          <Setter Property="Background" Value="LightBlue" />
          <Setter Property="Foreground" Value="Black"/>
          <Setter Property="FontSize" Value="15" />
          <Setter Property="FontWeight" Value="DemiBold"/>
          <Setter Property="Margin" Value="0"/>
        </Style>

        <Style x:Key="DGHeaderStyle" TargetType="{x:Type DataGrid}">
          <Setter Property="ColumnHeaderStyle" Value="{StaticResource DGCHeaderStyle}"/>
          <Setter Property="RowHeaderWidth" Value="0"/>
          <Setter Property="GridLinesVisibility" Value="None"/>
          <Setter Property="AlternatingRowBackground" Value="#B99BA5AB"/>
          <Setter Property="AutoGenerateColumns" Value="False"/>
          <Setter Property="IsReadOnly" Value="True"/>
          <Setter Property="Margin" Value="0"/>
        </Style>

        <DataTemplate x:Key="_EditarButtonCellTemplate">
          <cc:CircleIconButton
                      Icon="{StaticResource appbar_edit}"
                      Width="36"
                      Height="36"
                      IconWidth="13"
                      IconHeight="13"
                      Margin="{StaticResource Margin}"
                      Command="{Binding ElementName=_Root, Path=DataContext.EditarCitaCommand}"
                      CommandParameter="{Binding}">
            <Button.Style>
              <Style TargetType="cc:CircleIconButton" BasedOn="{StaticResource {x:Type cc:CircleIconButton}}">
                <Setter Property="Opacity" Value="0.5"/>
                <Style.Triggers>
                  <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Opacity" Value="1"/>
                    <Setter Property="Cursor" Value="Hand"/>
                  </Trigger>
                </Style.Triggers>
              </Style>
            </Button.Style>
          </cc:CircleIconButton>
        </DataTemplate>

        <DataTemplate x:Key="_FotoCellTemplate">
          <Ellipse Height="50" Width="50" 
                       Margin="{StaticResource Margin}" HorizontalAlignment="Center">
            <Ellipse.Fill>
              <ImageBrush ImageSource="{Binding Persona.Imagen, Converter={StaticResource _BinaryImageConverter}}" Stretch="Uniform"/>
            </Ellipse.Fill>
          </Ellipse>
        </DataTemplate>
      </ControlTemplate.Resources>
      <Grid>
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto"/>
          <RowDefinition />
        </Grid.RowDefinitions>
        <!-- Botón para cambiar template -->
        <cc:CircleIconButton 
            Click="CircleIconButton_Click" >
          <cc:CircleIconButton.Style>
            <Style TargetType="cc:CircleIconButton" BasedOn="{StaticResource {x:Type cc:CircleIconButton}}">
              <Setter Property="Foreground" Value="#645C5C"/>
              <Setter Property="Icon" Value="{StaticResource appbar_calendar}"/>
              <Setter Property="Margin" Value="4,-40,4,0"/>
              <Setter Property="HorizontalAlignment" Value="Right"/>
              <Setter Property="BorderThickness" Value="0"/>
              <Setter Property="IconWidth" Value="23"/>
              <Setter Property="IconHeight" Value="23"/>
              <Setter Property="Height" Value="35"/>
              <Setter Property="Width" Value="35"/>
              <Setter Property="VerticalAlignment" Value="Top"/>
              <!--<Style.Triggers>
                <DataTrigger Binding="{Binding ElementName=_ToggleCalendarStyleCheckbox, Path=IsChecked}" Value="True">
                  <Setter Property="Icon" Value="{StaticResource appbar_calendar}"/>
                  <Setter Property="Margin" Value="4,-40,4,0"/>
                </DataTrigger>
              </Style.Triggers>-->
            </Style>
          </cc:CircleIconButton.Style>
        </cc:CircleIconButton>

        <DataGrid 
          BorderThickness="1"
          Grid.Row="1"
          Margin="6,2,6,2"
          CanUserResizeColumns="False"
          Style="{StaticResource DGHeaderStyle}"
          ItemsSource="{Binding Path=Appointments,
              RelativeSource={RelativeSource Mode=FindAncestor,
                                  AncestorType={x:Type  CustomControls:CustomCalendar}}}">
          <DataGrid.Resources>
            <DataTemplate x:Key="_HeaderTemplate" >
              <TextBlock Text="{Binding}" Margin="{StaticResource Margin}"/>
            </DataTemplate>
          </DataGrid.Resources>
          <DataGrid.CellStyle>
            <Style TargetType="DataGridCell">
              <Setter Property="BorderThickness" Value="0"/>
              <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                  <Setter Property="Background" Value="Transparent" />
                  <Setter Property="Foreground" Value="Black" />
                </Trigger>
              </Style.Triggers>
            </Style>
          </DataGrid.CellStyle>
          <DataGrid.RowStyle>
            <Style TargetType="DataGridRow">
              <Setter Property="BorderThickness" Value="0"/>
              <Setter Property="VerticalContentAlignment" Value="Center"/>
              <Setter Property="FontSize" Value="13"/>
              <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                  <Setter Property="Background" Value="#D95796BE"/>
                  <Setter Property="BorderThickness" Value="0" />
                  <Setter Property="Foreground" Value="Black"/>
                </Trigger>
                <Trigger Property="IsMouseOver" Value="True">
                  <Setter Property="BorderThickness" Value="0"/>
                  <Setter Property="Background" Value="#D972BCE9"/>
                  <Setter Property="Foreground" Value="Black"/>
                </Trigger>
              </Style.Triggers>
            </Style>
          </DataGrid.RowStyle>
          <DataGrid.Columns>
            <DataGridTemplateColumn Header="Foto" 
                                  HeaderTemplate="{StaticResource _HeaderTemplate}" 
                                  CellTemplate="{StaticResource _FotoCellTemplate}"/>

            <DataGridTemplateColumn Header="Fecha" HeaderTemplate="{StaticResource _HeaderTemplate}">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <TextBlock HorizontalAlignment="Left"
                      Width="120"
                      VerticalAlignment="Center"
                      FontSize="14"
                      Text="{Binding Fecha, StringFormat=d}"
                      Padding="{StaticResource Margin}"
                             Margin="{StaticResource Margin}"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

            <DataGridTemplateColumn Header="Hora" HeaderTemplate="{StaticResource _HeaderTemplate}">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <TextBlock HorizontalAlignment="Left" 
                             FontSize="14"
                             VerticalAlignment="Center"
                             Margin="{StaticResource Margin}">
                  <Run Text="{Binding Hora}"/>
                  <Run Text=":"/>
                  <Run Text="{Binding Minutos}"/>
                  </TextBlock>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

            <DataGridTemplateColumn Header="Asistente" HeaderTemplate="{StaticResource _HeaderTemplate}">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <TextBlock Text="{Binding Asistente.Nombre}"
                             FontSize="14" 
                             Margin="{StaticResource Margin}"
                             Padding="{StaticResource Margin}"
                             VerticalAlignment="Center" HorizontalAlignment="Left" />
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

            <DataGridTemplateColumn Header="Sala" Width="*" HeaderTemplate="{StaticResource _HeaderTemplate}">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <TextBlock Text="{Binding Sala}" 
                             Margin="{StaticResource Margin}"
                             Padding="{StaticResource Margin}"
                             FontSize="14"
                             VerticalAlignment="Center" HorizontalAlignment="Left" />
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

            <DataGridTemplateColumn Header="Editar"
                                    HeaderTemplate="{StaticResource _HeaderTemplate}" 
                                    CellTemplate="{StaticResource _EditarButtonCellTemplate}"/>
          </DataGrid.Columns>
        </DataGrid>
      </Grid>

    </ControlTemplate>

    <Style x:Key="_EditarCitasCalendarStyle" TargetType="{x:Type CustomControls:CustomCalendar}">
      <Setter Property="Template" Value="{StaticResource _CalendarioCalendarStyle}"/>
      <Style.Triggers>
        <DataTrigger Binding="{Binding ElementName=_ToggleCalendarStyleCheckbox,Path=IsChecked}" Value="True">
          <Setter Property="Template" Value="{StaticResource _ListadoCalendarStyle}"/>
        </DataTrigger>
      </Style.Triggers>
    </Style>
  </UserControl.Resources>

  <Grid Margin="0,8,0,0">
    <!-- Magic CheckBox para cambiar template del calendario -->
{'fraction_non_alphanumeric': 0.10525740368715236, 'fraction_numerical': 0.011014991868585407, 'mean_word_length': 1.3222469057442081, 'pattern_counts': {'":': 4, '<': 963, '<?xml version=': 0, '>': 963, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 28}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 298, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2976591', 'n_tokens_mistral': 17183, 'n_tokens_neox': 15457, 'n_words': 2455}