[Bug] StateLayout does not load initial state other than None
Description
When StateLayout is presented it always defaults to the None View regardless what is set in CurrentState. I maybe using this wrong but surely if I set CurrentState to Success, it would default to that view.
Steps to Reproduce
- Create a basic StateLayout, with 1 or more Views and add something to the "None" View
- Set StateLayout.CurrentState="Success" or whatever Views we created other than None
- When the page is presented it shows the None View.
Expected Behavior
I'd expect to see the View I set in CurrentState.
Actual Behavior
StateView always default's to None.
Basic Information
- Version with issue: 1.0.3
- Last known good version: none
- IDE: VS 2109 16.8.4
- Platform Target Frameworks:
- iOS: not tested
- Android: 8.1 API 27
- UWP: not tested
I've not created a sample demo as Its very easy to reproduce.
Hi @henda79 thanks for reporting, could you please attach a reproduction repo? I have tried reproduce it in the sample App but was working as expected.
Hey @Cfun1, I thought it would have been easy to replicate as I had the issue pretty much OOB.
I've added it in my demo app which I use to report bugs to Syncfusion, so just ignore most of it. You'll see it loads to the 'None' View State Despite been explicitly set in the XAML.
Here's a link to it on my GitHub: https://github.com/henda79/ListViewDemo
I can confirm the described issue.
@Cfun1 not the same with #1122?
@AndreiMisiukevich no not the same, in this issue when State="Success" (other than the default one None) following OnCurrentStateChanged oldValue = None, newValue = Success, up to here good but in StateViews is still empty at that point.
https://github.com/xamarin/XamarinCommunityToolkit/blob/f52349cebb3db02d695028e05cd295de73951426/src/CommunityToolkit/Xamarin.CommunityToolkit/Views/StateLayout/StateLayoutController.shared.cs#L67
CC @sthewissen
I experienced this issue (or at least a very similar one) while the AnimateStateChanges property was set to true. It was causing my default "None" view to always appear first, no matter what my initial bound CurrentState was set to, resulting in an ugly flash of unloaded content before my Loading state appeared.
Setting AnimateStateChanges="False" made my intended initial state (Loading) correctly appear first.
I also have the same issue. The layout does not change for any properties. Thus far, setting the animation to false has not helped either.
I opened this 2 years ago, I can't see it getting any attention as all focus is on MAUI. You could just use this a base for your own control and change the behaviour as desired.