Handle event when Label Text Change

前端 未结 2 985
执笔经年
执笔经年 2021-01-28 17:24

I\'m developing App which communicate with RFID Reader, I have the following Label which takes it\'s value from the Reader (when I click on the read button on the hardware)

2条回答
  •  遥遥无期
    2021-01-28 17:36

    What you can do is on whatever page/view your label is on create a new bindableproperty that is set to your binding. Then add a propertyChanged method that will get called if the text on your label changes.

     public static BindableProperty TextChangedProperty = BindableProperty.Create(nameof(TextChanged), typeof(string), typeof(YourView), string.Empty,  propertyChanged:OnTextChanged);
    
     public string TextChanged
     {
         get { return (string)GetValue(TextChangedProperty); }
         set { SetValue(TextChangedProperty, value); }
     }
    
     static void OnTextChanged(BindableObject bindable, object oldValue, object newValue)
     {
        //Do stuff
     }
    

提交回复
热议问题