RadiantQ WPF Gantt
Special Lines
Previous Topic  Next Topic 

Special Lines


Special Lines are lines that can be drawn at specific times in the GanttChart to indicate milestones, deadlines or other times of interest.


Here is a sample code that will draw a line at a specific time, with the specific color:


            this.ganttControl.SpecialLineInfos.Add(new SpecialLineInfo()

            {

                LineDateTime = TimeComputingUtils.ToUtcKind(DateTime.Today) + TimeSpan.FromDays(10),

                ToolTipText = "Deadline",

                LineBrush = new SolidColorBrush(Colors.Green)

            });


GanttChart with special lines


Custom Style


To customize the Style with which the line is rendered, you can create a custom Style like this in your XAML:


First include these namespaces:

<Page ...........

xmlns:srcview="clr-namespace:RadiantQ.Windows.Controls.Gantt.View;assembly=RadiantQ.GanttControls.WPF"

xmlns:converters="clr-namespace:RadiantQ.Windows.Controls.Gantt.ValueConverters;assembly=RadiantQ.GanttControls.WPF"

       >


Then define this Style in your XAML resources section, to change the Width to 3 and use a Background color:

<converters:WidthToLeftMarginConverter x:Key="widthToLeftMarginConverter" />

<Style TargetType="{x:Type srcview:SpecialLines}">

    <Setter Property="ItemTemplate">

        <Setter.Value>

            <DataTemplate>

                <!--Using a Border rather than a Line because the Border stretches vertically, whereas the Line doesn't.-->

                <Border BorderBrush="{Binding Tag.LineBrush, Mode=OneTime}"

               ToolTipService.ToolTip="{Binding Tag.ToolTipText, Mode=OneTime}"

                Background="{Binding Tag.LineBrush, Mode=OneTime}"

               BorderThickness="1"

               Width="3"

               Grid.Row="0"

               Grid.Column="0"

               HorizontalAlignment="Left"

               Margin="{Binding Width, Converter={StaticResource widthToLeftMarginConverter}}">

                </Border>

            </DataTemplate>

        </Setter.Value>

    </Setter>

</Style>



� RadiantQ 2009 - 2019. All Rights Reserved.