(精华)2020年02月08日 WPF课程管理系统项目实战(首页界面-LiveCharts的使用)

244 阅读1分钟

1:首先引入第三方包

LiveCharts.Wpf

2:引入命名空间并使用

xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
<Border CornerRadius="5" Background="White" Margin="10">
                    <Border.Effect>
                        <DropShadowEffect Color="#F2F2F2" ShadowDepth="10" BlurRadius="105" Opacity="0.4" Direction="270"/>
                    </Border.Effect>
                    <Grid>
                        <lvc:CartesianChart Margin="0,0,0,45">
                            <lvc:CartesianChart.Series>
                                <lvc:LineSeries Stroke="#FECC71" Fill="#FFF2DE"
                                            PointGeometrySize="0"
                                            Values="1,2,3,40,5,6,7"/>
                            </lvc:CartesianChart.Series>
                            <lvc:CartesianChart.AxisX>
                                <lvc:Axis ShowLabels="False"/>
                            </lvc:CartesianChart.AxisX>
                            <lvc:CartesianChart.AxisY>
                                <lvc:Axis ShowLabels="False" MinValue="0" MaxValue="100"/>
                            </lvc:CartesianChart.AxisY>
                        </lvc:CartesianChart>

                        <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="15">
                            <Border Width="20" Height="20" Background="#EDFAF0" CornerRadius="5">
                                <TextBlock Text="&#xe62a;" FontFamily="../Assets/Fonts/#iconfont"
                                       Foreground="#7ADA95" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                            </Border>
                            <TextBlock Text="32%" VerticalAlignment="Center" Foreground="#7ADA95" Margin="5,0,0,0"/>
                        </StackPanel>

                        <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" Margin="15,3">
                            <Border Width="36" Height="36" Background="#FFF5E9" CornerRadius="10">
                                <TextBlock Text="&#xea2e;" FontFamily="../Assets/Fonts/#iconfont"
                                       VerticalAlignment="Center" HorizontalAlignment="Center"
                                       FontSize="20" Foreground="#FFBC57"/>
                            </Border>
                            <StackPanel Margin="15,0,0,0">
                                <TextBlock Text="监控数据一" Foreground="#3F4C5D" FontSize="12"/>
                                <TextBlock Text="32%" FontWeight="Bold" Foreground="#3F4C5D" FontSize="16"/>
                            </StackPanel>
                        </StackPanel>
                    </Grid>
                </Border>