英文:
Sharpnado Tabs First Tab is not showing
问题
我正在使用TabSwitcher中的DelayedViews。当我将布局从FlexLayout更改为DelayedView内部的Grid时,第一个选项卡将不显示任何内容。当我打开下一个选项卡时,它显示了正确的内容,该选项卡也显示了相同类型的DelayedView(来自相同类型的新对象)。
只有第一个带有其内容的选项卡将不会显示。没有任何异常被抛出或在logcat中显示。
重现步骤
Tabviewswitcher
<tabs:ViewSwitcher x:Name="Switcher"
Animate="True"
SelectedIndex="{Binding SelectedViewModelIndex, Mode=TwoWay}">
<tabs:DelayedView x:TypeArguments="contentViews:LobiPageView"
AccentColor="White"
BindingContext="{Binding Page1ViewModel}"
Animate="True"
UseActivityIndicator="True" />
<tabs:DelayedView x:TypeArguments="contentViews:LobiPageView"
BindingContext="{Binding Page2ViewModel}"
AccentColor="{StaticResource Primary}"
Animate="True"
UseActivityIndicator="True" />
<tabs:DelayedView x:TypeArguments="contentViews:LobiPageView"
BindingContext="{Binding Page3ViewModel}"
AccentColor="{StaticResource Primary}"
Animate="True"
UseActivityIndicator="True" />
<tabs:DelayedView x:TypeArguments="contentViews:LobiPageView"
BindingContext="{Binding Page4ViewModel}"
AccentColor="{StaticResource Primary}"
Animate="True"
UseActivityIndicator="True" />
<tabs:DelayedView x:TypeArguments="contentViews:LobiPageView"
BindingContext="{Binding Page5ViewModel}"
AccentColor="{StaticResource Primary}"
Animate="True"
UseActivityIndicator="True" />
</tabs:ViewSwitcher>
DelayedView ContentView
<StackLayout>
<Grid BindableLayout.ItemsSource="{Binding PageItems}" >
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<BindableLayout.ItemTemplate>
<DataTemplate>
.....
</DataTemplate>
</Grid>
</StackLayout>
截图(如果适用)
第一页未显示
第二个选项卡显示了相同内容的正确内容
英文:
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}">
<tabs:DelayedView x:TypeArguments="contentViews:LobiPageView"
AccentColor="White"
BindingContext="{Binding Page1ViewModel}"
Animate="True"
UseActivityIndicator="True" />
<tabs:DelayedView x:TypeArguments="contentViews:LobiPageView"
BindingContext="{Binding Page2ViewModel}"
AccentColor="{StaticResource Primary}"
Animate="True"
UseActivityIndicator="True" />
<tabs:DelayedView x:TypeArguments="contentViews:LobiPageView"
BindingContext="{Binding Page3ViewModel}"
AccentColor="{StaticResource Primary}"
Animate="True"
UseActivityIndicator="True" />
<tabs:DelayedView x:TypeArguments="contentViews:LobiPageView"
BindingContext="{Binding Page4ViewModel}"
AccentColor="{StaticResource Primary}"
Animate="True"
UseActivityIndicator="True" />
<tabs:DelayedView x:TypeArguments="contentViews:LobiPageView"
BindingContext="{Binding Page5ViewModel}"
AccentColor="{StaticResource Primary}"
Animate="True"
UseActivityIndicator="True" />
</tabs:ViewSwitcher>
DelayedView ContentView
<StackLayout>
<Grid BindableLayout.ItemsSource="{Binding PageItems}" >
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<BindableLayout.ItemTemplate>
<DataTemplate>
....
</DataTemplate>
</Grid>
</stackLayout>
Screenshots (if applicable)
First Page is not displayed
Scond Tab is displayed correctly with the same contentview
答案1
得分: 0
这似乎是一个Maui的bug。
解决方法是自己处理所选的TabIndex,并在TabviewSwitcher的第一个索引上隐藏一个空的StackLayout。
英文:
This seems to be a maui bug.
The Workaround is to handle the selectted TabIndex by myself and hide an empty StackLayout on the first index of the TabviewSwitcher
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论