虽然ContextFlyout只能在红石以上版本使用,但可以采用附加属性的方法手动写一个

    public static class ContextFlyoutSetter{public static Windows.UI.Xaml.Controls.Primitives.FlyoutBase GetCompatibleContextFlyout(FrameworkElement obj){return (Windows.UI.Xaml.Controls.Primitives.FlyoutBase)obj.GetValue(CompatibleContextFlyoutProperty);}public static void SetCompatibleContextFlyout(FrameworkElement obj, Windows.UI.Xaml.Controls.Primitives.FlyoutBase value){obj.SetValue(CompatibleContextFlyoutProperty, value);}static readonly bool issupport = Windows.Foundation.Metadata.ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "ContextFlyout");// Using a DependencyProperty as the backing store for ContextFlyout.  This enables animation, styling, binding, etc...public static readonly DependencyProperty CompatibleContextFlyoutProperty =DependencyProperty.RegisterAttached("CompatibleContextFlyout", typeof(Windows.UI.Xaml.Controls.Primitives.FlyoutBase), typeof(FrameworkElement), new PropertyMetadata(null, CompatibleContextFlyoutChanged));private static void CompatibleContextFlyoutChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e){var uie=obj as FrameworkElement;if(uie!=null){if(issupport ){uie.ContextFlyout = e.NewValue as Windows.UI.Xaml.Controls.Primitives.FlyoutBase;}else{Windows.UI.Xaml.Controls.Primitives.FlyoutBase.SetAttachedFlyout(uie, e.NewValue as Windows.UI.Xaml.Controls.Primitives.FlyoutBase);if (e.NewValue!=null){uie.Holding += Uie_Holding;uie.RightTapped += Uie_RightTapped;}else{uie.Holding -= Uie_Holding;uie.RightTapped -= Uie_RightTapped;}}}}private static void Uie_Holding(object sender, Windows.UI.Xaml.Input.HoldingRoutedEventArgs e){Windows.UI.Xaml.Controls.Primitives.FlyoutBase.ShowAttachedFlyout(sender as FrameworkElement);}private static void Uie_RightTapped(object sender, Windows.UI.Xaml.Input.RightTappedRoutedEventArgs e){Windows.UI.Xaml.Controls.Primitives.FlyoutBase.ShowAttachedFlyout(sender as FrameworkElement);}}

最后使用的时候只需要这样

                            <localControls:ContextFlyoutSetter.CompatibleContextFlyout><MenuFlyout></MenuFlyout></localControls:ContextFlyoutSetter.CompatibleContextFlyout>

转载于:https://www.cnblogs.com/yinyue200/p/6259811.html

ContextFlyout 在10586或10240的使用相关推荐

  1. 【Win10】探索 Windows 10 10586 之 JumpList(跳转列表)

    Windows 10 10586 出来了也挺久的了,应该大部分都从 10240 升级到这个版本了.在 10586 中,微软添加了 200 多个新的 API,具体 API 的变动,大家可以点击下面这个链 ...

  2. linux esd转iso,window_Win10 TH2正式版10586官方ESD映像怎么转换成ISO镜像?,今天phpstudy分享了Win10 TH2(Build - phpStudy...

    Win10 TH2正式版10586官方ESD映像怎么转换成ISO镜像? 今天phpstudy分享了Win10 TH2(Build 10586)各版本官方ESD映像下载地址,不过旧转换工具可能已不适用于 ...

  3. FileUploadException: Header section has more than 10240 bytes (maybe it is not properly terminated)]

    通过zuul网关文件上传报错: 2020-10-19 16:29:01.976 ERROR 8 --- [nio-9090-exec-6] o.a.c.c.C.[.[.[/].[dispatcherS ...

  4. 解决 vue 项目运行过程报错 JavaScript heap out of memory(内存溢出) “‘node --max-old-space-size=10240“‘ 不是内部或外部命令

    你是不是也遇到过 vue 项目 当你 ctrl+s,编译代码,项目就挂掉的情况?那么恭喜你,内存溢出了.兄dei,你膨胀了哟~ 不过不要慌,以下有完整的解决方案!         1.我们全局安装 i ...

  5. 【Ambari】设置yarn队列资源为绝对值[memory=10240,vcores=12,yarn.io/gpu=4]

    目录 1.介绍 2 修改资源队列 API步骤 2.1 获取capacity-scheduler配置的tag和version 2.2 获取capacity-scheduler指定版本的配置 2.3 通过 ...

  6. Windows 10 Build 10586与14393的游戏性能对比

    微软官方在本月初宣布,Windows 10 Anniversary Update一周年更新版将于8月2日正式发布,现有的Windows 10用户可以免费获得升级.如果玩家正在使用Windows 10 ...

  7. 发布两年后,再次体验Win10 10240

    作为永远都是完全安装Insider Preview版本的我,怎么会想起重新捡起Win10家族里,已经有两岁"高龄"的1507呢?无它,还不是看在每月例行的补丁日,微软对它的&quo ...

  8. windows 10预览版升级win10 7月29 10240.16384

    一路追着win10 从预览版到今天10240.16384 昨晚是中国区第一批下载win10的,不过不是第一批安装的. 早上才安装成功. win10预览版更新 7月29 1024016384 使用esd ...

  9. [下载]微软公布Windows 10 TH2 Build 10586 ISO镜像

    2015-11-13 06:40:21 63013 次阅读 27 次推荐 稿源:cnBeta.COM 52 条评论 微软昨晚向Windows 10用户推送TH2 Build 10586更新,并在MSD ...

最新文章

  1. PostgreSQL 10.0 preview 功能增强 - 后台运行(pg_background)
  2. linux中的date的用法
  3. hdu4908 中位数子串
  4. matlab中矩阵的左除右除
  5. 模拟操作网页 webBrowser
  6. Golang手册与常用包手册
  7. Java EE6装饰器:在注入时装饰类
  8. nodejs源码_nodejs之setTimeout源码解析
  9. HashMap深度分析
  10. 比特币链上活跃度下降,近24小时交易额约为1050.57亿美元
  11. Ubuntu18.04构建Go语言项目
  12. 如何编写完美的 Python 命令行程序?
  13. python读取modis数据
  14. 最好用图像处理库CxImage入门
  15. XP IIS之——问题总结
  16. java上传文件夹到oss
  17. opencv 去除背景算法的比较
  18. 对于position定位的认识
  19. 开源正在蚕食整个世界?
  20. 数据结构实验六 图的操作实现

热门文章

  1. Procrastination
  2. html画海绵宝宝css3,CSS3 海绵宝宝
  3. 海绵宝宝python代码_Python那些事——python还能这么玩?帅呆了
  4. 从“以票治税”走向“以数治税”,鲲鹏助力税务开启全电发票新时代!
  5. win7开机黑屏开计算机无桌面图标任务栏
  6. 蓝桥杯 单片机 独立按键 的使用
  7. thinkphp6 路由的学习
  8. mysql 外键约束
  9. ai人工智能市场客户_投资管理中的人工智能可提升客户关系和回报
  10. 阿里云IoT平台CoAP接入 3 了解下物模型