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

Unable to capture MouseLeftButtonDown on Timeruleritem

1 Answer 49 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Subramanian
Top achievements
Rank 1
Subramanian asked on 15 Mar 2012, 10:56 PM
Hello,

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;

 

}

}

1 Answer, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 21 Mar 2012, 01:39 PM
Hello Subramanian,

In the ControlTemplate of the TimeRulerItem in the TimelineView there is a RadButton - you can hook to its Click event, instead. To achieve this you need to use the OrientedTimeRulerItemStyleSelector. You can find an example of its use in this online demo. The only downside of this approach is that you have to copy all the styles of the TimeRulerItems, but edit only one of them, i.e. the TimeRulerGroupItemStyle. You can get the whole StyleSelector and the attached styles from the installation folder of the Telerik components on your machine. Usually this is
C://Program Files/Telerik/RadControls for Silverlight Q1 2012/Themes/ . Inside this folder, search the Themes folder to find the ScheduleView.xaml file that corresponds to your theme of choice.

Hope this information helps.

Greetings,
Konstantina
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
ScheduleView
Asked by
Subramanian
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Share this question
or