虽然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>

ContextFlyout 在10586或10240的使用的更多相关文章

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

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

  2. win10 enterprise 10240激活:

    win10 enterprise 10240激活: 以管理员命令:slmgr /upkslmgr /ipk NPPR9-FWDCX-D2C8J-H872K-2YT43slmgr /skms kms.x ...

  3. Win10 10586 更新

    最近发现,电脑c盘突然少了许多,发现c盘多了个windowsBT文件夹,大概6个G,恩,win10 又推出更新了,版本10586. 不知道为啥,更新时win10 把原来的下载的删除了,大概出了什么错误 ...

  4. pycrypto安装出错的问题 intmax_t C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\inttypes.

    前言: 需要安装 Microsoft Visual Studio2017 Community 或者buildtools 解决方案一(解决了python3.7上安装pycrypto-2.6.1的错误问题 ...

  5. 安装 VS 2015 Update 2 + Windows SDK Tools 1.3.1 + Windows SDK 10586.212 后提示找不到 10586.0 SDK 问题的解决方法

    将 Visual Studio 2015 升级到 Update 2,并安装 Windows SDK Tools 1.3.1 和 Windows SDK 10586.212 后,有可能造成原本已安装的 ...

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

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

  7. win7升级为Win10 10586版本,出现应用商店打不开的解决办法

    把公司的win7升级为了win10,但是打开应用商店时是白的,什么都没有,过一会之后,会有提示信息. 报的错误是: 错误代码:0X80072ee2 最后,我的解决办法是: 首先,咱们返回到win10 ...

  8. win10 10586 关机便利贴报内存不能为 read 应用程序错误

    解决方案: 最小化便利贴后关机.

  9. 【数论】UVa 10586 - Polynomial Remains

    Problem F: Polynomial Remains Given the polynomial a(x) = an xn + ... + a1 x + a0, compute the remai ...

随机推荐

  1. 【视频处理】YUV与RGB格式转换

    YUV格式具有亮度信息和色彩信息分离的特点,但大多数图像处理操作都是基于RGB格式. 因此当要对图像进行后期处理显示时,需要把YUV格式转换成RGB格式. RGB与YUV的变换公式如下: YUV(25 ...

  2. java多态的理解

    面向对象语言中的类有三个特征,封装.继承.多态.封装与继承很好理解,那什么是多态呢? 1.什么是多态? 多态的定义:指允许不同类的对象对同一消息做出响应.即同一消息可以根据发送对象的不同而采用多种不同 ...

  3. quartz定时+log4net日志+exchangeservice发邮件

    main using System; using System.Collections.Generic; using System.Linq; using System.Text; using Sys ...

  4. 全国SHP地图数据赠送

    百度搜索:GIS之家获取全国SHP图层数据的方式:收藏(ArcGIS地图全国电子地图shp格式版本GIS地图数据.GIS开发顺德政府GIS公共服务共享平台),并且截图验证,验证通过后,收下邮箱,我把下 ...

  5. 【转】用JitPack发布开源库时附加文档和源码

    来自:http://www.gcssloop.com/course/jitpack-sources-javadoc 用JitPack发布开源库时附加文档和源码 很早之前写过一篇用JitPack发布An ...

  6. 安装phpstudy之后发现80端口被占用

    安装phpstudy之后发现80端口被占用: 进入cmd的界面,在输入"netstat -ano",按回车键后,会显示当前电脑中程序占用的端口和程序ID等等信息:看到第一条就是:0 ...

  7. webapi frombody fromuri的参数绑定规则

    在WebAPI中,请求主体(HttpContent)只能被读取一次,不被缓存,只能向前读取的流. 举例子说明: 1. 请求地址:/?id=123&name=bob 服务端方法: void Ac ...

  8. 初始webservice

    webservice 可以用来查天气,以及手机号码类型等功能,这写都是简单的 方法有很多: 1.通过创建 web service exploer 创建出一个web services explorer ...

  9. webform控件

    简单控件: 1.Label 会被编译成span标签 属性: Text:文本内容 CssClass:CSS样式 <asp:Label ID=" CssClass="aaa&qu ...

  10. 代码管理工具 --- git的学习笔记二《git的工作原理》

    通过几个问题来学习代码管理工具之git 一.git是什么?为什么要用它?使用它的好处?它与svn的区别,在Mac上,比较好用的git图形界面客户端有 git 是分布式的代码管理工具,使用它是因为,它便 ...