I am trying to capture the MouseLeftButtonDown event on the timeline view definition header which contains the month names. I want to know which month was clicked and perform some action. I changed the TimeRuleItemTemplateSelector and added the mouseleftbuttondown event to the textblock in the HorizontalTimeLineGroupTemplate datatemplate. But event is not firing. I changed the textblock style and it works.
I appreciate any help. Please find below the code changes
Regards
Subramanian.V.V.
Template change
<telerik:TimeRulerItemTemplateSelector x:Key="MyTimeRulerItemTemplateSelector">
<telerik:TimeRulerItemTemplateSelector.HorizontalTimelineMajorItemTemplate>
<DataTemplate>
<TextBlock Margin="2" TextAlignment="Left" Text="{Binding FormattedValue}" />
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.HorizontalTimelineMajorItemTemplate>
<telerik:TimeRulerItemTemplateSelector.HorizontalTimelineMinorItemTemplate>
<DataTemplate>
<TextBlock Margin="2" TextAlignment="Left" Text="{Binding FormattedValue}" />
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.HorizontalTimelineMinorItemTemplate>
<telerik:TimeRulerItemTemplateSelector.HorizontalDayMajorItemTemplate>
<DataTemplate>
<TextBlock Margin="2" Text="{Binding FormattedValue}"/>
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.HorizontalDayMajorItemTemplate>
<telerik:TimeRulerItemTemplateSelector.HorizontalWeekMajorItemTemplate>
<DataTemplate>
<TextBlock Margin="2" Text="{Binding FormattedValue}"/>
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.HorizontalWeekMajorItemTemplate>
<telerik:TimeRulerItemTemplateSelector.HorizontalWeekMinorItemTemplate>
<DataTemplate>
<TextBlock Margin="2" Text="{Binding FormattedValue}"/>
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.HorizontalWeekMinorItemTemplate>
<telerik:TimeRulerItemTemplateSelector.HorizontalDayMinorItemTemplate>
<DataTemplate>
<TextBlock Margin="2" Text="{Binding FormattedValue}"/>
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.HorizontalDayMinorItemTemplate>
<telerik:TimeRulerItemTemplateSelector.HorizontalTimelineGroupTemplate>
<DataTemplate>
<TextBlock Margin="2 1" TextAlignment="Left" Text="{Binding FormattedValue}" FontWeight="Bold" MouseLeftButtonUp="TextBlock_MouseLeftButtonUp" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown" />
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.HorizontalTimelineGroupTemplate>
<telerik:TimeRulerItemTemplateSelector.MonthGroupTemplate>
<DataTemplate>
<TextBlock Margin="6 2" Text="{Binding FormattedValue}"/>
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.MonthGroupTemplate>
<telerik:TimeRulerItemTemplateSelector.MonthItemTemplate>
<DataTemplate>
<TextBlock Margin="6 2" Text="{Binding FormattedValue}"/>
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.MonthItemTemplate>
<telerik:TimeRulerItemTemplateSelector.VerticalTimelineMajorItemTemplate>
<DataTemplate>
<TextBlock Margin="0 2" MinWidth="54" TextAlignment="Right" Text="{Binding FormattedValue}" />
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.VerticalTimelineMajorItemTemplate>
<telerik:TimeRulerItemTemplateSelector.VerticalWeekMinorItemTemplate>
<DataTemplate>
<TextBlock Margin="0 2" MinWidth="54" TextAlignment="Right" Text="{Binding FormattedValue}" />
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.VerticalWeekMinorItemTemplate>
<telerik:TimeRulerItemTemplateSelector.VerticalWeekMajorItemTemplate>
<DataTemplate>
<TextBlock Margin="0 2" MinWidth="54" TextAlignment="Right" Text="{Binding FormattedValue}"/>
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.VerticalWeekMajorItemTemplate>
<telerik:TimeRulerItemTemplateSelector.VerticalTimelineGroupTemplate>
<DataTemplate>
<telerik:LayoutTransformControl VerticalAlignment="Top">
<telerik:LayoutTransformControl.LayoutTransform>
<RotateTransform Angle="-90"/>
</telerik:LayoutTransformControl.LayoutTransform>
<TextBlock Height="16" Margin="2 1" TextAlignment="Right" Text="{Binding FormattedValue}" />
</telerik:LayoutTransformControl>
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.VerticalTimelineGroupTemplate>
<telerik:TimeRulerItemTemplateSelector.VerticalDayMajorItemTemplate>
<DataTemplate>
<TextBlock Margin="0 2" MinWidth="54" TextAlignment="Right" Text="{Binding FormattedValue}"/>
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.VerticalDayMajorItemTemplate>
<telerik:TimeRulerItemTemplateSelector.VerticalDayMinorItemTemplate>
<DataTemplate>
<TextBlock Margin="0 2" MinWidth="54" TextAlignment="Right" Text="{Binding FormattedValue}"/>
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.VerticalDayMinorItemTemplate>
<telerik:TimeRulerItemTemplateSelector.VerticalTimelineMinorItemTemplate>
<DataTemplate>
<TextBlock Margin="0 2" MinWidth="54" TextAlignment="Right" Text="{Binding FormattedValue}" />
</DataTemplate>
</telerik:TimeRulerItemTemplateSelector.VerticalTimelineMinorItemTemplate>
</telerik:TimeRulerItemTemplateSelector>
Control Definition
<telerik:RadScheduleView x:Name="MarketingCalSchedular"
VerticalAlignment="Stretch"
Margin="0,0"
AppointmentsSource="{Binding MarketingCalendarAppointments}"
TimeRulerItemTemplateSelector="{StaticResource MyTimeRulerItemTemplateSelector}"
NavigationHeaderVisibility="Collapsed"
IsInlineEditingEnabled="False">
<telerik:RadScheduleView.ViewDefinitions>
<telerik:TimelineViewDefinition VisibleDays="365"
MinTimeRulerExtent="1"
TimerulerGroupStringFormat="{}{0:MMMM}"
MinorTickLength="1m"
MajorTickLength="1m"
GroupTickLength="1m"
/>
</telerik:RadScheduleView.ViewDefinitions>
</telerik:RadScheduleView>
Code-Behind
private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
TextBlock button = sender as TextBlock;
if (button != null)
{
string text = button.Text;
}
}