我目前正在开发一个复杂的业务应用程序,其中包含主要主题和子主题/视图。
我想要实现的是该应用程序内对所有页面的高性能导航。
使用汉堡菜单不是一种选择。
现在我已经拥有的是我的自定义选项卡式页面导航。
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Company.Core.Views.MainView"
xmlns:views="clr-namespace:Company.Core.Views"
xmlns:viewModelBase="clr-namespace:Company.Core.ViewModels.Base"
xmlns:controls="clr-namespace:Company.Core.Controls"
BarBackgroundColor="{StaticResource DarkGreenColor}"
BackgroundColor="{StaticResource BackgroundColor}"
BarTextColor="{StaticResource WhiteColor}"
viewModelBase:ViewModelLocator.AutoWireViewModel="true">
<TabbedPage.Title>
<OnPlatform
x:TypeArguments="x:String"
iOS="App Name"
WinPhone="App Name"/>
</TabbedPage.Title>
<ContentPage.ToolbarItems>
<ToolbarItem
Command="{Binding SettingsCommand}"
Text="Settings">
<ToolbarItem.Icon>
<OnPlatform
x:TypeArguments="FileImageSource"
WinPhone="Assetsapp_settings.png"
Android="app_settings"
iOS="app_settings"/>
</ToolbarItem.Icon>
</ToolbarItem>
</ContentPage.ToolbarItems>
<views:HomePageView
x:Name="HomeView">
<views:HomePageView.Icon>
<OnPlatform
x:TypeArguments="FileImageSource"
Android="menu_filter"
iOS="menu_filter"
WinPhone="Assets/test.png"/>
</views:HomePageView.Icon>
</views:HomePageView>
<views:EmployeesView
x:Name="EmployeesView">
<views:EmployeesView.Icon>
<OnPlatform
x:TypeArguments="FileImageSource"
Android="menu_filter"
iOS="menu_filter"
WinPhone="Assets/personalliste.png"/>
</views:EmployeesView.Icon>
</views:EmployeesView>
<views:MonthlySalaryView
x:Name="MonthlySalaryView">
<views:MonthlySalaryView.Icon>
<OnPlatform
x:TypeArguments="FileImageSource"
Android="bvg"
iOS="bvg"
WinPhone="Assets/bvg.png"/>
</views:MonthlySalaryView.Icon>
</views:MonthlySalaryView>
<views:CompanyDataView
x:Name="CompanyDataView">
<views:CompanyDataView.Icon>
<OnPlatform
x:TypeArguments="FileImageSource"
Android="DTA"
iOS="DTA"
WinPhone="Assets/DTA.png"/>
</views:CompanyDataView.Icon>
</views:CompanyDataView>
有了这个和这样的自定义呈现(使用 UWP 作为示例(:
<UserControl
x:Name="Control"
x:Class="Company.Core.UWP.Controls.TabItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Company.Core.UWP.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="600">
<UserControl.Resources>
<ResourceDictionary>
<Style x:Key="TabMainPanelStyle" TargetType="StackPanel">
<Setter Property="Height" Value="48" />
<Setter Property="Width" Value="150" />
</Style>
<Style x:Key="TabIconStyle" TargetType="Image">
<Setter Property="Height" Value="20" />
<Setter Property="Width" Value="20" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="Margin" Value="0, 4" />
</Style>
<Style x:Key="TabTextStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="White" />
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontSize" Value="12" />
<Setter Property="LineStackingStrategy" Value="BlockLineHeight" />
<Setter Property="LineHeight" Value="14" />
<Setter Property="MaxLines" Value="2" />
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="Margin" Value="2,5,2,7" />
</Style>
<Style x:Key="TabBadgeStyle" TargetType="Grid">
<Setter Property="Height" Value="16" />
<Setter Property="Width" Value="16" />
<Setter Property="CornerRadius" Value="24" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Margin" Value="6, 2, 0, 6" />
</Style>
<Style x:Key="BadgeTextStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="White" />
<Setter Property="FontSize" Value="10" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<StackPanel
Style="{StaticResource TabMainPanelStyle}">
<!-- TAB ICON -->
<Image
Source="{Binding ElementName=Control, Path=Icon}"
Style="{StaticResource TabIconStyle}"/>
<!-- TAB TEXT -->
<TextBlock
Text="{Binding ElementName=Control, Path=Label}"
Style="{StaticResource TabTextStyle}" />
占 位 符
</StackPanel>
<!-- TAB BADGE -->
<Grid
Background="{Binding ElementName=Control, Path=BadgeColor}"
Style="{StaticResource TabBadgeStyle}">
<TextBlock
Text="{Binding ElementName=Control, Path=BadgeText}"
Style="{StaticResource BadgeTextStyle}"/>
</Grid>
</Grid>
然后我把这段代码放在"占位符"中
<ListView>
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Border Background="LightGray" Height="200" Width="200">
<TextBlock Text="{Binding}"
FontSize="48" Foreground="Green"/>
</Border>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.Items>
<x:String>One</x:String>
<ListViewItem>Two</ListViewItem>
</ListView.Items>
</ListView>
现在我正在尝试实现的是一些菜单,当我单击我的选项卡时,我有一个下拉菜单。
我怎样才能做到这一点?
我知道
Xamarin.Forms中没有可用的下拉列表,但相当于Xamarin.Forms中的下拉列表是一个选择器。您可以使用它来显示您希望用户从中进行选择的选项列表。我希望我理解了你的问题,如果不让我知道