Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
535
How to configure Click event for every Timeline Event title
posted

I have been using  XamTimLine control for a while.Is there any way to trigger click event when the user clicks "Event Title"?.I have tried with MouseLeftButtonDown event but it is not getting triggered.Pls have a look at the code i have tried. I have also attached the sample snapshot for understanding.

<igtl:XamTimeline.Series>
                <igtl:DateTimeSeries Title="Input Events" Fill="Red" Position="TopOrLeft" MouseLeftButtonDown="Clicked">
                    <igtl:DateTimeSeries.Entries>
                        <igtl:DateTimeEntry Time="00:00:01" Title="Event 1" Details="Details Time Entry 1" MouseLeftButtonDown="Clicked" ToolTip = "One"/>
                        <igtl:DateTimeEntry Time="00:00:01" Title="Event 2" Details="Details Time Entry 1" MouseLeftButtonDown="Clicked" ToolTip = "Two"/>
                        <igtl:DateTimeEntry Time="00:00:01" Title="Event 3" Details="Details Time Entry 1" MouseLeftButtonDown="Clicked" ToolTip = "Three"/>
                        <igtl:DateTimeEntry Time="00:00:01" Title="Event 4" Details="Details Time Entry 1" MouseLeftButtonDown="Clicked" ToolTip = "Four"/>
                        </igtl:DateTimeSeries.Entries>
                </igtl:DateTimeSeries>
</igtl:XamTimeline.Series>

Parents
No Data
Reply
  • 12875
    Verified Answer
    posted

    Hi,

    You could re-templated the EventTitle style and add the MouseLeftButtonDown to the Grid in the template.

     

    <Style x:Key="eventTitleStyle" TargetType="ig:EventTitle" >

      <Setter Property="MaxWidth" Value="180" />

      <Setter Property="IsTabStop" Value="False"/>

      <Setter Property="Background" Value="White" />

      <Setter Property="Foreground" Value="#FF333333"/>

      <Setter Property="BorderThickness" Value="1" />

      <Setter Property="BorderBrush" Value="Black" />

      <Setter Property="PointStringFormat" Value="{}[{0}]" />

      <Setter Property="SpanStringFormat" Value="{}[{0}-{1}]" />

      <Setter Property="LineStyle">

          <Setter.Value>

              <Style TargetType="Line">

                 <Setter Property="StrokeThickness" Value="1" />

                 <Setter Property="Stroke" Value="Black" />

                 <Setter Property="Canvas.ZIndex" Value="-1" />

              </Style>

          </Setter.Value>

      </Setter>

     

      <Setter Property="Template">

        <Setter.Value>

            <ControlTemplate TargetType="ig:EventTitle" >

                <Border HorizontalAlignment="Left"

                        BorderThickness="{TemplateBinding BorderThickness}"

                        Background="{TemplateBinding Background}"

                        BorderBrush="{TemplateBinding BorderBrush}">

                    <Grid Background="{x:Null}" MouseLeftButtonDown="EventItemGrid_MouseLeftButtonDown">

                        <Grid.RowDefinitions>

                            <RowDefinition Height="*" />

                            <RowDefinition Height="Auto" />

                            </Grid.RowDefinitions>

                            <TextBlock Text="{TemplateBinding FormattedText}" TextWrapping="Wrap" />

                            <TextBlock Text="{TemplateBinding Title}" TextWrapping="Wrap" Grid.Row="1"/>

                    </Grid>

                </Border>

            </ControlTemplate>

         </Setter.Value>                   

      </Setter>

     

    </Style>

     

    And then add the style to the series.

    <ig:XamTimeline.Series>

         <ig:NumericTimeSeries Title="Default Title Style" Fill="White"

          EventTitleStyle="{StaticResource eventTitleStyle}"

     

    and of course   handle the code behind.

    private void EventItemGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)

    {

        Grid g = sender as Grid;

        DependencyObject dp = VisualTreeHelper.GetParent(g);

        while (dp != null && dp.GetType() != typeof(EventTitle))

        {

            dp = VisualTreeHelper.GetParent(dp);

        }

        if (dp.GetType() == typeof(EventTitle))

        {

            EventTitle et = dp as EventTitle;

            NumericTimeEntry nte = et.EventEntry as NumericTimeEntry;

     

            (this.xamTimeline0.Axis as NumericTimeAxis).SelectedTime = nte.Time;

     

         }

    }

     

    Let me know if you have any questions.      

Children