Page 1 of 1

audio when user controls appear / disappear

Posted: 18 Sep 2025, 03:04
by samc
We've been using the audio hooks on buttons, but we'd like to integrate audio better into our app and aren't sure how to do it.

We'd like trigger audio when a user control / screen appears and when a user control / screen disappears. Is there a best practice / best way to do this?

I saw this thread: viewtopic.php?p=16824 and tried to see if I could do something similar for visibility changing to collapse or to visibile..

Is there an EventTrigger I can wire up to handle this? I noticed on https://www.noesisengine.com/docs/Gui.C ... tml#events that there is an IsVisibleChanged event, but I'm not sure how to test against the new visibility value here for this event.

Suggestions on how to accomplish this? Maybe there is a completely separate way that would be best to do this?

thanks,
sam

Re: audio when user controls appear / disappear

Posted: 18 Sep 2025, 17:49
by sfernandez
If you need to do different actions when IsVisible is true vs when it is false you should use a DataTrigger instead of an EventTrigger:
<Grid x:Name="LayoutRoot">
  <b:Interaction.Triggers>
    <b:DataTrigger Binding="{Binding IsVisible, ElementName=LayoutRoot}" Value="True">
      <audio:AudioAction .../>
    </b:DataTrigger>
    <b:DataTrigger Binding="{Binding IsVisible, ElementName=LayoutRoot}" Value="False">
      <audio:AudioAction .../>
    </b:DataTrigger>
  </b:Interaction.Triggers>
  ...
</Grid>
Is this what you're looking for?

Re: audio when user controls appear / disappear

Posted: 18 Sep 2025, 18:05
by samc
This looks great! let me give this a shot!

thanks,
sam