Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 810199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:50:48+00:00 2026-05-15T00:50:48+00:00

My C#/WPF project needs a calendar. We’re going to be using it to pick

  • 0

My C#/WPF project needs a calendar. We’re going to be using it to pick a range of dates for appointment scheduling. I’m told the default calendar is too small to be used by some of our reps so I’ve been working on resizing it.

<toolkit:Calendar Grid.Row="1" x:Name="DateWindowCalendar" 
   BorderBrush="White" BorderThickness="0"
   Style="{StaticResource PopupCalendarStyle}" 
   DisplayMode="Month" SelectionMode="SingleRange"
   DisplayDateStart="{Binding FirstDayOfMonth}"
   AutomationProperties.AutomationId="ToolkitCalendarId"  
   VerticalAlignment="Top">
 </toolkit:Calendar>

And I’ve created this styling:

<Style x:Key="PopupCalendarStyle" TargetType="toolkit:Calendar">
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="toolkit:Calendar">
        <StackPanel Margin="0" HorizontalAlignment="Center" x:Name="Root">
          <toolkit:Calendar x:Name="Calendar" 
             SelectedDate="{TemplateBinding SelectedDate}"
             DisplayDateStart="{TemplateBinding DisplayDateStart}"
             SelectionMode="{TemplateBinding SelectionMode}"
             Background="{TemplateBinding Background}" 
             BorderBrush="{TemplateBinding BorderBrush}"
             BorderThickness="{TemplateBinding BorderThickness}"
             SelectedDatesChanged="Calendar_SelectedDatesChanged">

             <toolkit:Calendar.CalendarDayButtonStyle>
               <Style>
                 <Setter Property="Button.Height" Value="34"/>
                 <Setter Property="Button.Width" Value="34" />
                 <Setter Property="Button.FontSize" Value="16" />
               </Style>
              </toolkit:Calendar.CalendarDayButtonStyle>

              <toolkit:Calendar.CalendarButtonStyle>
                <Style>
                  <Setter Property="Button.Height" Value="34"/>
                  <Setter Property="Button.Width" Value="34"/>
                  <Setter Property="Button.FontSize" Value="16"/>
                </Style>
              </toolkit:Calendar.CalendarButtonStyle>

            </toolkit:Calendar>
          </StackPanel>
        </ControlTemplate>
      </Setter.Value>
    </Setter>               
  </Style>

Everything is almost perfect. I specify my range, I can track the selected dates (granted using the SelectedDatesChanged event instead of the SelectedDates property.

The problem is I also need to be able to set blackout dates (usually the period between first of the month and today although sometimes first of the month to a few days from now).

Without the styling, this works:

DateWindowCalendar.BlackoutDates.Add(new CalendarDateRange(
   new DateTime(DateTime.Now.Year, DateTime.Now.Month, 01), DateTime.Now));

But when I add the style, I don’t get the black out displays being displayed and worse its possible to select the blackout dates.

I’m not sure what I missed but I’m hoping someone has an easy answer so that I don’t have to rebuild the entire widget.

Any help is appreciated.

Thanks,

Chris

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T00:50:48+00:00Added an answer on May 15, 2026 at 12:50 am

    Okay… that wasn’t in it but I’ll leave this answer for the next person.

    First BlackoutDates is some horrid mish-mash of a readonly collection of ranges. Pretty much unbindable. I poked around with rewriting the widget but didn’t get all that far.

    I did find something that works. You can set the blackout range in code.

    However, if you do this during construction it isn’t passed through the template (not sure why). So if you construct a Calendar, and then set the blackout range that works. But when you style that Calendar it doesn’t have template bindings (because it isn’t a dependency property it can’t be bound).

    However… it looks like if you set the BlackoutDates through an event generated by the style, then the dates are set. I used the loaded event as so:

                <Style x:Key="PopupCalendarStyle" TargetType="toolkit:Calendar">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="toolkit:Calendar">
                            <StackPanel Margin="0" HorizontalAlignment="Center" x:Name="Root">
                                <toolkit:Calendar x:Name="Calendar" 
                                                  SelectedDate="{TemplateBinding SelectedDate}"
                                                  DisplayDateStart="{TemplateBinding DisplayDateStart}"
                                                  SelectionMode="{TemplateBinding SelectionMode}"
                                                  Background="{TemplateBinding Background}" 
                                                  BorderBrush="{TemplateBinding BorderBrush}"
                                                  BorderThickness="{TemplateBinding BorderThickness}"
                                                  SelectedDatesChanged="Calendar_SelectedDatesChanged"
                                                  **Loaded="Calendar_Loaded"**>
                                    <toolkit:Calendar.CalendarDayButtonStyle>
                                        <Style>
                                            <Setter Property="Button.Height" Value="34"/>
                                            <Setter Property="Button.Width" Value="34" />
                                            <Setter Property="Button.FontSize" Value="16" />
                                        </Style>
                                    </toolkit:Calendar.CalendarDayButtonStyle>
                                    <toolkit:Calendar.CalendarButtonStyle>
                                        <Style>
                                            <Setter Property="Button.Height" Value="34"/>
                                            <Setter Property="Button.Width" Value="34"/>
                                            <Setter Property="Button.FontSize" Value="16"/>
                                        </Style>
                                    </toolkit:Calendar.CalendarButtonStyle>
                                </toolkit:Calendar>
                            </StackPanel>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>               
            </Style>
    

    With that done it was fairly trivial to create a load handler that let me set the BlackoutDates on the styled Calendar:

            private void Calendar_Loaded(object sender, RoutedEventArgs e)
        {
            ((Calendar)sender).BlackoutDates.Add(new CalendarDateRange(new DateTime(DateTime.Now.Year, DateTime.Now.Month, 01), DateTime.Now));
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF project and I'm trying to setup a NAnt build script
I am starting a WPF project, which will be fairly complicated in complexity and
I started a new WPF project in VS2008 and then added some code to
My project requires a background thread to initiate the creation of a WPF control
Looking at the C# project templates in VS2008 and the offerings are WPF User
Sometimes I create some quick personal projects using C# with Windows Forms or WPF
i'm building a wpf control based on the outlook calender sample in code project,
This is my first WPF project. I'm trying to get a rolling credits effect
I have a WPF application targetting the .NET 4.0 Client Profile which needs to
I have a WPF VB.NET project in Visual Studio 2008. For some reason, Visual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.