WPF has a built-in ability to select DataTemplate based on the TargetType they declared to handle.
StyleSelectorByItemType does the same thing only it select Style based on the item type they declared to handle. It does so by looking for a Style resource with x:Key equal to the type of item they timeline need to present.


Notice in the first line x:Key="{x:Type gc:Task}". This is what StyleSelectorByItemType looking for.

<Style x:Key="{x:Type gc:Task}" TargetType="{x:Type uifx:TimelineItem}"
          BasedOn="{StaticResource BaseTimelineItemStyle}">
    <Setter Property="BorderBrush" Value="Red" />
    <Setter Property="BorderThickness" Value="3" />

   <Setter Property="ToolTip" Value="{StaticResource TaskTooltip}"/>

        <Trigger Property="IsDisplayAsZero" Value="True">
            <Setter Property="ContentTemplate" Value="{StaticResource TaskZeroTemplate}" />
            <Setter Property="ToolTip" Value="{StaticResource TaskDisplayAsZeroTooltip}"/>

Last edited May 10, 2011 at 8:28 AM by ido_ran, version 9


No comments yet.