【发布时间】:2019-10-27 00:51:56
【问题描述】:
我正在尝试使用Sharpnado's awesome tab 功能来创建他们所谓的“固定标签”。但它并没有按照我的意愿做 - 问题可能出在其他地方......基本上,选项卡没有响应点击。通过这个简单的示例,我将其范围缩小到了这一点。
上下文是一个使用普通标签页的应用程序(每个标签页都有导航页)。在其中一个选项卡上,我尝试放置 TabHostViewcontrol - 即使没有绑定,因为我最初认为这是问题所在。这是测试页面的截图:
当我点击两个选项卡(“Personlig”和“Udforsk”)时,什么也没有发生。 XAML 如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:tabs="clr-namespace:Sharpnado.Presentation.Forms.CustomViews.Tabs;assembly=Sharpnado.Presentation.Forms"
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
ios:Page.UseSafeArea="true"
xmlns:views="clr-namespace:Angler.Views.Partials"
x:Class="Angler.Views.StatisticsPage">
<NavigationPage.TitleView>
<Label Text="{Binding Title}" HorizontalOptions="Center"
VerticalOptions="Center" Style="{StaticResource PageTitle}" />
</NavigationPage.TitleView>
<StackLayout VerticalOptions="FillAndExpand" BackgroundColor="LightYellow">
<Label Text="{Binding ShowSelectedTab}" Margin="20,10" />
<Grid RowSpacing="0" ColumnSpacing="0" Margin="0"
BackgroundColor="LightPink" VerticalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<tabs:TabHostView ShadowType="Bottom" Grid.Row="0">
<tabs:TabHostView.Tabs>
<tabs:UnderlinedTabItem Label="Personlig" />
<tabs:UnderlinedTabItem Label="Udforsk" IsSelected="True" />
</tabs:TabHostView.Tabs>
</tabs:TabHostView>
</Grid>
</StackLayout>
</ContentPage>
viewmodel 看起来像这样(尽管上面已经缩小到不使用 tabindex 的属性。但我也调查了 viewmodel 的绑定上下文是否正常 - 似乎是这样):
public class StatisticsPageViewModel : ViewModelBase
{
public int SelectedTabIndex { get; set; }
public string ShowSelectedTab { get { return $"Index: {SelectedTabIndex}"; } }
public StatisticsPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService,
IDeviceService deviceService) : base(navigationService, pageDialogService,
deviceService)
{
Title = AppResources.StatisticsPageTitle;
}
public override void OnAppearing()
{
//SelectedTabIndex = 1;
base.OnAppearing();
Analytics.TrackEvent("Navigate to Statistics");
}
}
我正在使用 VisualStudio for Mac 8.3.4(内部版本 8)、Sharpnado.presentations.forms 1.3.0 和 Prism.forms 7.2.0.1367。
我已尝试将 InputTransparent="True" 添加到某些容器对象 - 没有效果。
任何关于如何解决这个问题的好主意都非常感谢!
【问题讨论】:
标签: xamarin.forms tabs