WPFTimelineControl 1.1.0
dotnet add package WPFTimelineControl --version 1.1.0
NuGet\Install-Package WPFTimelineControl -Version 1.1.0
<PackageReference Include="WPFTimelineControl" Version="1.1.0" />
<PackageVersion Include="WPFTimelineControl" Version="1.1.0" />
<PackageReference Include="WPFTimelineControl" />
paket add WPFTimelineControl --version 1.1.0
#r "nuget: WPFTimelineControl, 1.1.0"
#:package WPFTimelineControl@1.1.0
#addin nuget:?package=WPFTimelineControl&version=1.1.0
#tool nuget:?package=WPFTimelineControl&version=1.1.0
WPF Timeline Control
A timeline control for WPF, available for personal or commercial use under the MIT license.
Using the control
Install the NuGet package or download the source add add it to your Solution.
In your Window or UserControl, add the XAML namespace:
xmlns:tim="clr-namespace:WpfTimelineControl;assembly=WpfTimelineControl"Add the Timeline control:
<Grid> <tim:Timeline x:Name="myTimeline" /> </Grid>Through a Data Binding or code-behind, set the Timeline's DataContext:
List<TimelineEntry> entries = new List<TimelineEntry> { new TimelineBar("Event 1", DateTime.Now, TimeSpan.FromSeconds(92), 0), new TimelinePoint("Event 2", DateTime.Now, TimeSpan.FromSeconds(17), 1), }; var timelineBuilder = TimelineBuilderFactory.Create(); var viewModel = timelineBuilder.BuildViewModel(entries.ToArray()); myTimeline.DataContext = viewModel;
Customisation
See the Demo Apps for a demonstration of all the customisation options.
Dependency Properties
To customise the colours of the timeline entries, set
TimelineEntryBrushes:<tim:Timeline TimelineEntryBrushes="{StaticResource TimelineItemColors}" /> <Application.Resources> <SolidColorBrush x:Key="CorporateColor" Color="#2397D3" /> <x:Array Type="SolidColorBrush" x:Key="TimelineItemColors"> <SolidColorBrush Color="{Binding Color,Source={StaticResource CorporateColor1}}" /> <SolidColorBrush Color="#E9C43B" /> </x:Array> </Application.Resources>Type:
Brush[]Default:{ Brushes.Red, Brushes.Green, Brushes.Blue, Brushes.Yellow, Brushes.Magenta }To change the colour used for the 'Labels exceed bars' setting, set
LabelsExceedBarsSettingColorIndex:<tim:Timeline LabelsExceedBarsSettingColorIndex="2" />Type:
intDefault:0To choose whether the events' name labels are coloured, set
ColoredEntryNameLabels:<tim:Timeline ColoredEntryNameLabels="True" />Type:
BooleanDefault:TrueThe 3 strings used in the control can be translated using
NameLabel,StartLabelandEndLabel<tim:Timeline NameLabel="{lex:Loc Key=LBL_Name}" StartLabel="{lex:Loc Key=LBL_Start}" EndLabel="{lex:Loc Key=LBL_End}" />Type:
stringDefault:"Name","Start","End"With the top bar hidden, you can fix the
LabelsExceedBarssetting:<tim:Timeline LabelsExceedBars="False" />Type:
BooleanDefault:True
ViewModel Properties
Add a title to the timeline by setting
Title:viewModel.Title = "Events Today"Type:
stringDefault:NULLHide the settings controls on the top bar by setting
ShowControls:viewModel.ShowControls = falseType:
BooleanDefault:trueHide the longer date interval markers by setting
ShowDateMarkers:viewModel.ShowDateMarkers = falseType:
BooleanDefault:trueWith the top bar hidden, you can fix the
PixelsPerIntervalsetting, which affects the width of each interval and therefore of the timeline control:viewModel.PixelsPerInterval = 160;Type:
intDefault:320With the top bar hidden, you can fix the
MajorIntervalSecondssetting, which sets the timescale represented by each interval:viewModel.MajorIntervalSeconds = TimelineConstants.IntervalOptions[3];Type:
intDefault:[calculated based on the events]
Static Variables
The TimelineConstants class contains two static variables that control the behaviour of the timeline control.
The TimelineBuilder uses these values, which I have set based on my experience using this control at my previous company, but you may need to tweak them based on your data.
The timeline is always linear; each interval represents the same amount of time. The builder chooses one of the values from the IntervalOptions array, from 10 seconds up to 60 minutes.
The builder calculates the total duration of the events (from the beggining of the first to the end of the last) then divides this by the TimelineScalingFactor and finds the closest value from the options array.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
| .NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.6.2
- No dependencies.
-
net6.0-windows7.0
- No dependencies.
-
net8.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.