We are using the RadCalendar in a FillTool for one of our Apps. The first time it loads it is very slow, depending on the computer. We have a couple of slower computer in the office and it takes up too 5 or 6 seconds to display the first time. From then on it load rather quickly is there a way to cache this control on application start so it loads fast every time.
Using:
Silverlight 4 and Version 2010.3.1314.1040 of radcontrols
ToolDate.xaml
Tool.cs
MainPage.xaml.cs
App.xaml
It takes around 2 seconds for this window to pop up for my computer. Fill tools are used to aid in filling a text box so they need to pop up fast anything over half a second is really too slow. Any suggestions for performance increase is appreciated.
Using:
Silverlight 4 and Version 2010.3.1314.1040 of radcontrols
ToolDate.xaml
<
v:Tool
xmlns:sdk
=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
x:Class
=
"CalendarPerformanceTest.ToolDate"
xmlns:sys
=
"clr-namespace:System;assembly=mscorlib"
xmlns:t
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
xmlns:v
=
"clr-namespace:RI.View"
xmlns:q
=
"clr-namespace:QISS.Base.DB.QDM"
xmlns:telerik
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
mc:Ignorable
=
"d"
d:DesignHeight
=
"500"
d:DesignWidth
=
"550"
>
<
UserControl.Resources
>
<
q:QListItem
x:Key
=
"DefaultValue"
R
=
"{}{AllTime}"
D
=
"{}{AllTime}"
></
q:QListItem
>
<
q:QListItems
x:Key
=
"singles"
>
<
q:QListItem
R
=
"{}{Today}"
D
=
"{}{Today}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{WeekStart}"
D
=
"{}{WeekStart}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{WeekEnd}"
D
=
"{}{WeekEnd}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{MonthStart}"
D
=
"{}{MonthStart}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{MonthEnd}"
D
=
"{}{MonthEnd}"
></
q:QListItem
>
</
q:QListItems
>
<
q:QListItems
x:Key
=
"ranges"
>
<
q:QListItem
R
=
"{}{AllTime}"
D
=
"{}{AllTime}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{ThisWeek}"
D
=
"{}{ThisWeek}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{ThisMonth}"
D
=
"{}{ThisMonth}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{ThisQuarter}"
D
=
"{}{ThisQuarter}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{ThisYear}"
D
=
"{}{ThisYear}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{WeeKToDate}"
D
=
"{}{WeeKToDate}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{MonthToDate}"
D
=
"{}{MonthToDate}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{YearToDate}"
D
=
"{}{YearToDate}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{InceptionToDate}"
D
=
"{}{InceptionToDate}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{PrevWeek}"
D
=
"{}{PrevWeek}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{Prev2Weeks}"
D
=
"{}{Prev2Weeks}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{PrevMonth}"
D
=
"{}{PrevMonth}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{PrevQuarter}"
D
=
"{}{PrevQuarter}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{PrevYear}"
D
=
"{}{PrevYear}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{NextWeek}"
D
=
"{}{NextWeek}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{NextWeeks}"
D
=
"{}{NextWeeks}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{NextMonth}"
D
=
"{}{NextMonth}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{NextQuarter}"
D
=
"{}{NextQuarter}"
></
q:QListItem
>
<
q:QListItem
R
=
"{}{NextYear}"
D
=
"{}{NextYear}"
></
q:QListItem
>
<
q:QListItem
R
=
"test"
D
=
"{}{}"
></
q:QListItem
>
</
q:QListItems
>
<
DataTemplate
x:Name
=
"keyWordTemp"
>
<
TextBlock
Text
=
"{Binding D}"
></
TextBlock
>
</
DataTemplate
>
</
UserControl.Resources
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
HorizontalAlignment
=
"Stretch"
VerticalAlignment
=
"Top"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"25"
></
RowDefinition
>
<
RowDefinition
Height
=
"210"
></
RowDefinition
>
<
RowDefinition
Height
=
"1*"
></
RowDefinition
>
<
RowDefinition
Height
=
"25"
></
RowDefinition
>
</
Grid.RowDefinitions
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"135"
></
ColumnDefinition
>
<
ColumnDefinition
Width
=
"210"
></
ColumnDefinition
>
<
ColumnDefinition
Width
=
"210"
></
ColumnDefinition
>
</
Grid.ColumnDefinitions
>
<
Border
Grid.Row
=
"0"
Grid.Column
=
"0"
Grid.ColumnSpan
=
"3"
Style
=
"{StaticResource MainHeaderBorder}"
>
</
Border
>
<
TextBlock
Grid.Row
=
"0"
Grid.Column
=
"0"
Text
=
"Ranges"
Style
=
"{StaticResource MainHeaderTextBlockStyle}"
HorizontalAlignment
=
"Center"
/>
<
TextBlock
Grid.Row
=
"0"
Grid.Column
=
"1"
Text
=
"From"
Style
=
"{StaticResource MainHeaderTextBlockStyle}"
HorizontalAlignment
=
"Center"
/>
<
TextBlock
Grid.Row
=
"0"
Grid.Column
=
"2"
Text
=
"To"
Style
=
"{StaticResource MainHeaderTextBlockStyle}"
HorizontalAlignment
=
"Center"
/>
<
telerik:RadCalendar
Width
=
"200"
Height
=
"200"
Grid.Row
=
"1"
Grid.Column
=
"1"
HorizontalAlignment
=
"Center"
SelectedDate
=
"{Binding Tool.LeftValue,Mode=TwoWay}"
></
telerik:RadCalendar
>
<
telerik:RadCalendar
Width
=
"200"
Height
=
"200"
Grid.Row
=
"1"
Grid.Column
=
"2"
HorizontalAlignment
=
"Center"
SelectedDate
=
"{Binding Tool.RightValue,Mode=TwoWay}"
></
telerik:RadCalendar
>
<
ListBox
Grid.Row
=
"1"
Grid.Column
=
"0"
Grid.RowSpan
=
"2"
ItemsSource
=
"{StaticResource ranges}"
SelectedItem
=
"{Binding Tool.ToolValue,Mode=TwoWay}"
ItemTemplate
=
"{StaticResource keyWordTemp}"
></
ListBox
>
<
ListBox
Grid.Row
=
"2"
Grid.Column
=
"1"
ItemsSource
=
"{StaticResource singles}"
SelectedItem
=
"{Binding Tool.LeftValue,Mode=TwoWay}"
ItemTemplate
=
"{StaticResource keyWordTemp}"
></
ListBox
>
<
ListBox
Grid.Row
=
"2"
Grid.Column
=
"2"
ItemsSource
=
"{StaticResource singles}"
SelectedItem
=
"{Binding Tool.RightValue,Mode=TwoWay}"
ItemTemplate
=
"{StaticResource keyWordTemp}"
></
ListBox
>
<
Button
Grid.Row
=
"3"
Grid.Column
=
"1"
x:Name
=
"ftclear"
Command
=
"{Binding Tool.ClearCommand}"
CommandParameter
=
"{StaticResource DefaultValue}"
>
<
TextBlock
Text
=
"Clear"
></
TextBlock
>
</
Button
>
</
Grid
>
</
v:Tool
>
Tool.cs
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Net;
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;
using
System.Collections;
using
Telerik.Windows.Controls;
using
System.Collections.ObjectModel;
using
System.Collections.Specialized;
using
System.Text;
using
System.Windows.Controls.Primitives;
using
System.Windows.Media.Effects;
namespace
RI.View
{
public
class
Tool : UserControl
{
internal
Conditions cond;
public
object
SrcObject
{
get
{
return
(
object
)GetValue(SrcObjectProperty); }
set
{ SetValue(SrcObjectProperty, value); }
}
// Using a DependencyProperty as the backing store for SrcObject. This enables animation, styling, binding, etc...
public
static
readonly
DependencyProperty SrcObjectProperty =
DependencyProperty.Register(
"SrcObject"
,
typeof
(
object
),
typeof
(Tool),
new
PropertyMetadata(
null
));
public
Tool()
{
// InitializeComponent();
//cond = new Conditions();
//cond.CollectionChanged += cond_CollectionChanged;
}
//void cond_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
//{
// UpdateSrcValue();
//}
protected
void
UpdateSrcValue()
{
StringBuilder sb =
new
StringBuilder();
for
(
int
i = 0; i < cond.Count; i++)
{
if
(i > 0)
{
sb.Append(
","
);
}
sb.Append(cond[i].val1);
if
(!String.IsNullOrEmpty(cond[i].val2))
{
sb.Append(
".."
);
sb.Append(cond[i].val2);
}
}
((TextBox)SrcObject).Text = sb.ToString();
}
protected
void
setSrcValue(
string
s)
{
((TextBox)SrcObject).Text = s;
}
protected
virtual
void
ParseExistingValue()
{
string
val = ((TextBox)SrcObject).Text;
string
[] vals = val.Split(
new
char
[] {
','
,
'&'
});
foreach
(
string
s
in
vals)
{
Condition c = Condition.Parse(s);
cond.Add(c);
}
}
}
internal
class
Conditions : ObservableCollection<Condition>
{
}
internal
class
Condition
{
public
static
Condition Parse(
string
s)
{
s = s.Trim();
Condition c =
new
Condition();
if
(s.Length > 1 && s[0] ==
'!'
)
{
c.not =
true
;
s = s.Substring(1, s.Length - 1);
}
string
[] parts = s.Split(
new
string
[] {
".."
}, StringSplitOptions.None);
c.val1 = parts[0];
if
(parts.Length > 1)
{
c.val2 = parts[1];
}
return
c;
}
//public String oper = ",";
public
Boolean not =
false
;
public
string
val1;
public
string
val2;
}
}
namespace
QISS.Base.DB.QDM
{
public
class
QListItem
{
private
string
_R;
public
string
R
{
get
{
return
_R; }
set
{ _R = value; }
}
private
string
_D;
public
string
D
{
get
{
return
_D; }
set
{ _D = value; }
}
}
public
class
QListItems:List<QListItem>
{
}
}
MainPage.xaml.cs
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Net;
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;
using
Telerik.Windows.Controls;
namespace
CalendarPerformanceTest
{
public
partial
class
MainPage : UserControl
{
public
MainPage()
{
InitializeComponent();
}
private
void
btn_Click(
object
sender, RoutedEventArgs e)
{
RadWindow w =
new
RadWindow();
w.Content =
new
ToolDate();
w.Show();
w.Width = 600;
w.Height = 600;
}
}
}
App.xaml
<
Application
xmlns
=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
x:Class
=
"CalendarPerformanceTest.App"
>
<
Application.Resources
>
<
ResourceDictionary
>
<
SolidColorBrush
x:Key
=
"WhiteSmokeBrush"
Color
=
"WhiteSmoke"
/>
<
LinearGradientBrush
x:Key
=
"MainBodyBorderBackGroundBrush"
StartPoint
=
".5,0"
EndPoint
=
".5,1"
>
<
GradientStop
Color
=
"WhiteSmoke"
Offset
=
"0"
/>
<
GradientStop
Color
=
"Silver"
Offset
=
"5"
/>
<
GradientStop
Color
=
"DarkGray"
Offset
=
"10"
/>
</
LinearGradientBrush
>
<
LinearGradientBrush
x:Key
=
"MainHeaderBorderBackGroundBrush"
StartPoint
=
".5,0"
EndPoint
=
".5,1"
>
<
GradientStop
Color
=
"#62bbe8"
Offset
=
"0"
/>
<
GradientStop
Color
=
"#3baae3"
Offset
=
".5"
/>
<
GradientStop
Color
=
"#6fc0ea"
Offset
=
"1"
/>
</
LinearGradientBrush
>
<
Style
x:Key
=
"MainBodyBorder"
TargetType
=
"Border"
>
<
Setter
Property
=
"CornerRadius"
Value
=
"6"
/>
<
Setter
Property
=
"Padding"
Value
=
"6"
/>
<
Setter
Property
=
"BorderBrush"
Value
=
"#2694e8"
/>
<
Setter
Property
=
"BorderThickness"
Value
=
"1"
/>
<
Setter
Property
=
"Background"
Value
=
"WhiteSmoke"
/>
</
Style
>
<
Style
x:Key
=
"MainHeaderBorder"
TargetType
=
"Border"
>
<
Setter
Property
=
"CornerRadius"
Value
=
"6"
/>
<
Setter
Property
=
"Padding"
Value
=
"2"
/>
<
Setter
Property
=
"BorderBrush"
Value
=
"DimGray"
/>
<
Setter
Property
=
"BorderThickness"
Value
=
"1"
/>
<
Setter
Property
=
"Background"
Value
=
"{StaticResource MainHeaderBorderBackGroundBrush}"
/>
</
Style
>
<
Style
x:Key
=
"MainHeaderTextBlockStyle"
TargetType
=
"TextBlock"
>
<
Setter
Property
=
"FontSize"
Value
=
"12"
/>
<
Setter
Property
=
"FontWeight"
Value
=
"Bold"
/>
<
Setter
Property
=
"Margin"
Value
=
"5 0 0 0"
/>
<
Setter
Property
=
"VerticalAlignment"
Value
=
"Center"
/>
<
Setter
Property
=
"HorizontalAlignment"
Value
=
"Left"
/>
<
Setter
Property
=
"Foreground"
Value
=
"Snow"
/>
</
Style
>
<
Style
x:Key
=
"MainBodyTextBlockStyle"
TargetType
=
"TextBlock"
>
<
Setter
Property
=
"Margin"
Value
=
"20 10 0 0"
/>
<
Setter
Property
=
"FontSize"
Value
=
"12"
/>
</
Style
>
</
ResourceDictionary
>
</
Application.Resources
>
</
Application
>
It takes around 2 seconds for this window to pop up for my computer. Fill tools are used to aid in filling a text box so they need to pop up fast anything over half a second is really too slow. Any suggestions for performance increase is appreciated.