Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. WPF Toolkit DatePicker/Calender issue

WPF Toolkit DatePicker/Calender issue

Scheduled Pinned Locked Moved WPF
wpfhelpcsharpcsswcf
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bonkers123
    wrote on last edited by
    #1

    Hi, I have a DatePicker, where I set the CalendarStyle (I'm using mvvm). The issue is, when I select a day on the calender, nothing happens (Looks like the Click event just never fires, or something.) The Control looks as follow:

    <tool:DatePicker Grid.Column="1" Grid.Row="8" SelectedDate="{Binding BirthDate}" CalendarStyle="{DynamicResource CalenderStyleNew}"></tool:DatePicker>

    Where the style looks as follow:

    <Style TargetType="Controls:Calendar" x:Key="CalenderStyleNew">
    <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="Controls:Calendar">
    <StackPanel HorizontalAlignment="Center" x:Name="Root">
    <Controls:Calendar x:Name="Calendar" SelectedDate="{TemplateBinding SelectedDate}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
    Controls:Calendar.CalendarDayButtonStyle
    <Style>
    <Setter Property="Button.Height" Value="50"></Setter>
    <Setter Property="Button.Width" Value="50"></Setter>
    <Setter Property="Button.FontSize" Value="20"></Setter>
    </Style>
    </Controls:Calendar.CalendarDayButtonStyle>
    Controls:Calendar.CalendarButtonStyle
    <Style>
    <Setter Property="Button.Height" Value="50"></Setter>
    <Setter Property="Button.Width" Value="50"></Setter>
    <Setter Property="Button.FontSize" Value="20"></Setter>
    </Style>
    </Controls:Calendar.CalendarButtonStyle>
    </Controls:Calendar>
    </StackPanel>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>

    I need the buttons bigger, because it's a touch screen app... Test this in your app, and you'll see, nothing happens when you select a day... Any help would be much appreciated. Kind regards, Hugo

    B 1 Reply Last reply
    0
    • B bonkers123

      Hi, I have a DatePicker, where I set the CalendarStyle (I'm using mvvm). The issue is, when I select a day on the calender, nothing happens (Looks like the Click event just never fires, or something.) The Control looks as follow:

      <tool:DatePicker Grid.Column="1" Grid.Row="8" SelectedDate="{Binding BirthDate}" CalendarStyle="{DynamicResource CalenderStyleNew}"></tool:DatePicker>

      Where the style looks as follow:

      <Style TargetType="Controls:Calendar" x:Key="CalenderStyleNew">
      <Setter Property="Template">
      <Setter.Value>
      <ControlTemplate TargetType="Controls:Calendar">
      <StackPanel HorizontalAlignment="Center" x:Name="Root">
      <Controls:Calendar x:Name="Calendar" SelectedDate="{TemplateBinding SelectedDate}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
      Controls:Calendar.CalendarDayButtonStyle
      <Style>
      <Setter Property="Button.Height" Value="50"></Setter>
      <Setter Property="Button.Width" Value="50"></Setter>
      <Setter Property="Button.FontSize" Value="20"></Setter>
      </Style>
      </Controls:Calendar.CalendarDayButtonStyle>
      Controls:Calendar.CalendarButtonStyle
      <Style>
      <Setter Property="Button.Height" Value="50"></Setter>
      <Setter Property="Button.Width" Value="50"></Setter>
      <Setter Property="Button.FontSize" Value="20"></Setter>
      </Style>
      </Controls:Calendar.CalendarButtonStyle>
      </Controls:Calendar>
      </StackPanel>
      </ControlTemplate>
      </Setter.Value>
      </Setter>
      </Style>

      I need the buttons bigger, because it's a touch screen app... Test this in your app, and you'll see, nothing happens when you select a day... Any help would be much appreciated. Kind regards, Hugo

      B Offline
      B Offline
      bonkers123
      wrote on last edited by
      #2

      ok, after A LOT of struggling, I managed to make a work around... but, it's not pretty !!! An easier solution would be much appreciated. What I did, was the following:

      <Controls:DatePicker Grid.Column="1" Grid.Row="6" SelectedDate="{Binding BirthDate}" ViewModels:EmployeeViewModel.DatePickerGotFocus="{Binding}">
      Controls:DatePicker.CalendarStyle
      <Style TargetType="Controls:Calendar">
      <Setter Property="Template">
      <Setter.Value>
      <ControlTemplate TargetType="Controls:Calendar">
      <StackPanel HorizontalAlignment="Center" x:Name="Root">
      <Controls:Calendar x:Name="Calendar" ViewModels:EmployeeViewModel.OnCalenderLoaded="{Binding}" SelectedDate="{Binding BirthDate}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
      Controls:Calendar.CalendarDayButtonStyle
      <Style>
      <Setter Property="Button.Height" Value="50"></Setter>
      <Setter Property="Button.Width" Value="50"></Setter>
      <Setter Property="Button.FontSize" Value="20"></Setter>
      </Style>
      </Controls:Calendar.CalendarDayButtonStyle>
      Controls:Calendar.CalendarButtonStyle
      <Style>
      <Setter Property="Button.Height" Value="50"></Setter>
      <Setter Property="Button.Width" Value="50"></Setter>
      <Setter Property="Button.FontSize" Value="20"></Setter>
      </Style>
      </Controls:Calendar.CalendarButtonStyle>
      </Controls:Calendar>
      </StackPanel>
      </ControlTemplate>
      </Setter.Value>
      </Setter>
      </Style>
      </Controls:DatePicker.CalendarStyle>
      </Controls:DatePicker>

      Then I made attached properties for the DatePicker and Calendar as follow:

      private Calendar _calender;
      private DatePicker _datePicker;

      B 1 Reply Last reply
      0
      • B bonkers123

        ok, after A LOT of struggling, I managed to make a work around... but, it's not pretty !!! An easier solution would be much appreciated. What I did, was the following:

        <Controls:DatePicker Grid.Column="1" Grid.Row="6" SelectedDate="{Binding BirthDate}" ViewModels:EmployeeViewModel.DatePickerGotFocus="{Binding}">
        Controls:DatePicker.CalendarStyle
        <Style TargetType="Controls:Calendar">
        <Setter Property="Template">
        <Setter.Value>
        <ControlTemplate TargetType="Controls:Calendar">
        <StackPanel HorizontalAlignment="Center" x:Name="Root">
        <Controls:Calendar x:Name="Calendar" ViewModels:EmployeeViewModel.OnCalenderLoaded="{Binding}" SelectedDate="{Binding BirthDate}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
        Controls:Calendar.CalendarDayButtonStyle
        <Style>
        <Setter Property="Button.Height" Value="50"></Setter>
        <Setter Property="Button.Width" Value="50"></Setter>
        <Setter Property="Button.FontSize" Value="20"></Setter>
        </Style>
        </Controls:Calendar.CalendarDayButtonStyle>
        Controls:Calendar.CalendarButtonStyle
        <Style>
        <Setter Property="Button.Height" Value="50"></Setter>
        <Setter Property="Button.Width" Value="50"></Setter>
        <Setter Property="Button.FontSize" Value="20"></Setter>
        </Style>
        </Controls:Calendar.CalendarButtonStyle>
        </Controls:Calendar>
        </StackPanel>
        </ControlTemplate>
        </Setter.Value>
        </Setter>
        </Style>
        </Controls:DatePicker.CalendarStyle>
        </Controls:DatePicker>

        Then I made attached properties for the DatePicker and Calendar as follow:

        private Calendar _calender;
        private DatePicker _datePicker;

        B Offline
        B Offline
        bonkers123
        wrote on last edited by
        #3

        lol, I over complicated this a bit. The final solution I made was as follow:

        <tool:DatePicker Grid.Column="1" Grid.Row="8" SelectedDate="{Binding BirthDate}" ViewModels:PatronViewModel.DatePickerGotFocus="{Binding}" Height="34" FontSize="18">
        tool:DatePicker.LayoutTransform
        <ScaleTransform ScaleY="1.5" ScaleX="1.5"></ScaleTransform>
        </tool:DatePicker.LayoutTransform>
        tool:DatePicker.CalendarStyle
        <Style TargetType="tool:Calendar">
        <Setter Property="Template">
        <Setter.Value>
        <ControlTemplate TargetType="tool:Calendar">
        <StackPanel HorizontalAlignment="Center" x:Name="Root">
        <tool:Calendar x:Name="Calendar" ViewModels:PatronViewModel.OnCalenderLoaded="{Binding}" SelectedDate="{Binding BirthDate}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
        tool:Calendar.LayoutTransform
        <ScaleTransform ScaleX="2" ScaleY="2"></ScaleTransform>
        </tool:Calendar.LayoutTransform>
        </tool:Calendar>
        </StackPanel>
        </ControlTemplate>
        </Setter.Value>
        </Setter>
        </Style>
        </tool:DatePicker.CalendarStyle>
        </tool:DatePicker>

        So by simply scaling the DatePicker, I got a cool touch screen DatePicker....

        M 1 Reply Last reply
        0
        • B bonkers123

          lol, I over complicated this a bit. The final solution I made was as follow:

          <tool:DatePicker Grid.Column="1" Grid.Row="8" SelectedDate="{Binding BirthDate}" ViewModels:PatronViewModel.DatePickerGotFocus="{Binding}" Height="34" FontSize="18">
          tool:DatePicker.LayoutTransform
          <ScaleTransform ScaleY="1.5" ScaleX="1.5"></ScaleTransform>
          </tool:DatePicker.LayoutTransform>
          tool:DatePicker.CalendarStyle
          <Style TargetType="tool:Calendar">
          <Setter Property="Template">
          <Setter.Value>
          <ControlTemplate TargetType="tool:Calendar">
          <StackPanel HorizontalAlignment="Center" x:Name="Root">
          <tool:Calendar x:Name="Calendar" ViewModels:PatronViewModel.OnCalenderLoaded="{Binding}" SelectedDate="{Binding BirthDate}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
          tool:Calendar.LayoutTransform
          <ScaleTransform ScaleX="2" ScaleY="2"></ScaleTransform>
          </tool:Calendar.LayoutTransform>
          </tool:Calendar>
          </StackPanel>
          </ControlTemplate>
          </Setter.Value>
          </Setter>
          </Style>
          </tool:DatePicker.CalendarStyle>
          </tool:DatePicker>

          So by simply scaling the DatePicker, I got a cool touch screen DatePicker....

          M Offline
          M Offline
          Member 3423847
          wrote on last edited by
          #4

          I tried your code above. For some reason, when I select a date from the calendar popup, it doesn't close the popup or select a date. I removed all Bindings since I don't have a viewmodel. I am just trying this out before putting it in my project.

          B 1 Reply Last reply
          0
          • M Member 3423847

            I tried your code above. For some reason, when I select a date from the calendar popup, it doesn't close the popup or select a date. I removed all Bindings since I don't have a viewmodel. I am just trying this out before putting it in my project.

            B Offline
            B Offline
            bonkers123
            wrote on last edited by
            #5

            I remember having this problem.... I had to do some magic on the actual date time by hiding and showing the actual boxes....

            J 1 Reply Last reply
            0
            • B bonkers123

              I remember having this problem.... I had to do some magic on the actual date time by hiding and showing the actual boxes....

              J Offline
              J Offline
              Jimmy Carter 0
              wrote on last edited by
              #6

              I have the same problem (selecting date does nothing and I am not using view model) I was hoping you could elaborate on the "magic" that you used to resolve this problem. Thanks.

              B 1 Reply Last reply
              0
              • J Jimmy Carter 0

                I have the same problem (selecting date does nothing and I am not using view model) I was hoping you could elaborate on the "magic" that you used to resolve this problem. Thanks.

                B Offline
                B Offline
                bonkers123
                wrote on last edited by
                #7

                You don't even want to know what I had to do to fix this !!!! It's INSANE !

                T 1 Reply Last reply
                0
                • B bonkers123

                  You don't even want to know what I had to do to fix this !!!! It's INSANE !

                  T Offline
                  T Offline
                  tronix01
                  wrote on last edited by
                  #8

                  hi bonkers, i thank you very much!!!!. your snippet helps me to solve my DatePicker SelectedDate - Binding problem! here is my solution. just override the ControlTemplate of the DatePicker-Control and bind the SelectedDate of the PopupCalendar.

                  <Popup Name="Part_CalendarPopup"
                  Margin="0,22,-22,-12"
                  HorizontalAlignment="Right"
                  PlacementTarget="{Binding ElementName=Part_CalendarButton}" StaysOpen="False">
                  <Grid Name="Part_CalendarGrid" Background="White">
                  <cal:Calendar
                  SelectedDate="{Binding SelectedDate, Mode=TwoWay}"
                  Height="160" Width="160"
                  FooterVisibility="Collapsed" WeekColumnVisibility="Collapsed"
                  FontSize="9"/>
                  </Grid>
                  </Popup>

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups