samc
Topic Author
Posts: 43
Joined: 21 Aug 2019, 19:22

Trigger seems to be activating even though data model shouldnt be triggering it

04 Aug 2022, 20:29

We're hitting a very odd bug right now that I'm not sure how to explain. I'll start with our xaml and data model setup..

We have a top-level variable in our model named "GameStateName" -- which tells us where the player is -- ie, playing, in menus, etc.

In our top-level xaml, we have a bunch of data triggers that look at that variable and then switch parts of the UI to be visible/not visible:
        <b:DataTrigger Binding="{Binding Player.GameStateName}" Comparison="Equal" Value="{x:Static definitions:GameStateName.Teams}">
            <b:ChangePropertyAction x:Name="StateTeams_ShowTeams" TargetName="Teams" PropertyName="Visibility" Value="Visible"/>
            <b:ChangePropertyAction x:Name="StateTeams_HideInteract" TargetName="Interact" PropertyName="Visibility" Value="Hidden"/>
        </b:DataTrigger>
Every time our game state changes, we have debug logging.

So, the weird thing that is happening is that the "Teams" view in the little code block above is somehow becoming visible, even though the game state is not (and hasn't ever been) GameStateName.Teams. I've checked and I don't see anywhere else in our code where we make this piece of UI visible except right here.

The weird thing -- this is not consistent at all. The only time we see this happening is when you are observing other players and cycling through them. In that case, obviously a lot of the UI and data model are changing, but the game state name is NOT changing in those cases. I just mention this because this bug seems to be related to "a lot of other stuff changing in the data model".

For the top-level XAML, nearly all the data triggers are related to the GameStateName, but there are a few other data triggers related to properties on the observed player.

Any suggestions about how I could go about debugging this? Is there a logging level that would help explain why some of these data triggers seem to be activating even though they shouldn't?

thanks!
sam
 
User avatar
sfernandez
Site Admin
Posts: 2665
Joined: 22 Dec 2011, 19:20

Re: Trigger seems to be activating even though data model shouldnt be triggering it

08 Aug 2022, 16:57

Hi Sam, I see in HUD.xaml that "Teams" view is initially visible. If the "GameStateName" doesn't go through the "Playing" state where the data trigger sets that view to collapsed then it will be visible even if the state is never set to "Teams".

Could that be what you are seeing?
 
samc
Topic Author
Posts: 43
Joined: 21 Aug 2019, 19:22

Re: Trigger seems to be activating even though data model shouldnt be triggering it

10 Aug 2022, 00:55

I don't think that's what is happening; unless somehow the XAML is being reset to it's default state somehow. Would that just be the case when the XAML is initially loaded, or is there something else we might be doing to reset it to the default state?

thanks,
sam
 
User avatar
sfernandez
Site Admin
Posts: 2665
Joined: 22 Dec 2011, 19:20

Re: Trigger seems to be activating even though data model shouldnt be triggering it

10 Aug 2022, 18:53

When the HUD xaml is loaded for the first time the "Teams" view will be visible, as its Visibility property is not set and the default value is Visible.

The easiest way to debug this is by adding a Rectangle in the HUD.xaml and change its Fill to another color in the DataTrigger that makes Teams visible. My guess is that the trigger is not being executed and the rectangle doesn't change its color in the situation you are describing.
<ei:DataTrigger Binding="{Binding Player.GameStateName}" Comparison="Equal" Value="{x:Static definitions:GameStateName.Teams}">
  <ei:ChangePropertyAction x:Name="StateTeams_ShowTeams" TargetName="Teams" PropertyName="Visibility" Value="Visible"/>
  <ei:ChangePropertyAction x:Name="StateTeams_HideInteract" TargetName="Interact" PropertyName="Visibility" Value="Hidden"/>
  <ei:ChangePropertyAction TargetName="rect" PropertyName="Fill" Value="Red"/>
</ei:DataTrigger>
Could you please verify that?

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Semrush [Bot] and 2 guests