ARTICLE

Calendar control in Silverlight using VB

Posted by Manish Tewatia Articles | Silverlight using VB.NET October 20, 2010
In this article you will about the how to work with calendar control in silverlight using VB language.
 
Reader Level:

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"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:basics='clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls'
    d:DesignHeight="300" d:DesignWidth
="400">
    <StackPanel>
        <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>
    </StackPanel>
</
UserControl>

//File: Page.xaml.vb

Partial Public Class MainPage
    Inherits UserControl 
    Public Sub New()
        InitializeComponent()
    End Sub
    Private Sub DatePicker_DateValidationError(ByVal sender As Object, ByVal e As DatePickerDateValidationErrorEventArgs)
        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 Object, ByVal e As SelectionChangedEventArgs)
        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
        Next
    End
Sub
End Class

Output Window

calan.gif

Conclusion

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

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Become a Sponsor