WPF 事件更新UI属性

1.代码部分

    //事件声明--VM类
    public class Temp1 : TempAbs
    {
        const Single Mutiple = 10f;

        public event EventHandler TempChange;
    }
        //事件订阅--UI类
        public Temperature(int i) : base()
        {
            InitializeComponent();
            tempAbs = applicationServices.VMTemps[i];
            InputSet = applicationServices.VMPipeSets[i];

            tempAbs.Fill(null);
            //事件订阅
            tempAbs.TempChange += WinVM_TempChange;
        }
        //事件订阅的具体业务--UI类
        //public async void WinVM_UserChange(object sender, int e)
        public void WinVM_TempChange(object sender, int e)
        {
            if (e > 0)
            {
                this.Dispatcher.BeginInvoke(new Action(() =>
                {
                    Temp1.ValueFloat = UserMath.ToSingle(e.ToString());
                    Temp2.ValueFloat = UserMath.ToSingle(e.ToString());
                    Temp3.ValueFloat = UserMath.ToSingle(e.ToString());
                    Temp4.ValueFloat = UserMath.ToSingle(e.ToString());
                    Temp5.ValueFloat = UserMath.ToSingle(e.ToString());
                }), null);
            }
        }
                    //事件业务执行--VM类
                    if (ShortValue[11] > 0)
                    {
                        TempChange(null, ShortValue[11]);
                    }

你可能感兴趣的:(WPF知识点,ui,wpf,c#)