A Microsoft framework for building cross-platform mobile apps using .NET and C# with native performance and user interfaces.
@Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.)
Today in MAUI there is the same problem. I explain our problem, I have this layout:
<DataTemplate>
<SwipeView>
<SwipeView.BotomItems>
<Border> here inside is my layout </Border
</SwipeView>
</DataTemplate>
If I put this code
<VisualStateManager.VisualStateGroups>
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="{DynamicResource primary}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="{DynamicResource black025}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</VisualStateManager.VisualStateGroups>
Before </Swipeview> It changes the backgorund underneath my layout aka border because it changes the background color of the SWIPE ! while I need to change the background color of the <Border> to see it visually in UI !
If I move the visual state before </Border> it doesn't work.
So I neet to change the visual state of my element in order that user have a visual feedback, otherwise the swipe is underneath my layout, visible only if I swipe.
SOLUTION:
Add
<Border x:Name="RootBorder"
Then add TargetName to redirect to the desired object.
<VisualStateManager.VisualStateGroups>
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter TargetName="RootBorder" Property="BackgroundColor" Value="Red" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter TargetName="RootBorder" Property="BackgroundColor" Value="White" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</VisualStateManager.VisualStateGroups>