/// <summary> /// This code will run whenever TickLocation changes /// </summary> internal virtual void OnTickLocationChanged(TickLocation location) { if (Orientation == Orientation.Horizontal) { if (ElementHorizontalTickPanel != null) { if (location == TickLocation.None) ElementHorizontalTickPanel.Visibility = Visibility.Collapsed; else { ElementHorizontalTickPanel.Visibility = Visibility.Visible; SetupTickMarks(); } } } else { //TODO: IMPLEMENT FOR VERTICAL TEMPLATE } }
/// <summary> /// /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <returns></returns> FrameworkElement CreateTickMark(Point start, Point end, TickLocation location) { // If no template was specified, use the default if (TickTemplate == null) { System.Windows.Shapes.Line ln = new System.Windows.Shapes.Line(); ln.Stroke = new SolidColorBrush(Colors.Black); ln.StrokeThickness = 1.0; ln.X1 = start.X; ln.Y1 = start.Y; ln.X2 = end.X; ln.Y2 = end.Y; return ln; } else { ContentPresenter cp = new ContentPresenter(); //cp.Content = "a"; cp.ContentTemplate = TickTemplate; if (location == TickLocation.Top) { cp.SetValue(Canvas.TopProperty, start.Y - cp.ActualHeight); cp.SetValue(Canvas.LeftProperty, start.X - (cp.ActualWidth / 2)); } else { cp.SetValue(Canvas.TopProperty, end.Y); cp.SetValue(Canvas.LeftProperty, start.X - (cp.ActualWidth / 2)); } return cp; } }