12-08-2013 05:25 AM
What happened to minro gridlines in WPF version? There is no such property, only for ticks. WinForms version had this as I remember
Solved! Go to Solution.
12-09-2013 11:09 AM
Unfortunately, we did not have time to implement all of the features available in Windows Forms for the WPF controls. We do plan to add features like minor gridlines in future releases.
As a workaround, you can use a custom axis type like the mockup below:
XAML
<local:CustomAxis>
<local:CustomAxis.MinorGridLines>
<ni:GridLines Stroke="#50A0" />
</local:CustomAxis.MinorGridLines>
</local:CustomAxis>
Code
public sealed class CustomAxis : Axis<double> {
public static readonly DependencyProperty MinorGridLinesProperty =
DependencyProperty.Register(
"MinorGridLines", typeof( GridLines ), typeof( CustomAxis ) );
public GridLines MinorGridLines {
get { return (GridLines)GetValue( MinorGridLinesProperty ); }
set { SetValue( MinorGridLinesProperty, value ); }
}
private GridLinesRenderer<double> minorGridLinesRenderer;
protected override void RegisterParent( IGraph parent ) {
if( MinorGridLines.TryGetRenderer( GetDataMapper( ), true, true, out minorGridLinesRenderer ) ) {
minorGridLinesRenderer.Subdivisions = new NotifyingCollection<double>( );
minorGridLinesRenderer.AxisOrientation = Orientation;
((ISupportChildren)parent).AddDependentChild( minorGridLinesRenderer );
}
base.RegisterParent( parent );
}
protected override void UnregisterParent( IGraph parent ) {
base.UnregisterParent( parent );
if( minorGridLinesRenderer != null ) {
((ISupportChildren)parent).RemoveDependentChild( minorGridLinesRenderer );
minorGridLinesRenderer = null;
}
}
protected override NotifyingCollection<TData> Present<TData>( ScalePresenter presenter, IRangeDataMapper<TData> dataMapper, bool isRangeEditable ) {
var majorDivisions = base.Present<TData>( presenter, dataMapper, isRangeEditable );
if( minorGridLinesRenderer != null ) {
var minorDivisions = (IEnumerable<double>)MinorDivisions.Mode.GetSubdivisions( dataMapper, majorDivisions );
minorGridLinesRenderer.Subdivisions.ReplaceAll( minorDivisions );
}
return majorDivisions;
}
}
12-10-2013 03:20 AM - edited 12-10-2013 03:25 AM
Hi, Paul!
Would you please try this axis with Log10 scale. It freezes for me...
What I do:
run app with Linear axis - minor lines are there
switch to Log10 axis - no minor lines
switch to Linear - freeze
12-10-2013 05:53 AM
first time graph is switched to log mode, there are no lines
then i pan it, and lines are there but usually with delay (see picture)
12-10-2013 06:11 AM
same happens in linear mode. not related to log...
just pan the graph and you'll see the delay
12-10-2013 10:01 AM
You are correct: I forgot that the major divisions is a notifying collection that can be monitored, which meant the minor divisions renderer was missing updates. I have attached an updated version of the custom axis mockup, moving updates to the minor divisions renderer into a collection changed handler.
12-10-2013 10:34 AM
thanks! seems to work now
10-23-2014 06:23 AM
I can't hide these lines when needed. Tried both:
Snippet
(ax as AxisWithMinorGridLines).MinorGridLines = null; //(ax as AxisWithMinorGridLines).MinorGridLines.Visibility = System.Windows.Visibility.Collapsed;
10-23-2014 09:49 AM
Looking at CustomAxis.cs
, all that should be needed is to add a property change callback to the dependency property registration. When the minor grid lines are set to null or hidden, you can remove the renderer (as in UnregisterParent
), or just clear the Subdivisions
collection; when it is assigned or visible, you can add the renderer (RegisterParent
) or restore Subdivisions
.
10-26-2014 01:14 PM
Thanks!