使用  Rg.Plugins.Popup 插件

1.  新建 PopupMenu.xaml

<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
xmlns:iconize="clr-namespace:Plugin.Iconize;assembly=Plugin.Iconize"
x:Class="DCMS.Client.Views.CustomView.PopupMenu" x:Name="PopupMaster">
<pages:PopupPage.Resources>
<ResourceDictionary>
<Style x:Key="EntryStyle"
TargetType="Entry">
<Setter Property="PlaceholderColor"
Value="#9cdaf1" />
<Setter Property="TextColor"
Value="#7dbbe6" />
</Style>
</ResourceDictionary>
</pages:PopupPage.Resources>
<pages:PopupPage.Animation>
<animations:ScaleAnimation PositionIn="Top"
PositionOut="Center"
ScaleIn=""
ScaleOut="0.7"
DurationIn=""
EasingIn="BounceOut" />
</pages:PopupPage.Animation>
<ScrollView HorizontalOptions="End"
VerticalOptions="Start">
<AbsoluteLayout Margin="0,45,0,0"
x:Name="MainLayout">
<Frame x:Name="FrameContainer"
Margin="0,10,10,0"
HorizontalOptions="Center"
BorderColor="Transparent"
BackgroundColor="White">
<ListView x:Name="SecondaryToolbarListView"
VerticalOptions="Start"
HorizontalOptions="Start"
WidthRequest=""
HasUnevenRows="True"
ItemsSource="{Binding Source={x:Reference PopupMaster},Path=MenuItems}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal"
HorizontalOptions="FillAndExpand"
Margin=""
Spacing=""
HeightRequest=""
Padding="15,0,0,0">
<iconize:IconImage x:Name="iconImage"
Icon="{Binding Icon}"
HorizontalOptions="Start"
VerticalOptions="Center"
Margin="0,0,8,0"
IconColor="{StaticResource PrimaryDarkColor}"
IconSize="" />
<Label x:Name="menuText"
Text="{Binding MenuText}"
FontSize=""
VerticalOptions="Center"
HorizontalOptions="Start" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Frame>
<ContentView AbsoluteLayout.LayoutFlags="XProportional"
AbsoluteLayout.LayoutBounds=".8,5, 15, 15">
<ContentView.GestureRecognizers>
<TapGestureRecognizer Tapped="OnCloseButtonTapped" />
</ContentView.GestureRecognizers>
<BoxView HeightRequest=""
x:Name="CloseImage"
WidthRequest=""
BackgroundColor="White"></BoxView>
</ContentView>
</AbsoluteLayout>
</ScrollView>
</pages:PopupPage>
     [XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PopupMenu : PopupPage
{
private List<ToolbarItemModel> MenuItems { get; set; }
public PopupMenu (List<ToolbarItemModel> data)
{
InitializeComponent ();
MenuItems = data;
} protected override void OnAppearing()
{
base.OnAppearing();
SecondaryToolbarListView.ItemsSource = MenuItems;
SecondaryToolbarListView.HeightRequest = MenuItems.Count * ;
} protected override void OnAppearingAnimationBegin()
{
base.OnAppearingAnimationBegin();
CloseImage.Rotation = ;
//CloseImage.TranslationY = -10;
MainLayout.RaiseChild(CloseImage);
} private void OnCloseButtonTapped(object sender, EventArgs e)
{
CloseAllPopup();
} protected override bool OnBackgroundClicked()
{
CloseAllPopup(); return false;
} private async void CloseAllPopup()
{
await PopupNavigation.Instance.PopAllAsync();
}
}

2.  在需要添加Toolbar 的页面中  添加 菜单项。

  public partial class SaleBillPage : ContentPage
{ private PopupMenu _popupMenu; public SaleBillPage()
{
InitializeComponent(); var items = new List<ToolbarItemModel>
{
new ToolbarItemModel {Icon = "fas-list-alt", MenuText = "历史单据"},
new ToolbarItemModel {Icon = "fas-list-alt", MenuText = "支付方式"},
new ToolbarItemModel {Icon = "fas-list-alt", MenuText = "欠款"},
new ToolbarItemModel {Icon = "fas-list-alt", MenuText = "优惠"},
new ToolbarItemModel {Icon = "fas-list-alt", MenuText = "整单备注"},
new ToolbarItemModel {Icon = "fas-list-alt", MenuText = "清空单据"},
new ToolbarItemModel {Icon = "fas-list-alt", MenuText = "打印"},
}; _popupMenu = new PopupMenu(items);
} #region Overrides protected override void OnAppearing()
{
base.OnAppearing();
this.ToolbarItems.Clear();
foreach (var toolBarItem in GetToolBarItems().ToList())
{
this.ToolbarItems.Add(toolBarItem);
}
} #endregion private IList<ToolbarItem> GetToolBarItems()
{
var list = new List<ToolbarItem>();
list.Add(new ToolbarItem("\uf0c7", "", () =>
{
Device.BeginInvokeOnMainThread(() =>
{
DisplayAlert("提示", "抱歉,功能稍后开放...", "取消");
});
},ToolbarItemOrder.Primary, ));
list.Add(new ToolbarItem("\uf0c9", "", () =>
{
Device.BeginInvokeOnMainThread(async () =>
{
await PopupNavigation.Instance.PushAsync(_popupMenu);
});
}, ToolbarItemOrder.Primary, )); return list;
}
}

效果如图:

Xamarin 自定义 ToolbarItem 溢出菜单实现(Popover/Popup) 弹出下拉效果的更多相关文章

  1. IOS第二天-新浪微博 - 添加搜索框,弹出下拉菜单 ,代理的使用 ,HWTabBar.h(自定义TabBar)

    ********HWDiscoverViewController.m(发现) - (void)viewDidLoad { [super viewDidLoad]; // 创建搜索框对象 HWSearc ...

  2. 【android开发】使用PopupWindow实现页面点击顶部弹出下拉菜单

    没有太多花样,也没有很复杂的技术,就是简单的PopupWindow的使用,可以实现点击弹出一个自定义的view,view里可以随便设计,常用的可以放一个listview. demo中我只是一个点击展示 ...

  3. 有序无序Ul->Li Ol->Li菜单,默认点击当前弹出下拉,再次点击收起下拉菜单(变形2 ---修饰)

    从上面可以看出,两个问题,第一:下拉出现的太快太突然,第二:再点击下一个下拉菜单的时候,上一个不会闭合,针对这两个问题,接下来会一 一解决. 解决下拉太快: js中有个jquery效果,有一个效果是j ...

  4. 有序无序ul->li ol->li菜单,默认点击当前弹出下拉,再次点击收起下拉菜单

    实现这一效果利用css和js技术结合 以ul->li为例子 <!DOCTYPE html><html lang="en"><head> & ...

  5. bootstrap中popover.js(弹出框)使用总结+案例

    bootstrap中popover.js(弹出框)使用总结+案例 *转载请注明出处: 作者:willingtolove: http://www.cnblogs.com/willingtolove/p/ ...

  6. Android定位&地图&导航——基于百度地图,实现自定义图标绘制并点击时弹出泡泡

    一.问题描述 上一次我们使用百度地图实现基本的定位功能,接下来我们继续实现搜索和定位,并使用LocationOverlay绘制定位位置,同时展示如何使用自定义图标绘制并点击时弹出泡泡 如图所示: 二. ...

  7. UWP Popup 弹出

    一:需求 做一个类似于安卓的弹出消息框,如图.当用户点击下载或者选择时,能够从底部弹出一个提示框,用于提示用户. 二:Popup 类 不需要我们自己额外去写一个弹窗类,微软自己有一个Popup 弹窗类 ...

  8. vant - 弹框 【Popup 弹出层】【DatetimePicker 时间选择】

    [HelloWorld.vue] <template> <div class="hello"> <van-row class="m-head ...

  9. UWP Popup 弹出提示框

    一:需求 做一个类似于安卓的弹出消息框,如图.当用户点击下载或者选择时,能够从底部弹出一个提示框,用于提示用户. 二:Popup 类 不需要我们自己额外去写一个弹窗类,微软自己有一个Popup 弹窗类 ...

随机推荐

  1. Python调用selenium

    import time from selenium import webdriver from selenium.webdriver.common.touch_actions import Touch ...

  2. IDEA 通过Maven创建Spring MVC项目搭建

    概述 本篇随笔主要记录内容如下: 1.通过Maven创建基于Spring Framework类库的MVC项目,免去了繁琐的XML配置: 2.在Idea里面配置Tomcat的测试启动项: Maven创建 ...

  3. 使用Redis构建全局并发锁

    谈起Redis的用途,小伙伴们都会说使用它作为缓存,目前很多公司都用Redis作为缓存,但是使用Redis仅仅作为缓存未免太大材小用了.深究Redis的原理后你会发现它有很多用途,在很多场景下能够使用 ...

  4. 对屏幕的理解---分辨率,dpi,ppi,屏幕尺寸,像素 等

    1. 名词理解 屏幕尺寸(screen size) 屏幕尺寸(screen size),是屏幕的对角线长度,一般讲的大小单位都是英寸. DPI (dots per inch) dpi 是(英文Dots ...

  5. 如何用div绘制一个容器,例如圆形

    需求:一个圆形的容器,里面有两种颜色,随比率不同而变化. 实现同一个容器中两种颜色变化的关键是css渐变 //background:linear-gradient(#818181 30%,#06FF3 ...

  6. 利用NSE脚本检测域传送和证书透明度滥用

    nslookup -type=NS <domain> <server> nmap -p 53 --script dns-zone-transfer --script-args ...

  7. Telsa显卡比较

    1. T4 2. P4/ P40 3. P100 4. V100

  8. python yield 和 yield from用法总结

    #例1. 简单输出斐波那契數列前 N 个数#缺点:该函数可复用性较差,因为 fab 函数返回 None,其他函数无法获得该函数生成的数列#要提高 fab 函数的可复用性,最好不要直接打印出数列,而是返 ...

  9. 洛谷.5283.[十二省联考2019]异或粽子(可持久化Trie 堆)

    LOJ 洛谷 考场上都拍上了,8:50才发现我读错了题=-= 两天都读错题...醉惹... \(Solution1\) 先求一遍前缀异或和. 假设左端点是\(i\),那么我们要在\([i,n]\)中找 ...

  10. day13_H5_CSS_2

    一.css样式引用优先级,最高的是标签中写的样式,一标签为基准,有内而外,有下到上依次应用 2.样式隐藏,插入小知识,宽度可以写百分比(如:100%就是宽度两边占满) 3.加大加粗 4.水平垂直居中 ...