Replies: 12 comments
-
As you probably seen, delayed view is a very simple piece of code. So I'm afraid I would lean for a maui bug. You can try increase the delay to see if it changes something, or use a LazyView instead |
Beta Was this translation helpful? Give feedback.
-
ah , the curious thing is. This only occurs in release mode. When i am debugging, everything is displaying correct |
Beta Was this translation helpful? Give feedback.
-
Try increasing the delay then |
Beta Was this translation helpful? Give feedback.
-
I increased it, now the loading symbol of the delayedview is at least showing. but the view itself won´t show. Seems like i will try to use a lazyview at least for the first tab |
Beta Was this translation helpful? Give feedback.
-
Workaround is to put an empty and hidden StackLayout in first Position of the ViewSwitcher and handle the selectedTabIndex by myself |
Beta Was this translation helpful? Give feedback.
-
I solved this by adding an empty view in ViewSwitcher and an empty tab in the TabHostView. Problem now is the empty tab, even though it is hidden and has a width of 0, it still takes up space. Any ideas how to shrink the width to zero so it only fully "shows" 3 tabs? |
Beta Was this translation helpful? Give feedback.
-
Hey I have a similar problem and want to share some insights. OS: iOS I have a |
Beta Was this translation helpful? Give feedback.
-
Please this at your code behind |
Beta Was this translation helpful? Give feedback.
-
Hey, same problem here, maybe a different cause ; but here is what I have and for me the solution is rather straight forward : In the xaml page file : give the switcher a variable name in order to access it from the code behind <tabs:ViewSwitcher x:Name="Switcher">
<tabs:LazyView x:TypeArguments="views:MyView"
AccentColor="{StaticResource Primary}"
UseActivityIndicator="True">
</tabs:LazyView>
</tabs:ViewSwitcher> And in the Page implementation : protected override void OnAppearing()
{
base.OnAppearing();
// Forces the ViewSwitcher to trigger the SelectedIndexPropertyChanged event
Switcher.SelectedIndex = -1;
Switcher.SelectedIndex = _viewModel.SelectedViewModelIndex;
} The event is triggered like this in the codebase : SelectedIndexPropertyChanged This happens because when adding children in ViewSwitcher, by default they are hidden : protected override void OnChildAdded(Element child)
{
base.OnChildAdded(child);
if (child is View view)
{
HideView(view, Children.Count - 1);
}
} Original code can be found here. I don't know if that's the only reason for the tab not to show in the first place, flickering it like I'm doing is probably not the thing to do here, but for me it solved the issue quite well 😄 Shouldn't the first child tab be loaded and visible by default whenever the TabSwitcher is loaded (and displayed) ? |
Beta Was this translation helpful? Give feedback.
-
I have a similar issue on iOS only. First tab never gets the binding context set. Second one does. If I put a the following code in my ContentView, with a break point, the breakpoint gets hit when I change the tab but never for the first tab. I had to set my default value of the view model SelectedViewModelIndex to -1 and then add |
Beta Was this translation helpful? Give feedback.
-
Thanks for the tip, this workaround is working for me without messing with index -1 |
Beta Was this translation helpful? Give feedback.
-
My dudes in the ViewSwitcher the SelectedIndexProperty already default to -1. for example: public class BottomTabsPageViewModel : ANavigableViewModel
{
private int _selectedViewModelIndex = 0;
public BottomTabsPageViewModel(
INavigationService navigationService,
ISillyDudeService sillyDudeService,
ErrorEmulator errorEmulator)
: base(navigationService)
{
HomePageViewModel = new HomePageViewModel(navigationService, sillyDudeService);
GridPageViewModel = new GridPageViewModel(navigationService, sillyDudeService);
SelectedViewModelIndex = 2;
} will start the app with the 3rd bottom tabs selected (and lazy loaded). You can also directly set the SelectedIndex in the view constructor code behind: public partial class MainPage : ContentPage
{
public MainPage(BottomTabsPageViewModel viewModel)
{
InitializeComponent();
BindingContext = viewModel;
Switcher.SelectedIndex = 3;
}
private BottomTabsPageViewModel ViewModel => (BottomTabsPageViewModel)BindingContext;
} |
Beta Was this translation helpful? Give feedback.
-
Platform (please complete the following information):
Describe the bug
I am using DelayedViews in my TabSwitcher. When i am changing the layout from a FlexLayout to a Grid inside the DelayedView, the first tab will display nothing. When i open the next tab which is displaying the same kind of DelayedView(a new object from the same type) it gets displayed correctly.
only the first Tab with its content will not be displayed. There is no exception being thrown or displayed in the logcat
To Reproduce
Tabviewswitcher
`<tabs:ViewSwitcher x:Name="Switcher"
Animate="True"
SelectedIndex="{Binding SelectedViewModelIndex, Mode=TwoWay}">
DelayedView ContentView
`
....
`
Screenshots (if applicable)
First Page is not displayed
Scond Tab is displayed correctly with the same contentview
Beta Was this translation helpful? Give feedback.
All reactions