I’m developing an app that creates a timeline in run time. So I created a Grid (not a datagrid) and I wanna put some time stamps in equal spaces (60 pixels/hour – 1 pixel/minute).
I already know how to create the columns programmatically:
public void ColumnCreator(double totalInterval, double divPattern)
{
int divisionPattern = Convert.ToInt16(divPattern);
if (divisionPattern < totalInterval)
{
for (int i = 0; i < totalInterval; i += divisionPattern)
{
internalGrid.ColumnDefinitions.Add(new ColumnDefinition() {
Width = new GridLength(divisionPattern, GridUnitType.Pixel) });
}
}
}
but these lines are not synchronized. Does anybody have a solution for me?
Thanks in advance 😎
As was pointed out especially for real time visualization
Gridmay be the worse choice you can made.Gridis responsible for containing controls layout management and has a heavy impact on performance.Use a
Canvasto draw a stuff on it. UseShapeandPathfor drawing. To achive a reasonable performance on real time UI you need to read at least this link: http://msdn.microsoft.com/en-us/library/ms747393.aspxDo not use
Pixelsbut provided by WPFUnits, which are device independent way to declaring the dimension of something in WPF. So your drawing will maintain a proportion on different monitorsscreen sizesanddpi.