Updating Test Step Settings within code

Hello,

I have a button in my Test Step Settings and this performs some queries on an instrument and guides me through some selections I have to make. Those selections are then used for the properties (string, int) and therefore overwritten in code. Everything works as expected when I execute the test however after overwriting the properties in code the UI is not being updated. Is there a way to force an update of the UI which shows the Test Step Settings?

Hi @kreibich,

It depends a bit on how you do it.
If it’s done in a blocking fashion when clicking the button, it should just work.

If it’s done asynchronously, you need to notify the UI that the property has been changed. This is often done through OnPropertyChanged.

Here’s an example:

        [Browsable(true)]
        public int ButtonClickedNumberOfTimes { get; private set; }
        
        [Browsable(true)]
        public void ButtonAsync()
        {
            TapThread.Start(() =>
            {
                TapThread.Sleep(1000);
                ButtonClickedNumberOfTimes += 1;
                
                // UI cannot know the property was changed out of band.
                // So we need to tell the UI about the updated property
                OnPropertyChanged(nameof(ButtonClickedNumberOfTimes));
            });
        }
        [Browsable(true)]
        public void ButtonSync()
        {
            ButtonClickedNumberOfTimes += 1;
            // No need to tell the UI about this - It knows we clicked a button so it will check for updates for us.
            // OnPropertyChanged(nameof(ButtonClickedNumberOfTimes));
        }

thanks for your answer!

I noticed that my project had a reference to TAP 9.9.2 where it didn’t work. Switching to the latest version everything works as expected and the refresh works!