Button Image Reset to Default

I have a column of 6 buttons I use to select the input media source for my receiver (please see attached Test_Deselect.hrp). Like others, I want to highlight my selected source button when clicked, leaving the other buttons in a default/deselected state. I have reviewed other approaches (e.g. [ How to efficiently change multiple buttons using one data trigger](https:// How to efficiently change multiple buttons using one data trigger)), and chose the “virtual device variable” approach.

On loading, each button is assigned a default “deselected” image. Each button also has an EventTrigger and a DataTrigger. When I click a button, the EventTrigger fires and assigns a unique “button ID” value to a variable PriActVar. The DataTrigger conditional tests for this button ID and also fires, explicitly loading a new “selected” button image.

If I click a new media source button, HR seems to automatically reset the old button image to its default/deselected state. But my buttons do NOT have a second Datatrigger to explicitly perform this “default image reset” operation.

I’m a huge fan of this HR behavior, but I can’t explain it with my limited knowledge of the triggers I’ve set up, so I’m leery of depending on it. I’m not sure if a DataTrigger has some property that invokes a default action if a conditional evaluates to FALSE. How can a button image change without an explicit action on my part?

Test_Deselect.hrp (1.5 MB)

1 Like

I have a similar question I have wondered about and never did find anything to explain how this action works. I see several objects have a Background color or resource defined in Properties and then will have a Data Trigger that is Bonded to @Device.Switch so when the .Switch is “On” a Setter will change the Background value. I cannot find a trigger to change the Background value when the .Switch changes to “Off”.

It seems to change the Setter value while .Switch is “On”, and then when .Switch changes back to “Off” the Setter action automatically is no longer active and the Background color defined in Properties is once again used.

I think your answer to your question will also answer mine being both are so similar so I added it here instead of a new post.

Jerry

What you are doing is perfectly fine & in fact that’s how almost all XAML pages are designed, not just Home Remote. It’s kind of hard to describe this without saying that’s just the way it is:) Since XAML was first introduced back in 2006 DataTriggers have always functioned this way. Think of DataTriggers as a temporary override. When the DataTrigger’s condition is no longer true, then it will reset back to its normal default state.

…and to try & further clarify. The values you define in the Properties pane above the Triggers box are your normal/default states. They are never lost. There’s an internal cache kept by the framework so those same values can be reapplied when the trigger is no longer active. This is all part of the XAML standard. You need not worry about this behavior ever changing.

Well thank you XAML, and thank you Bill! This is a great feature, and having it as a core capability of HR is just fantastic.
Terry