/default.aspx
Silverlight .NET CMS and Controls
Home
/controls.aspx
Silverlight Controls
Controls
Calendar

Silverlight Calendar Control

The Calendar control developed by VectorLight.Net and for use with Microsoft's Silverlight web technology has been designed for use in web applications where selecting a date from user friendly calendar is essential.

How to Use the Calendar Control

In your XAML ensure you have a reference to the Liquid.dll in the UserControl tag at the top. To use it on your Silverlight page:

<UserControl x:Class="Calendar.Page"
    xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:liquid="clr-namespace:Liquid;assembly=Liquid"
    Width="400" Height="300">
     <Canvas>
          <liquid:CalendarPlus x:Name="testCal" Canvas.Top="10" Canvas.Left="10" />
     </Canvas>
</UserControl>
 

In your Silverlight C# code behind file you can refer to your calendar using testCal. The Calendar has a Selected property which allows you to set or read the currently selected date.

The Calendar exposes a click event which is fired (named Clicked) when a day is clicked on, you can attach an event handler to this to read the date value.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Calendar
{
     public partial class Page : UserControl
     {
          public Page()
          {
               InitializeComponent();

               testCal.Clicked += new EventHandler(testCal_Clicked);
          }

          private void testCal_Clicked(object sender, EventArgs e)
          {
               DateTime selectedDate = testCal.Selected;
          }
     }
}

 

Example VectorLight.Net Calendar Control:

Silverlight Calendar Control
  • Written in Client-Side C# .NET 3.5
  • Microsoft Silverlight Only
  • Month and Year Navigation
  • Customizable Visual Feel

The screenshot above shows the Silverlight Calendar control in action.

Your Comments and Questions Answered

 You are not logged in. You need to login to post new messages, if you do not have a login you can register for free!

dan Aug, 14 2008 - 04:56

Hi Nina,

It is not possible to set individual background color at the moment, but it is a good suggestion and one which we will look to implementing in the next version. Thanks for the suggestion!

 

Nina Aug, 13 2008 - 02:20

hi!

Is it possible to set a background color for specific dates?
thx in advance!

 

dan Mar, 03 2008 - 05:36

Hello,

At the moment the day text cannot be changed, this is a bit of an oversight and has been added to the features list for the next version. Using the SetSkin() method only general styling of a control can be changed and not the text property, thanks for your patience, a fix is on the way.

 

Marek Bober Mar, 03 2008 - 03:48

Hello,
I have a problem with setting text to day title. I would like to change to CZECH name by this:

skins.Add("Calendar.Tue.Text", "Ut");

But is not working, can you help me, please? I am using version 3.0.

 

dan Feb, 26 2008 - 05:11

Hello,

No, not at the moment, this functionality is included in the next build and will be released shortly. Let me know if you have any other suggestions for inclusion in the datagrid.

 

prejeshvp Feb, 26 2008 - 04:55

Hi Dan,
Thanks for your earlier info.
Can we add checkboxes and dropdownlist in editable datagrid?

 

prejeshvp Feb, 25 2008 - 20:34

Hi Dan,
No, i was using older version (2.4)
Thanks, i will try with newer version

 

dan Feb, 25 2008 - 05:15

Hello,

Are you using verision 3.0? This only works with the latest version:

// This changes the Selected date background color to Green:
skins.Add("Calendar.Day.Background.Selected.Fill", "<SolidColorBrush Color=\"#ff00ff00\" />");
skins.Add("Calendar.Weekend.Background.Selected.Fill", "<SolidColorBrush Color=\"#ff00ff00\" />");

// This changes the Current date (Todays date) background color to Red:
skins.Add("Calendar.Day.Background.Current.Fill", "<SolidColorBrush Color=\"#ffff0000\" />");
skins.Add("Calendar.Weekend.Background.Current.Fill", "<SolidColorBrush Color=\"#ffff0000\" />");

 

prejeshvp Feb, 25 2008 - 04:04

Hi Dan,
Thanks for info

itseems that selected date and todays date background color are same, is there any way of having 2 different colors for these days?

 

dan Feb, 25 2008 - 02:15

Hello,

In your example below you are using an empty string as the XAML to fill the background rectangle. What you need to do is specify valid XAML and that should fix your problem:

skins.Add("Calendar.Day.Background.Selected.Fill", "<SolidColorBrush Color=\"#ff00ff00\" />");

This will make the selected day Green, it is important to note that the above will only affect selected dates that are not weekends, to modify the selected date fill property for weekends you will need to add:

skins.Add("Calendar.Weekend.Background.Selected.Fill", "<SolidColorBrush Color=\"#ff00ff00\" />");

Your earlier request to be able to control the background color of the current date has been implemented in version 3.0 and the syntax is similar to the above. The example on Custom Visualizations shows how to set the XAML for both Selected and Current dates.

 

prejeshvp Feb, 24 2008 - 20:43

Hi dan,
When i try to apply skin, skins.Add("Calendar.Day.Background.Selected.Fill", "");

i am getting following exception. But other skins are working except one mentioned below

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in agclr.dll

 

prejeshvp Feb, 24 2008 - 20:21

Thanks Dan

 

dan Feb, 22 2008 - 23:28

Yes, using the example on the Calendar Visual Customizations you could add the following line to the ApplySkin() method:

skins.Add("Calendar.Day.Background.Selected.Fill", "");

The selected element of a calendar day is a Rectangle so you can apply other properties such as the opacity:

skins.Add("Calendar.Day.Background.Selected.Opacity", "0.8");

Hope this helps.

 

prejeshvp Feb, 22 2008 - 21:02

Hi Dan,

Thanks for that Info. Can you please share how to style selected date?

 

dan Feb, 22 2008 - 05:30

Hello,

Thanks for the info. the datagrid demo seems to be working now, it may have just been a dll versioning conflict as were updating the demos all the time.

With regards to you question about the calendar, at the moment there is no way to control the styling of the current date, only the selected date can be styled. It is a good suggestion has been added to the list of improvements for the next version which is available soon, along with the datagrid.

Thanks for your feedback.

 

prejeshvp Feb, 22 2008 - 03:51

Hi Dan,

Silverlight grid Demo shows some parse error plz check it.

Can we change the background color of todays date. i want selected date and todays date to be in different colors ,is there any way of doing it?

 

dan Jan, 12 2008 - 00:05

When using the latest version of the controls, images are no longer required. Images are only needed for versions 2.0 and below.

 

dan Nov, 27 2007 - 02:13

The images should be placed in a folder called images. This folder should be in your root folder, i.e. the same level as your ClientBin folder, not in the ClentBin folder.

 

MrCyprom Nov, 25 2007 - 08:23

Hi,
I tried to use your Calendar but I get this Error : error 1001 download error . I suppose it is caused by the images which must be pasted in a specific location. I tried in the ClientBin directory of my project : ClientBin/Images or directly paste the images into ClientBin but it does not work.
Do you have a solution ?

Regards.

 
This page is 30.76KB and was generated by the SilverPages CMS in 0.062 seconds. Total impressions: 1625.