08-17-2016 11:50 PM
WINFORM:
var d = new AxisCustomDivision(78, "78");
d.GridLineStyle = LineStyle.Dash;
d.GridVisible = true;
WPF:
var d=CustomDivision(value)
no text,no gridline,no gridline style?
WPF how to do?
Solved! Go to Solution.
08-18-2016 02:47 PM
Regarding text, you can use a custom LabelPresenter
to control the display of the label. By default, it will just do a basic "to string" of the numeric value.
When we added custom divisions to WPF, we did not implement custom grid lines at the same time. However, you can use the existing grid line renderer to get this functionality. I've attached an example custom grid line renderer implemenation, which supports both distinct styles (as shown in your screenshot), and a simpler uniform style (where you just specify an axis).
08-22-2016 12:29 AM - edited 08-22-2016 12:30 AM
Thank you for your answer. But I don't know how to use it?
phansen 已写:Regarding text, you can use a custom LabelPresenter to control the display of the label. By default, it will just do a basic "to string" of the numeric value.
When we added custom divisions to WPF, we did not implement custom grid lines at the same time. However, you can use the existing grid line renderer to get this functionality. I've attached an example custom grid line renderer implemenation, which supports both distinct styles (as shown in your screenshot), and a simpler uniform style (where you just specify an axis).
08-22-2016 12:29 AM
Thank you for your answer. But I don't know how to use it.
08-22-2016 01:14 AM - edited 08-22-2016 01:16 AM
C# code:
SolidColorBrush b = new SolidColorBrush(Color.FromRgb(255, 255, 255));
yAxis1.MajorGridLines = new GridLines();
CustomGridLinesRenderer.ForAxis(yAxis1, b);
WPF XML:
<ni:Graph Grid.Row="0" Grid.Column="0" x:Name="graph" DefaultInteraction="Pan" RenderMode="Hardware" PlotAreaBackground="Black" Interactions="{x:Null}" >
<ni:Graph.Axes>
<ni:AxisDouble Orientation="Horizontal" x:Name="xAxis1" Range="0,4800" Adjuster="None" >
</ni:AxisDouble>
<ni:AxisDouble Orientation="Vertical" Range="0,380" Adjuster="None" Name="yAxis1" >
<ni:AxisDouble.CustomDivisions>
<ni:CustomDivision LabelBrush="#FFC64D4D" Value="78"/>
</ni:AxisDouble.CustomDivisions>
</ni:AxisDouble>
</ni:Graph.Axes>
08-22-2016 09:56 AM
Ah sorry, I completely overlooked that. To use the renderer, add it to the Children
collection of the graph:
...
var renderer = CustomGridLinesRenderer.ForAxis(yAxis1, b);
graph.Children.Add( renderer );