Discussion What should a provider call when a property value changes?

  • Friday, August 31, 2012 5:46 PM
     
     

    Hi, I was recently asked a question about what event-related calls a UIA provider should make when a property value changes on an element. The question arose because given that the provider can call UiaRaiseAutomationPropertyChangedEvent() passing in the very useful data of the id of the property that changed along with the previous and new values of the property, why would the provider ever call UiaRaiseAutomationEvent() passing in UIA_AutomationPropertyChangedEventId? In the latter case, a client that received the event wouldn't even know what specific property had changed.

    In all the situations I've seen, the provider calls UiaRaiseAutomationPropertyChangedEvent(). This allows the client to often easily know everything it needs to about what's changed in the provider, and in some cases doesn't need to go back to the provider in response to the event to gather any more information. So I don't actually know of any scenario when UiaRaiseAutomationEvent() would be called with UIA_AutomationPropertyChangedEventId(). (That doesn't mean to say there aren't any legitimate scenarios, but I've not hit those myself yet. Maybe custom properties are somehow related to this, as I've never used them.)

    So I'd say if your provider wants to raise an event in response to a property value changing, call UiaRaiseAutomationPropertyChangedEvent().

    Thanks,

    Guy