This is a migrated thread and some comments may be shown as answers.

Telerik RadCalendar First Look problem

2 Answers 177 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
ekie ekie
Top achievements
Rank 1
ekie ekie asked on 12 Nov 2010, 02:36 PM
Hello.
I Have a problem with the code shown in the Telerik RadCalendar First Look (showing in the Rad Controls Silverlight 2010 q2 Demo). I like this first demo of RadCalendar and I want to use it in one of my projects (for a school). But when I try it, i get this error message. 

For the C# code
  1. The type or namespace name 'Event' could not be found (are you missing a using directive or an assembly reference?) .

For the Silverlight code (xaml code), i get this error messages 
  1. The type 'local:EventsCollection' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
  2. The type 'local:Event' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
  3. The type 'local:EventDayTemplateSelector' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
  4. The attachable property 'DefaultTemplate' was not found in type 'EventDayTemplateSelector'
  5. The attachable property 'EventTemplate' was not found in type 'EventDayTemplateSelector' 

Here you can see all code of the project 

Xaml Code: 
<UserControl x:Class="Telerik.Windows.Examples.Calendar.MainPage"
        xmlns:local="clr-namespace:Telerik.Windows.Examples.Calendar"
        xmlns:telerikQuickStart="clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=Telerik.Windows.Controls"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="400">
 
    <UserControl.Resources>
        <LinearGradientBrush x:Key="RadHeaderBackground" EndPoint="0.499,1.802" StartPoint="0.5,0.0839999988675117">
            <GradientStop Color="#FF78AED6" Offset="0.178"/>
            <GradientStop Color="#FF174A74" Offset="1"/>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="RadContentBorderBackground" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FFF2F2F2" Offset="0"/>
            <GradientStop Color="#FFE1E1E1" Offset="1"/>
            <GradientStop Color="#FFF9F9F9" Offset="0.127"/>
            <GradientStop Color="#FFF9F9F9" Offset="0.8"/>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="RadColBackground" EndPoint="0.5,0.936" StartPoint="0.5,0.084">
            <GradientStop Color="#FFE4E4E4" Offset="0"/>
            <GradientStop Color="#FFC1C1C1 " Offset="1"/>
        </LinearGradientBrush>
 
        <DataTemplate x:Key="EventTemplate">
            <StackPanel Orientation="Vertical" Width="348" HorizontalAlignment="Left" Margin="0,8">
                <TextBlock x:Name="EventDate" TextWrapping="Wrap" FontSize="11" Text="{Binding FormatedDate}" />
                <TextBlock x:Name="EventCompanyBranch" TextWrapping="Wrap" FontSize="11" Text="{Binding Company}"/>
                <TextBlock x:Name="EventTitle" Foreground="{Binding Brush}" TextWrapping="Wrap" Margin="0,4" FontSize="13" Text="{Binding Title}" />
                <TextBlock x:Name="EventDetails" TextWrapping="Wrap" Foreground="#FF666666" FontSize="11" Text="{Binding Description}" />
            </StackPanel>
        </DataTemplate>
 
        <Style x:Key="ListBoxItemStyle" TargetType="ListBoxItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <ContentPresenter />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
 
        <local:EventsCollection x:Key="EventsList">
            <local:Event Day="2" Title="ASP.NET AJAX or Silverlight Is The Future Of Web Development"  Company="Telerik Inc - Boston, USA"
                                 Description="Speaker: Tom Black; Start Time - 11.15 AM" Brush="#FF005F9F" />
            <local:Event Day="3" Title="Blend For Silverlight Developers"  Company="Telerik Inc - Texas, USA"
                                 Description="Speaker: Tom Black; Start Time - 4.00 PM" Brush="#FF7F003F" />
            <local:Event Day="4" Title="Integrating WPF and WCF into Office Business Applications"  Company="Telerik Inc - Boston, USA"
                                 Description="Speaker: Tom Wildermuth; Start Time - 1.00 PM" Brush="#FF006666" />
 
            <local:Event Day="6" Title="ASP.NET AJAX or Silverlight Is The Future Of Web Development"  Company="Telerik Inc - Boston, USA"
                                 Description="Speaker: Tom Black; Start Time - 11.15 AM" Brush="#FF005F9F" />
            <local:Event Day="7" Title="Blend For Silverlight Developers"  Company="Telerik Inc - Texas, USA"
                                 Description="Speaker: Tom Black; Start Time - 4.00 PM" Brush="#FF7F003F" />
            <local:Event Day="8" Title="Integrating WPF and WCF into Office Business Applications"  Company="Telerik Inc - Boston, USA"
                                 Description="Speaker: Tom Wildermuth; Start Time - 1.00 PM" Brush="#FF006666" />
 
            <local:Event Day="11" Title="ASP.NET AJAX or Silverlight Is The Future Of Web Development"  Company="Telerik Inc - Boston, USA"
                                 Description="Speaker: Tom Black; Start Time - 11.15 AM" Brush="#FF005F9F" />
            <local:Event Day="14" Title="Blend For Silverlight Developers"  Company="Telerik Inc - Texas, USA"
                                 Description="Speaker: Tom Black; Start Time - 4.00 PM" Brush="#FF7F003F" />
            <local:Event Day="15" Title="Integrating WPF and WCF into Office Business Applications"  Company="Telerik Inc - Boston, USA"
                                 Description="Speaker: Tom Wildermuth; Start Time - 1.00 PM" Brush="#FF006666" />
 
            <local:Event Day="11" Title="ASP.NET AJAX or Silverlight Is The Future Of Web Development"  Company="Telerik Inc - Boston, USA"
                                 Description="Speaker: Tom Black; Start Time - 11.15 AM" Brush="#FF005F9F" />
            <local:Event Day="14" Title="Blend For Silverlight Developers"  Company="Telerik Inc - Texas, USA"
                                 Description="Speaker: Tom Black; Start Time - 4.00 PM" Brush="#FF7F003F" />
            <local:Event Day="15" Title="Integrating WPF and WCF into Office Business Applications"  Company="Telerik Inc - Boston, USA"
                                 Description="Speaker: Tom Wildermuth; Start Time - 1.00 PM" Brush="#FF006666" />
 
            <local:Event Day="23" Title="ASP.NET AJAX or Silverlight Is The Future Of Web Development"  Company="Telerik Inc - Boston, USA"
                                 Description="Speaker: Tom Black; Start Time - 11.15 AM" Brush="#FF005F9F" />
            <local:Event Day="22" Title="Blend For Silverlight Developers"  Company="Telerik Inc - Texas, USA"
                                 Description="Speaker: Tom Black; Start Time - 4.00 PM" Brush="#FF7F003F" />
            <local:Event Day="16" Title="Integrating WPF and WCF into Office Business Applications"  Company="Telerik Inc - Boston, USA"
                                 Description="Speaker: Tom Wildermuth; Start Time - 1.00 PM" Brush="#FF006666" />
        </local:EventsCollection>
 
        <CollectionViewSource x:Key="EventsView" x:Name="EventsList" Filter="EventsList_Filter" Source="{StaticResource EventsList}" />
 
        <local:EventDayTemplateSelector x:Key="EventDayTemplateSelector" EventsCollection="{StaticResource EventsList}">
            <local:EventDayTemplateSelector.DefaultTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Text}" />
                </DataTemplate>
            </local:EventDayTemplateSelector.DefaultTemplate>
            <local:EventDayTemplateSelector.EventTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Text}" Foreground="#FF000000" FontWeight="Bold" />
                </DataTemplate>
            </local:EventDayTemplateSelector.EventTemplate>
        </local:EventDayTemplateSelector>
 
    </UserControl.Resources>
 
    <Grid Width="670" Height="400">
        <Grid.RowDefinitions>
            <RowDefinition Height="45" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Border CornerRadius="5,5,0,0" Background="{StaticResource RadHeaderBackground}">
            <Grid>
                <TextBlock Text="Upcoming Events" Foreground="#CCC2D2EF" FontSize="22" VerticalAlignment="Center" TextWrapping="Wrap" Margin="10,2,10,0" />
                <TextBlock Text="Upcoming Events" Foreground="#FF00466C" FontSize="22" VerticalAlignment="Center" TextWrapping="Wrap" Margin="10,0,10,0" />
            </Grid>
        </Border>
        <Border Grid.Row="1" CornerRadius="0" Background="{StaticResource RadContentBorderBackground}" BorderBrush="#FFC8C8C8" BorderThickness="1,0,1,1">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.4*" />
                    <ColumnDefinition Width="0.6*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="35" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Border Grid.Column="1" Grid.RowSpan="2" BorderBrush="#FFFFFFFF" BorderThickness="1,0,0,0" />
                <Border Grid.Column="0" Grid.RowSpan="2" BorderBrush="#FFD4D4D4" BorderThickness="0,0,1,0" />
 
                <Border BorderBrush="#FFBEBEBE" BorderThickness="0,0,1,0" Background="{StaticResource RadColBackground}">
                    <Grid>
                        <TextBlock Text="Calendar" Foreground="#CCFFFFFF" FontSize="17" VerticalAlignment="Center" Margin="10,2,10,0" />
                        <TextBlock Text="Calendar" Foreground="#CC001F3F" FontSize="17" VerticalAlignment="Center" Margin="10,0,10,0" />
                    </Grid>
 
                </Border>
                <Border Grid.Column="1" BorderBrush="#FFFFFFFF" BorderThickness="1,0,0,0" Background="{StaticResource RadColBackground}">
                    <Grid>
                        <TextBlock Text="Events" Foreground="#CCFFFFFF" FontSize="17" VerticalAlignment="Center" Margin="10,2,10,0" />
                        <TextBlock Text="Events" Foreground="#CC001F3F" FontSize="17" VerticalAlignment="Center" Margin="10,0,10,0" />
                    </Grid>
                </Border>
 
                <Border Grid.Row="1" Grid.Column="0" telerikQuickStart:ThemeAwareBackgroundBehavior.IsEnabled="True" />
 
                <telerik:RadCalendar x:Name="calendar"
                        Grid.Row="1" VerticalAlignment="Top" Margin="0,15,0,0" HorizontalAlignment="Center"
                        SelectionMode="Extended"
                        IsTodayHighlighted="True" ViewsHeaderVisibility="Collapsed"
                        Culture="en-US"
                        SelectionChanged="calendar_SelectionChanged"
                        DayTemplateSelector="{StaticResource EventDayTemplateSelector}">
 
                </telerik:RadCalendar>
 
                <Grid Grid.Column="1" Grid.Row="1" Margin="15">
                    <ListBox x:Name="myEventsList" ItemContainerStyle="{StaticResource ListBoxItemStyle}"
                             ItemsSource="{Binding Source={StaticResource EventsView}}" ItemTemplate="{StaticResource EventTemplate}"
                             BorderBrush="{x:Null}" Background="{x:Null}" HorizontalAlignment="Left" />
                    <Grid x:Name="EmptyContent">
                        <TextBlock Text="There are no upcoming events for this date." FontStyle="Italic" FontSize="12" Foreground="#FF666666" />
                    </Grid>
                </Grid>
 
                <Border  Grid.ColumnSpan="2" Grid.RowSpan="2" BorderBrush="#FFFFFFFF" BorderThickness="0.7,0,0.7,0.7" />
            </Grid>
        </Border>
    </Grid>
 
</UserControl>


The C# code : 
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Windows;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.Calendar;
using System.Windows.Data;
#if !SILVERLIGHT
using SelectionChangedEventArgs = System.Windows.Controls.SelectionChangedEventArgs;
using DataTemplateSelector = System.Windows.Controls.DataTemplateSelector;
#endif
 
namespace Telerik.Windows.Examples.Calendar
{
    public partial class MainPage : System.Windows.Controls.UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            calendar.SelectedDate = DateTime.Today;
            calendar_SelectionChanged(null, null);
        }
 
        private void calendar_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            CollectionViewSource c = (this.Resources["EventsView"] as CollectionViewSource);
            c.View.Refresh();
            if (c.View.IsEmpty)
            {
                this.EmptyContent.Visibility = Visibility.Visible;
            }
            else
            {
                this.EmptyContent.Visibility = Visibility.Collapsed;
            }
        }
 
        private void EventsList_Filter(object sender, System.Windows.Data.FilterEventArgs e)
        {
            Event item = e.Item as Event;
            e.Accepted = this.calendar != null && this.calendar.SelectedDates.Contains(item.Date);
        }
    }
}

Thank for your help.













2 Answers, 1 is accepted

Sort by
0
ranjeew
Top achievements
Rank 1
answered on 15 Nov 2010, 03:16 AM
Hi Telarik team,

I also have a Question in Rad Calender where I want to check a particular date I have already Colored ( Yellow) in the calender and Color again two cells after that. The question I am having is that how would you check whether the calender cells are already colored or not ,when you're iterating through the calender for the second time ( basically need to find out a get cell color method in RadCalender control - how would you know which color is there in backcolor of the day cell). I have used special days to color the calender for the first time. Please help this is an urgent work I need to finish within few days.

Best Regards,
0
Kaloyan
Telerik team
answered on 16 Nov 2010, 10:29 AM
Hi ranjeew,

Let me first answer ekie's question. The error that you are getting is due to some not successfully compiled assemblies. You can download our latest Q3 2010 release and try it again. As about your question: you can explore the dates stored in the EventsCollection to check if some particular dates are presented in there.

Best wishes,
Kaloyan
the Telerik team
See What's New in RadControls for Silverlight in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
Tags
Calendar
Asked by
ekie ekie
Top achievements
Rank 1
Answers by
ranjeew
Top achievements
Rank 1
Kaloyan
Telerik team
Share this question
or