WPF編程,Live Charts使用說明(27)——進度

在這裏插入圖片描述

後臺

namespace Wpf.Gauges
{
    public partial class Gauge360
    {
        public Gauge360()
        {
            InitializeComponent();
        }
    }
}

前臺

<UserControl x:Class="Wpf.Gauges.Gauge360"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
             xmlns:gauges="clr-namespace:Wpf.Gauges"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance gauges:Gauge360}">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
 
        <!--normal gauge-->
        <lvc:Gauge Grid.Row="0" Grid.Column="0" Margin="5"
                   Uses360Mode="True"
                   From="0" To="100" Value="50" />
 
        <!--this gauge is rotated 90° and has an inverted clockwise fill-->
        <lvc:Gauge Grid.Row="0" Grid.Column="1" Margin="5"
                   Uses360Mode="True"
                   From="0" To="100" Value="50" >
            <lvc:Gauge.GaugeRenderTransform>
                <TransformGroup>
                    <RotateTransform Angle="90"></RotateTransform>
                    <ScaleTransform ScaleX="-1"></ScaleTransform>
                </TransformGroup>
            </lvc:Gauge.GaugeRenderTransform>
        </lvc:Gauge>
 
        <lvc:Gauge Grid.Row="1" Grid.Column="0" Margin="5"
                   Uses360Mode="True"
                   From="0" To="100" Value="20"
                   HighFontSize="60" Foreground="White"
                   InnerRadius="0" GaugeBackground="#BE54A3E9"/>
 
        <!--the next gauge interpolates from color white, to color black according
        to the current value in the gauge-->
        <lvc:Gauge Grid.Row="1" Grid.Column="1" Margin="5"
                   Uses360Mode="True"
                   From="0" To="100" Value="50"
                   HighFontSize="60" Foreground="#424242"
                   FromColor="White" ToColor="Black"
                   InnerRadius="0" GaugeBackground="Transparent">
        </lvc:Gauge>
 
        <!--standard gauge-->
        <lvc:Gauge Grid.Row="2" Grid.Column="0" Margin="5"
                   From="0" To="100" Value="50"/>
 
        <!--custom fill gauge-->
        <lvc:Gauge Grid.Row="2" Grid.Column="1"
                   From="0" To="100" Value="50"
                   LabelsVisibility="Collapsed">
            <lvc:Gauge.GaugeActiveFill>
                <LinearGradientBrush>
                    <GradientStop Color="Yellow" Offset="0.0" />
                    <GradientStop Color="Orange" Offset="0.5" />
                    <GradientStop Color="Red" Offset="1.0" />
                </LinearGradientBrush>
            </lvc:Gauge.GaugeActiveFill>
        </lvc:Gauge>
 
    </Grid>
</UserControl>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章