title: Customized Datepicker does not popup calendar
body: <p>I have customized datepicker style, but for some reason when i click on the datepicker, the calendar does not popup and does not activate the mouseup subroutine.</p>
  
  <p>If I change the Button x:Name="Button" to Button x:Name="PART_Button" the calendar will popup, but the TextBlocks Content will show:"Show Calendar"</p>
  
  <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:controls="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"
  xmlns:iPodConv="clr-namespace:Custom_DatePicker.CustomDateConverter"
  xmlns:vsm="clr-namespace:System.Windows;assembly=PresentationFramework"&gt;        
      &lt;Style x:Key="CustomDatePickerStyle" TargetType="controls:DatePicker"&gt;
          &lt;Setter Property="IsTabStop" Value="False"/&gt;
          &lt;Setter Property="Background" Value="#FFFFFFFF"/&gt;
          &lt;Setter Property="Padding" Value="2"/&gt;
          &lt;!--Setter Property="SelectionBackground" Value="#FF444444"/--&gt;
          &lt;Setter Property="BorderBrush"&gt;
              &lt;Setter.Value&gt;
                  &lt;LinearGradientBrush EndPoint=".5,0" StartPoint=".5,1"&gt;
                      &lt;GradientStop Color="#FF617584" Offset="0"/&gt;
                      &lt;GradientStop Color="#FF718597" Offset="0.375"/&gt;
                      &lt;GradientStop Color="#FF8399A9" Offset="0.375"/&gt;
                      &lt;GradientStop Color="#FFA3AEB9" Offset="1"/&gt;
                  &lt;/LinearGradientBrush&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
          &lt;Setter Property="BorderThickness" Value="1"/&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="controls:DatePicker"&gt;
                  &lt;Grid x:Name="PART_Root"&gt;
                      &lt;Grid.Resources&gt;
                          &lt;SolidColorBrush x:Key="DisabledBrush" Color="#8CFFFFFF"/&gt;
                          &lt;ControlTemplate x:Key="DropDownButtonTemplate" TargetType="Button"&gt;
                              &lt;Grid&gt;
                                  &lt;vsm:VisualStateManager.VisualStateGroups&gt;
                                      &lt;vsm:VisualStateGroup x:Name="CommonStates"&gt;
                                          &lt;vsm:VisualStateGroup.Transitions&gt;
                                              &lt;vsm:VisualTransition GeneratedDuration="0"/&gt;
                                              &lt;vsm:VisualTransition GeneratedDuration="0:0:0.1" To="MouseOver"/&gt;
                                              &lt;vsm:VisualTransition GeneratedDuration="0:0:0.1" To="Pressed"/&gt;
                                          &lt;/vsm:VisualStateGroup.Transitions&gt;
                                          &lt;vsm:VisualState x:Name="Normal"/&gt;
                                          &lt;vsm:VisualState x:Name="MouseOver"&gt;
                                              &lt;Storyboard&gt;
                                                  &lt;ColorAnimation Duration="0" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="#FF448DCA"/&gt;
                                                  &lt;ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)"&gt;
                                                      &lt;SplineColorKeyFrame KeyTime="0" Value="#7FFFFFFF"/&gt;
                                                  &lt;/ColorAnimationUsingKeyFrames&gt;
                                                  &lt;ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)"&gt;
                                                      &lt;SplineColorKeyFrame KeyTime="0" Value="#CCFFFFFF"/&gt;
                                                  &lt;/ColorAnimationUsingKeyFrames&gt;
                                                  &lt;ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)"&gt;
                                                      &lt;SplineColorKeyFrame KeyTime="0" Value="#F2FFFFFF"/&gt;
                                                  &lt;/ColorAnimationUsingKeyFrames&gt;
                                              &lt;/Storyboard&gt;
                                          &lt;/vsm:VisualState&gt;
                                          &lt;vsm:VisualState x:Name="Pressed"&gt;
                                              &lt;Storyboard&gt;
                                                  &lt;ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"&gt;
                                                      &lt;SplineColorKeyFrame KeyTime="0" Value="#FF448DCA"/&gt;
                                                  &lt;/ColorAnimationUsingKeyFrames&gt;
                                                  &lt;DoubleAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="Highlight" Storyboard.TargetProperty="(UIElement.Opacity)"&gt;
                                                      &lt;SplineDoubleKeyFrame KeyTime="0" Value="1"/&gt;
                                                  &lt;/DoubleAnimationUsingKeyFrames&gt;
                                                  &lt;ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)"&gt;
                                                      &lt;SplineColorKeyFrame KeyTime="0" Value="#EAFFFFFF"/&gt;
                                                  &lt;/ColorAnimationUsingKeyFrames&gt;
                                                  &lt;ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)"&gt;
                                                      &lt;SplineColorKeyFrame KeyTime="0" Value="#C6FFFFFF"/&gt;
                                                  &lt;/ColorAnimationUsingKeyFrames&gt;
                                                  &lt;ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)"&gt;
                                                      &lt;SplineColorKeyFrame KeyTime="0" Value="#6BFFFFFF"/&gt;
                                                  &lt;/ColorAnimationUsingKeyFrames&gt;
                                                  &lt;ColorAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)"&gt;
                                                      &lt;SplineColorKeyFrame KeyTime="0" Value="#F4FFFFFF"/&gt;
                                                  &lt;/ColorAnimationUsingKeyFrames&gt;
                                              &lt;/Storyboard&gt;
                                          &lt;/vsm:VisualState&gt;
                                          &lt;vsm:VisualState x:Name="Disabled"&gt;
                                              &lt;Storyboard&gt;
                                                  &lt;DoubleAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="DisabledVisual" Storyboard.TargetProperty="(UIElement.Opacity)"&gt;
                                                      &lt;SplineDoubleKeyFrame KeyTime="0" Value="1"/&gt;
                                                  &lt;/DoubleAnimationUsingKeyFrames&gt;
                                              &lt;/Storyboard&gt;
                                          &lt;/vsm:VisualState&gt;
                                      &lt;/vsm:VisualStateGroup&gt;
                                  &lt;/vsm:VisualStateManager.VisualStateGroups&gt;
                                  &lt;Grid Height="48" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center" Width="59" Background="#11FFFFFF"&gt;
                                      &lt;Grid.ColumnDefinitions&gt;
                                          &lt;ColumnDefinition Width="6*"/&gt;
                                          &lt;ColumnDefinition Width="30*"/&gt;
                                          &lt;ColumnDefinition Width="30*"/&gt;
                                          &lt;ColumnDefinition Width="30*"/&gt;
                                      &lt;/Grid.ColumnDefinitions&gt;
                                      &lt;Grid.RowDefinitions&gt;
                                          &lt;RowDefinition Height="6*"/&gt;
                                          &lt;RowDefinition Height="20*"/&gt;
                                          &lt;RowDefinition Height="20*"/&gt;
                                          &lt;RowDefinition Height="30*"/&gt;
                                      &lt;/Grid.RowDefinitions&gt;
                                      &lt;Border x:Name="Highlight" Margin="-1" Opacity="0" Grid.ColumnSpan="4" Grid.Row="0" Grid.RowSpan="4" BorderBrush="#FF6DBDD1" BorderThickness="1" CornerRadius="0,0,1,1"/&gt;
                                      &lt;Border x:Name="Background" Margin="0,-1,0,0" Opacity="1" Grid.ColumnSpan="4" Grid.Row="1" Grid.RowSpan="3" Background="#FF1F3B53" BorderBrush="#FFFFFFFF" BorderThickness="1" CornerRadius=".5"/&gt;
                                      &lt;Border x:Name="BackgroundGradient" Margin="0,-1,0,0" Opacity="1" Grid.ColumnSpan="4" Grid.Row="1" Grid.RowSpan="3" BorderBrush="#BF000000" BorderThickness="1" CornerRadius=".5"&gt;
                                          &lt;Border.Background&gt;
                                              &lt;LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0"&gt;
                                                  &lt;GradientStop Color="#FFFFFFFF" Offset="0"/&gt;
                                                  &lt;GradientStop Color="#F9FFFFFF" Offset="0.375"/&gt;
                                                  &lt;GradientStop Color="#E5FFFFFF" Offset="0.625"/&gt;
                                                  &lt;GradientStop Color="#C6FFFFFF" Offset="1"/&gt;
                                              &lt;/LinearGradientBrush&gt;
                                          &lt;/Border.Background&gt;
                                      &lt;/Border&gt;
                                      &lt;Rectangle StrokeThickness="1" Grid.ColumnSpan="4" Grid.RowSpan="2" Margin="0,0,0,2"&gt;
                                          &lt;Rectangle.Stroke&gt;
                                              &lt;LinearGradientBrush EndPoint="0.48,-1" StartPoint="0.48,1.25"&gt;
                                                  &lt;GradientStop Color="#FF494949"/&gt;
                                                  &lt;GradientStop Color="#FF9F9F9F" Offset="1"/&gt;
                                              &lt;/LinearGradientBrush&gt;
                                          &lt;/Rectangle.Stroke&gt;
                                          &lt;Rectangle.Fill&gt;
                                              &lt;LinearGradientBrush EndPoint="0.3,-1.1" StartPoint="0.46,1.6"&gt;
                                                  &lt;GradientStop Color="#FFBD4A40"/&gt;
                                                  &lt;GradientStop Color="#FFEAAFAF" Offset="1"/&gt;
                                              &lt;/LinearGradientBrush&gt;
                                          &lt;/Rectangle.Fill&gt;
                                      &lt;/Rectangle&gt;
                                      &lt;TextBlock
                                                  HorizontalAlignment="Center" 
                                                  VerticalAlignment="Center" 
                                                  DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=.Content}"
                                                  Text="{Binding Converter={StaticResource DateTimeFormatter}, ConverterParameter=DOW}"
                                                  FontSize="11" Margin="0,0,0,3"
                                                  Grid.Column="0" 
                                                  Grid.ColumnSpan="4" 
                                                  Grid.Row="0" 
                                                  Grid.RowSpan="2" 
                                                  /&gt;
                                      &lt;TextBlock
                                                  HorizontalAlignment="Center" 
                                                  VerticalAlignment="Center" 
                                                  DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}"
                                                  Text="{Binding Converter={StaticResource DateTimeFormatter}, ConverterParameter=MMMM}"
                                                  FontSize="10" Margin="0,10,0,3"
                                                  Grid.Column="0" 
                                                  Grid.ColumnSpan="4" 
                                                  Grid.Row="1" 
                                                  Grid.RowSpan="2" 
                                                  /&gt;
                                      &lt;TextBlock
                                                  HorizontalAlignment="Center" 
                                                  VerticalAlignment="Bottom" 
                                                  DataContext="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}"
                                                  Text="{Binding Converter={StaticResource DateTimeFormatter}, ConverterParameter=dd}"
                                                  FontSize="26" Margin="0,0,0,-3" 
                                                  Grid.Column="0" 
                                                  Grid.ColumnSpan="4" 
                                                  Grid.Row="2" 
                                                  Grid.RowSpan="2" /&gt;
                                      &lt;Border x:Name="PART_DisabledVisual" Opacity="0" Grid.ColumnSpan="4" Grid.Row="0" Grid.RowSpan="4" BorderBrush="#B2FFFFFF" BorderThickness="1" CornerRadius="0,0,.5,.5"/&gt;
                                  &lt;/Grid&gt;
                              &lt;/Grid&gt;
                          &lt;/ControlTemplate&gt;
                      &lt;/Grid.Resources&gt;
                      &lt;Grid.ColumnDefinitions&gt;
                          &lt;ColumnDefinition Width="*"/&gt;
                          &lt;ColumnDefinition Width="Auto"/&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
                      &lt;vsm:VisualStateManager.VisualStateGroups&gt;
                          &lt;vsm:VisualStateGroup x:Name="CommonStates"&gt;
                              &lt;vsm:VisualState x:Name="Normal"/&gt;
                              &lt;vsm:VisualState x:Name="Disabled"&gt;
                                  &lt;Storyboard&gt;
                                      &lt;DoubleAnimation Duration="0" Storyboard.TargetName="DisabledVisual" Storyboard.TargetProperty="Opacity" To="1"/&gt;
                                  &lt;/Storyboard&gt;
                              &lt;/vsm:VisualState&gt;
                          &lt;/vsm:VisualStateGroup&gt;
                      &lt;/vsm:VisualStateManager.VisualStateGroups&gt;
                      &lt;Button x:Name="Button" Grid.Column="0" Grid.ColumnSpan="4"
                                  Content="{TemplateBinding SelectedDate}"
                                  Template="{StaticResource DropDownButtonTemplate}"
                                  Margin="2,0,2,0" 
                                  Width="60" 
                                  BorderBrush="{TemplateBinding BorderBrush}" 
                                  BorderThickness="{TemplateBinding BorderThickness}" 
                                  Foreground="{TemplateBinding Foreground}"/&gt;
                      &lt;Grid x:Name="DisabledVisual" IsHitTestVisible="False" Opacity="0" Grid.ColumnSpan="2"&gt;
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition Width="*"/&gt;
                              &lt;ColumnDefinition Width="Auto"/&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
                          &lt;Rectangle Fill="#8CFFFFFF" RadiusX="1" RadiusY="1"/&gt;
                          &lt;Rectangle Fill="#8CFFFFFF" RadiusX="1" RadiusY="1" Height="18" Margin="2,0,2,0" Width="24" Grid.Column="1"/&gt;
                      &lt;/Grid&gt;
  
                      &lt;Popup x:Name="PART_Popup"
                             PlacementTarget="{Binding ElementName=Button}"
                             Placement="Bottom" 
                             StaysOpen="False"
                             AllowsTransparency="True" 
                             PopupAnimation="Slide"
                             Focusable="True" /&gt;
                  &lt;/Grid&gt;
              &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>Any help will be appreciated.</p>