自定义控件之仪表盘gauge

 

gauge.xaml

<UserControl x:Class="WpfApplication5.gauge"

 

             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" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             xmlns:gauge="clr-namespace:CircularGauge;assembly=CircularGauge">
    <Grid>
        <gauge:CircularGaugeControl x:Name="myGauge1" Grid.Column="0" Grid.Row="0" 
                                        Radius="75"                                           
                                                  ScaleRadius="55"                         
                                                  ScaleStartAngle="180"                
                                                  CurrentValue="{Binding Score}"  
                                                  ScaleSweepAngle="180"           
                                        PointerLength="35"        
                                        PointerCapRadius="15" 
                                        MinValue="0" 
                                        MaxValue="100" 
                                        MajorDivisionsCount="10" 
                                        MinorDivisionsCount="5" 
                                        ImageSize="20,30"
                                        RangeIndicatorThickness="0"
                                        RangeIndicatorRadius="56"
                                        ScaleLabelRadius="65"
                                        ScaleLabelSize="18,10"
                                        ScaleLabelFontSize="8"
                                        ScaleLabelForeground="White"
                                        MajorTickSize="8,3"
                                        MinorTickSize="3,1"
                                        MajorTickColor="White"
                                        MinorTickColor="LightGray"
                                        GaugeBackgroundColor="Gray"
                                        PointerThickness ="5"
                                        OptimalRangeStartValue="30"
                                        OptimalRangeEndValue="90" 
                                        DialTextOffset="20" 
                                        DialTextColor="Black" >


        </gauge:CircularGaugeControl>
    </Grid>

 

</UserControl>

 

备注:

- Background 背景色设置,背景颜色会自动创建一个渐变和玻璃效果。 

 

- ScaleRadius 刻度位置的半径值,根据自己需要进行调制半径值达到调整刻度位置的目的。 
- ScaleLabelRadius 刻度标签的半径值。 
- RangeIndicatorRadius 刻度范围指示器的半径、 
- ImageOffset 外置图片的位置偏移。 
- DialTextOffset     标识的文本控件位置偏移。 
- DialText           文本内容,比如本文设置为 “mA”。 
- RangeIndicatorLightOffset 范围指示灯的位置偏移。 
- OptimalRangeStartValue 最佳范围的起始值,与OptimalRangeEndValue一起搭配使用

 

- OptimalRangeEndValue   最佳范围的终止值。 

                                        Radius="75"                                     表盘的半径值                                     
                                        ScaleRadius="55"                           刻度位置的半径值
                                        ScaleStartAngle="180"                  表盘刻度起始的位置
                                        CurrentValue="{Binding Score}"    表盘值
                                        ScaleSweepAngle="180"               表盘角度的覆盖范围。最大360度
                                        PointerLength="35"                         指针的长度
                                        PointerCapRadius="15"                 表盘中心原点的半径
                                        MinValue="0"                                    刻度最小值
                                        MaxValue="100"                               刻度最大值
                                        MajorDivisionsCount="10"               主盘刻度间隔10

                                        MinorDivisionsCount="5"                 副盘刻度间隔50.......................................

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

                                        ImageSize="20,30"
                                        RangeIndicatorThickness="0"           范围指示器 线粗
                                        RangeIndicatorRadius="56"              范围指示器的半径
                                        ScaleLabelRadius="65"                     刻度标签的半径值
                                        ScaleLabelSize="18,10"                     刻度标签的大小
                                        ScaleLabelFontSize="8"                       刻度标签字体的大小
                                        ScaleLabelForeground="White"            刻度标签字体的颜色
                                        MajorTickSize="8,3"
                                        MinorTickSize="3,1"
                                        MajorTickColor="White"
                                        MinorTickColor="LightGray"
                                        GaugeBackgroundColor="Gray"
                                        PointerThickness ="5"
                                        OptimalRangeStartValue="30"
                                        OptimalRangeEndValue="90" 
                                        DialTextOffset="20" 
                                        DialTextColor="Black" >

 

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值