Silverlight Calendar control in VB.NET

In this article you will about the how to work with calendar control in silverlight using VB language.
  • 2024

Silverlight: Microsoft Silverlight is a web application framework it is a new cross-browser, cross-platform implementation of the .NET Framework for building and delivering the next generation of media experiences and Rich Interactive Applications(RIA) for the web, With support for advanced data integration, multithreading, HD video using IIS Smooth Streaming, and built in content protection, Silverlight enables online and offline applications for a broad range of business and consumer scenarios.

Silverlight controls are used for building rich line-of-business Silverlight applications. Sharing the same codebase with Telerik WPF controls, the Silverlight controls offer a clean and intuitive API and Expression Blend.

Calendar Control: A Calendar control is used to create a visual calendar that let users pick a date, or range of dates, it provides Powerful databinding, different views â€" month, year, decade, multiple views, culture awareness, flexible date navigation and transition animations.

Example of an Calendar

<UserControl x:Class="SilverlightApplication11.MainPage"
    d:DesignHeight="300" d:DesignWidth
        <basics:Calendar Margin="3" SelectionMode="MultipleRange"SelectedDatesChanged="Calendar_SelectedDatesChanged" ></basics:Calendar>
        <basics:Calendar Margin="3" DisplayMode="Year"SelectedDatesChanged="Calendar_SelectedDatesChanged" ></basics:Calendar>
        <basics:DatePicker Margin="3" DateValidationError="DatePicker_DateValidationError" ></basics:DatePicker>
        <basics:DatePicker Margin="3" SelectedDateFormat="Long"DateValidationError="DatePicker_DateValidationError" ></basics:DatePicker>
        <TextBlock x:Name="lblError" Foreground="Red" TextWrapping="Wrap"></TextBlock>

//File: Page.xaml.vb

Partial Public Class MainPage
    Inherits UserControl 
    Public Sub New()
    End Sub
    Private Sub DatePicker_DateValidationError(ByVal sender As ObjectByVal e AsDatePickerDateValidationErrorEventArgs)
        lblError.Text = "'" & Convert.ToString(e.Text) & "' is not a valid value because " &Convert.ToString(e.Exception.Message)
    End Sub 
    Private Sub Calendar_SelectedDatesChanged(ByVal sender As ObjectByVal e AsSelectionChangedEventArgs)
        For Each selectedDate As DateTime In e.AddedItems
            If (selectedDate.DayOfWeek = DayOfWeek.Saturday) OrElse (selectedDate.DayOfWeek =DayOfWeek.Sunday) Then
                lblError.Text = "Weekends are not allowed" 
                DirectCast(sender, Calendar).SelectedDates.Remove(selectedDate)
            End If
End Class

Output Window



Hope this article will help you to understand the calendar control in Silverlight using VB language.


More Articles

© 2020 DotNetHeaven. All rights reserved.