GroupHeader and events

2 posts, 0 answers
  1. Doots
    Doots avatar
    13 posts
    Member since:
    Apr 2011

    Posted 19 Jun 2012 Link to this post


    I would like to rise an event when a user click on a TextBlock located in the group header of my ScheduleView. Here is my XAML :

                        <TextBlock Text="{Binding FormattedName}" Grid.Column="1" FontWeight="Bold" Width="100" HorizontalAlignment="Left" VerticalAlignment="Center">
                                    <i:EventTrigger EventName="MouseUp">
                                        <commands:EventToCommand Command="{Binding TestCommand}" />

    Nothing happen, and the TestCommand is never called in my ViewModel, could you tell me if this is possible, and if yes how to fire this event ? I tried other events than MouseUp and the result is the same.

    Thanks for your help,
  2. Yana
    Yana avatar
    4604 posts

    Posted 22 Jun 2012 Link to this post

    Hello Doots,

    There are two issues with your code:

    1. First, the GroupHeader contains a button which switches to the DayViewDefinition when clicked. So in order to handle the Click event, you should remove the Command to this button. You should customize the GroupHeaderStyleSelector in order to achieve this. In the attached project I demonstrated the approach. Please check the CustomGroupHeaderTemplate template where the command to the GroupHeaderButton is removed.

    2. You should handle MouseDown event ot the TextBlock as Click event is not available. Also the TestCommand should be bound like this:

    <i:EventTrigger EventName="MouseDown">
        <commands:EventToCommand Command="{Binding DataContext.TestCommand,ElementName=ScheduleView}" />

    I've attached a simple project with the needed changes. Hope it helps.

    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top