Hi, I am using this class for showing appointment with different styles.
I want the things dynamically.
I have created data template
<DataTemplate x:Key="FlexibleFinishedRecurrentAppointmentTemplate">
<Border x:Name="XamlBorder"
BorderBrush="Black"
BorderThickness="0.5"
Margin="-2">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop Color="#FF6F94C0"
Offset="0.162" />
<GradientStop Color="#FFBCD0E8"
Offset="0.892" />
</LinearGradientBrush>
</Border.Background>
<Grid>
<ToolTipService.ToolTip>
<StackPanel Orientation="Vertical"
MaxWidth="225"
MaxHeight="225">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Start, StringFormat=\{0:HH:mm\}}" />
<TextBlock Text="-" />
<TextBlock Text="{Binding End, StringFormat=\{0:HH:mm\}}" />
</StackPanel>
<TextBlock Text="{Binding Subject}"
TextWrapping="Wrap" />
</StackPanel>
</ToolTipService.ToolTip>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right"
VerticalAlignment="Bottom">
<maestroBaseControls:XamlIconMT x:Name="XamlFlexibleImage" Foreground="{StaticResource ColorBrush5}"
Margin="0,0,1,4"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Width="16"
Height="16"
XamlIconType="{Binding Text, Converter={StaticResource XamlImageSourceConverter}, ElementName=XamlFlexible}" />
<TextBlock x:Name="XamlFlexible"
Text="Flexible"
Width="1000"
Visibility="Collapsed" />
<maestroBaseControls:XamlIconMT x:Name="Xamlrecurrence" Foreground="{StaticResource ColorBrush5}"
Margin="0,0,4,4"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Width="16"
Height="16"
XamlIconType="{Binding Text, Converter={StaticResource XamlImageSourceConverter}, ElementName=XamlRecurrence}" />
<TextBlock x:Name="XamlRecurrence"
Text="Recurrence"
Width="1000"
Visibility="Collapsed" />
</StackPanel>
<TextBlock x:Name="XamlSubjectTextBlock"
Margin="7 0 18 0"
Width="{Binding Width, ElementName=XamlBorder}"
VerticalAlignment="Top"
HorizontalAlignment="Left"
TextTrimming="WordEllipsis"
Text="{Binding Subject}"
Foreground="Black"
TextWrapping="Wrap" />
</Grid>
</Border>
</DataTemplate>
So many templates are there each template have same content except the things in Bold area. Image will be different for different template.
---------------------------------------------------------------------------------------------------------------------------------------------------
TemplateSelector static resource.
<localScheduler:ReservationTemplateSelector x:Key="XamlItemTemplateSelector"
FlexibleFinishedRecurrentAppointmentTemplate="{StaticResource FlexibleFinishedRecurrentAppointmentTemplate}"
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Binding in XAML
<telerik:RadScheduleView x:Name="XamlRadScheduleView"
AppointmentItemContentTemplateSelector="{StaticResource XamlItemTemplateSelector}"
/>
------------------------------------------------------------------------------------------------------------------------------------------------------------------
In TemplateSelector class I am using
public override DataTemplate SelectTemplate(object item, DependencyObject container, ViewDefinitionBase activeViewDeifinition)
{
{if (ocu.Appointment != null)
{
if (actualEndTime != null)
{
return this.FlexibleFinishedRecurrentAppointmentTemplate;
}
..........
.......
.........
......... (multiple conditions are there)
Now I have a problem with this structure. If I want to add one new template then I have to make changes in each and every template. As Template change is something like this
T1 - image1
T2 - image2
T3 - image1 image2
T4 - without image
So if I want to add one more template with Image3 then changes into templates are like this
T1 - image1
T2 - image2
T3 - image3
T4 - image1 and image2
T5 - image2 and image3
T6 - image1 and image3
T7 - Image1 and Image2 and Image3
T8 - without image.
So it goes in the n^2 manner, Is there any possibility that In XAML I use only one template and make changes into template run time one the basis of different condition.?
Thanks
h@rdik pancholi
I want the things dynamically.
I have created data template
<DataTemplate x:Key="FlexibleFinishedRecurrentAppointmentTemplate">
<Border x:Name="XamlBorder"
BorderBrush="Black"
BorderThickness="0.5"
Margin="-2">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop Color="#FF6F94C0"
Offset="0.162" />
<GradientStop Color="#FFBCD0E8"
Offset="0.892" />
</LinearGradientBrush>
</Border.Background>
<Grid>
<ToolTipService.ToolTip>
<StackPanel Orientation="Vertical"
MaxWidth="225"
MaxHeight="225">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Start, StringFormat=\{0:HH:mm\}}" />
<TextBlock Text="-" />
<TextBlock Text="{Binding End, StringFormat=\{0:HH:mm\}}" />
</StackPanel>
<TextBlock Text="{Binding Subject}"
TextWrapping="Wrap" />
</StackPanel>
</ToolTipService.ToolTip>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right"
VerticalAlignment="Bottom">
<maestroBaseControls:XamlIconMT x:Name="XamlFlexibleImage" Foreground="{StaticResource ColorBrush5}"
Margin="0,0,1,4"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Width="16"
Height="16"
XamlIconType="{Binding Text, Converter={StaticResource XamlImageSourceConverter}, ElementName=XamlFlexible}" />
<TextBlock x:Name="XamlFlexible"
Text="Flexible"
Width="1000"
Visibility="Collapsed" />
<maestroBaseControls:XamlIconMT x:Name="Xamlrecurrence" Foreground="{StaticResource ColorBrush5}"
Margin="0,0,4,4"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Width="16"
Height="16"
XamlIconType="{Binding Text, Converter={StaticResource XamlImageSourceConverter}, ElementName=XamlRecurrence}" />
<TextBlock x:Name="XamlRecurrence"
Text="Recurrence"
Width="1000"
Visibility="Collapsed" />
</StackPanel>
<TextBlock x:Name="XamlSubjectTextBlock"
Margin="7 0 18 0"
Width="{Binding Width, ElementName=XamlBorder}"
VerticalAlignment="Top"
HorizontalAlignment="Left"
TextTrimming="WordEllipsis"
Text="{Binding Subject}"
Foreground="Black"
TextWrapping="Wrap" />
</Grid>
</Border>
</DataTemplate>
So many templates are there each template have same content except the things in Bold area. Image will be different for different template.
---------------------------------------------------------------------------------------------------------------------------------------------------
TemplateSelector static resource.
<localScheduler:ReservationTemplateSelector x:Key="XamlItemTemplateSelector"
FlexibleFinishedRecurrentAppointmentTemplate="{StaticResource FlexibleFinishedRecurrentAppointmentTemplate}"
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Binding in XAML
<telerik:RadScheduleView x:Name="XamlRadScheduleView"
AppointmentItemContentTemplateSelector="{StaticResource XamlItemTemplateSelector}"
/>
------------------------------------------------------------------------------------------------------------------------------------------------------------------
In TemplateSelector class I am using
public override DataTemplate SelectTemplate(object item, DependencyObject container, ViewDefinitionBase activeViewDeifinition)
{
{if (ocu.Appointment != null)
{
if (actualEndTime != null)
{
return this.FlexibleFinishedRecurrentAppointmentTemplate;
}
..........
.......
.........
......... (multiple conditions are there)
Now I have a problem with this structure. If I want to add one new template then I have to make changes in each and every template. As Template change is something like this
T1 - image1
T2 - image2
T3 - image1 image2
T4 - without image
So if I want to add one more template with Image3 then changes into templates are like this
T1 - image1
T2 - image2
T3 - image3
T4 - image1 and image2
T5 - image2 and image3
T6 - image1 and image3
T7 - Image1 and Image2 and Image3
T8 - without image.
So it goes in the n^2 manner, Is there any possibility that In XAML I use only one template and make changes into template run time one the basis of different condition.?
Thanks
h@rdik pancholi