Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

WPF how to do? AxisCustomDivision gridline ,text?

Solved!
Go to solution

WINFORM:

pic1.JPG

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?

 

 

0 Kudos
Message 1 of 6
(4,498 Views)

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).

~ Paul H
0 Kudos
Message 2 of 6
(4,473 Views)

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).


 

0 Kudos
Message 3 of 6
(4,448 Views)

Thank you for your answer. But I don't know how to use it.

0 Kudos
Message 4 of 6
(4,447 Views)

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>

 

 

捕获.JPG

 

 

0 Kudos
Message 5 of 6
(4,443 Views)
Solution
Accepted by jiewei_li

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 );

~ Paul H
0 Kudos
Message 6 of 6
(4,433 Views)