使用Xamarin Forms在工具栏中嵌套菜单

时间:2017-10-11 06:10:23

标签: xamarin.ios xamarin.forms xamarin.android xamarin.uwp

我想创建带有子菜单项的工具栏。它可以在Xamarin.Android天真地完成,但我想在IOS和UWP中实现这样一种功能。我没有提到可扩展的列表项。它应该类似于子菜单。

enter image description here

我使用下面的代码

在Xamarin.Android中创建了这个
<?xml version="1.0" encoding="UTF-8" ?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:AMCSMobile="http://schemas.android.com/apk/res-auto">
  <!-- Route View - Action Bar Menu -->
  <item
    android:id="@+id/RouteView_ActionButton_Messages"
    android:icon="@drawable/ic_action_read_light"
    AMCSMobile:showAsAction="always|withText"
    android:title="@string/ScheduleView_ActionButton_Messages" />

  <item
      android:id="@+id/RouteView_ActionButton_Tracking"
      android:icon="@drawable/ic_action_location_found_light"
      AMCSMobile:showAsAction="ifRoom"
      android:title="@string/RouteView_Button_TrackingOn" />

  <item
      android:id="@+id/RouteView_ActionButton_StartBreak"
      android:icon="@drawable/ic_action_pause_light"
      AMCSMobile:showAsAction="ifRoom"
      android:title="@string/RouteView_Button_StartBreak" />

  <item
      android:id="@+id/RouteView_ActionButton_Complete"
      android:icon="@drawable/ic_action_accept_light"
      AMCSMobile:showAsAction="ifRoom"
      android:title="@string/RouteView_Button_Complete" />


  <item
    android:id="@+id/RouteView_ActionButton_EventSelection"
    android:icon="@drawable/ic_action_new_event_light"
    AMCSMobile:showAsAction="always"
    android:title="@string/ScheduleView_ActionButton_Event"
      >
    <menu>
      <item
        android:id="@+id/RouteView_ActionButton_Event_RecordRefuelEvent"
        android:icon="@drawable/ic_action_refresh_light"
        android:title="@string/ScheduleView_ActionButton_Event_RecordRefuelEvent" />
      <item
        android:id="@+id/RouteView_ActionButton_Event_RecordDisposalEvent"
        android:icon="@drawable/ic_action_discard_light"
        android:title="@string/ScheduleView_ActionButton_Event_RecordDisposalEvent" />
      <item
        android:id="@+id/RouteView_ActionButton_Event_RecordMiscEvent"
        android:icon="@drawable/ic_action_help_light"
        android:title="@string/ScheduleView_ActionButton_Event_RecordMiscEvent" />
      <item
        android:id="@+id/RouteView_ActionButton_Event_RecordBlockageEvent"
        android:icon="@drawable/ic_action_warning_light"
        android:title="@string/ScheduleView_ActionButton_Event_RecordBlockageEvent" />
    </menu>
  </item>

  <item
      android:id="@+id/RouteView_ActionButton_Commute"
      android:icon="@drawable/ic_action_split_light"
      AMCSMobile:showAsAction="never"
      android:title="@string/RouteView_Button_ShowCommute" />

  <item
      android:id="@+id/RouteView_ActionButton_Logout"
      android:icon="@drawable/ic_action_back_light"
      AMCSMobile:showAsAction="never"
      android:title="@string/RouteView_Button_Logout" />

</menu>

我想知道是否可以在其他平台(IOS和UWP)中进行此操作。请告诉我你的建议。

0 个答案:

没有答案