WPF图表轴线

时间:2019-04-16 11:42:13

标签: c# wpf mvvm

我需要创建一个可以在画布上显示不同数学函数的应用程序。我还需要在画布上绘制带有轴标签的x轴和y轴。它看起来应该像这样: https://imgur.com/1Rbjm1Q

我已经创建了轴线,所以我只需要有关轴线标签的帮助。 到目前为止是这样的: https://imgur.com/3VMHash

这是我到目前为止使用的代码:

<Line X1="0" Y1="200" X2="600" Y2="200" StrokeThickness="1" Stroke="Black"/>
<Line X1="300" Y1="0" X2="300" Y2="400" StrokeThickness="1" Stroke="Black"/>
    <Canvas.Background>
                <DrawingBrush Stretch="None" TileMode="Tile"
                     Viewport="0,0 20,20" ViewportUnits="Absolute">
                    <!-- ^^^^^^^^^^^ set the size of the tile-->
                    <DrawingBrush.Drawing>
                        <GeometryDrawing>
                            <GeometryDrawing.Geometry>
                                <!-- draw a single X -->
                                <GeometryGroup>
                                    <LineGeometry StartPoint="0,0" EndPoint="0,20"/>
                                    <LineGeometry StartPoint="0,0" EndPoint="20,0"/>
                                </GeometryGroup>
                            </GeometryDrawing.Geometry>
                            <GeometryDrawing.Pen>
                                <!-- set color and thickness of lines -->
                                <Pen Thickness="0.1" Brush="Black" />
                            </GeometryDrawing.Pen>
                        </GeometryDrawing>
                    </DrawingBrush.Drawing>
                </DrawingBrush>
     </Canvas.Background>

0 个答案:

没有答案