Xamarin.Forms:带有 Sharnado.presentation.forms 的选项卡不响应点击
Xamarin.Forms: Tabs with Sharnado.presentation.forms do not respond to tap
我正在尝试使用 Sharpnado's awesome tab 功能来创建他们所谓的 "Fixed tabs"。但它没有按照我的意愿行事 - 问题可能出在其他地方......基本上,选项卡没有响应点击。我已经通过这个简单的示例将范围缩小到仅此范围。
上下文是一个使用普通标签页(每个标签都有导航页)的应用程序。在其中一个选项卡上,我试图放置 TabHostView
控件 - 即使没有绑定,因为我最初认为这是问题所在。这是测试页面的截图:
点击两个选项卡("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 用于 Mac 8.3.4(build 8)、Sharpnado.presentations.forms 1.3.0 和 Prism.forms 7.2.0.1367。
我已尝试将 InputTransparent="True"
添加到某些容器对象 - 但没有效果。
非常感谢有关如何解决此问题的任何好主意!
好吧,这太愚蠢了(浪费了两天时间!)...
在尝试解决其他问题时,我退回了我的源代码库 - 有一次退得太远了......所以平台项目中的 Sharpnado 初始化不存在。这种情况有所不同。
因此,如果您没有记得将此行添加到您的平台项目,您将会看到这种行为:
SharpnadoInitializer.Initialize()
就把它留在这里以防其他人出现相同的症状:-)
我正在尝试使用 Sharpnado's awesome tab 功能来创建他们所谓的 "Fixed tabs"。但它没有按照我的意愿行事 - 问题可能出在其他地方......基本上,选项卡没有响应点击。我已经通过这个简单的示例将范围缩小到仅此范围。
上下文是一个使用普通标签页(每个标签都有导航页)的应用程序。在其中一个选项卡上,我试图放置 TabHostView
控件 - 即使没有绑定,因为我最初认为这是问题所在。这是测试页面的截图:
<?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 用于 Mac 8.3.4(build 8)、Sharpnado.presentations.forms 1.3.0 和 Prism.forms 7.2.0.1367。
我已尝试将 InputTransparent="True"
添加到某些容器对象 - 但没有效果。
非常感谢有关如何解决此问题的任何好主意!
好吧,这太愚蠢了(浪费了两天时间!)...
在尝试解决其他问题时,我退回了我的源代码库 - 有一次退得太远了......所以平台项目中的 Sharpnado 初始化不存在。这种情况有所不同。
因此,如果您没有记得将此行添加到您的平台项目,您将会看到这种行为:
SharpnadoInitializer.Initialize()
就把它留在这里以防其他人出现相同的症状:-)