WPF 自定义控件--仪表盘

仪表盘:

WPF 自定义控件--仪表盘_第1张图片

  可根据数值调整颜色,绿色:正常,黄色:预警、红色:警告。图示仪表盘数值绑定Slider的Value。 

  依赖属性注册:

  [Category("值设定")]
        public Brush ShowBrush
        {
            get { return (Brush)GetValue(ShowBrushPropertyProperty); }
            set { SetValue(ShowBrushPropertyProperty, value); }
        }
        public static readonly DependencyProperty ShowBrushPropertyProperty =
            DependencyProperty.Register("ShowBrush", typeof(Brush), typeof(ArcGauge), new PropertyMetadata(Brushes.Green, OnValueChanged));

ShowBrush可在样式中(仪表盘)绑定:

你可能感兴趣的:(wpf)