All Posts (295) 295


How to Fix Extended TitleBar Overlapping NavigationView PaneToggleButton

In UWP Apps, we some times extend our main view into title bar to get rid of Windows 10 default title bar. However if you are using NavigationView under extended title bar, you will find your PaneToggleButton overlapped by the title bar. And the user won't be able to click on the upper part of the button because it is where the title bar need to respond to window drag actions. This image shows th...

XAML UWP

Windows Community Toolkit: Use CameraPreview to Take Photos

In UWP Apps, if we want to use the device's camera to take photos and save to a file, it is used to be some how complicated, the developer need to know about quite a lot things and also write quite a few code to get it down (As you can find the Camera examples from Microsoft offical sample code). In fact, in many cases, we just want to take a photo by the most easy and default options via the came...

UWP Camera

Read System Certificates in UWP

In Windows, we can view and manage the certificates using certmgr.msc, which is a system management console included in Windows itself.  However, what if we want to view the certificates information in an UWP app? Here is the answer. First thing first, the method I use does not apply to UWP only. In fact it is from a WPF app I wrote. As Microsoft released .NET Standard 2.0, which allows me to...

UWP

Deploy Linux VPN Server on Microsoft Azure

For some unspeakable reasons, this article can not expose too many details about every steps to setup and configure the VPN server, but the key steps and scripts will all be listed.  So you will need basic Linux command knowledge and some Azure experience in order to complete the operation.  The reason for choosing Linux over Windows is because the cost is way less then Windows machines, so that...

VPN Azure Linux

Send Feedback in UWP Apps by Windows 10 Feedback Hub

After our app has been put on Microsoft Store, there are a lot of ways to get users to send feedback, such as email, store reviews, or even write our own API collect feedback. But in fact, Windows 10 Feedback Hub can also be used to send feedbacks for our own Apps. Those who are familiar with Windows Insider know that when Windows 10 is installed, the system has a Feedback Hub, which is usually u...

UWP

UWP应用中自定义亚克力材质

Windows 10 秋季更新(Build 16299)中引入了亚克力材质,这是一种类似于Windows 7窗口磨砂玻璃效果的Brush。 很多Windows自带的应用,比如计算器,就引入了这样的设计。然而,系统自带的画刷有时候无法满足我们自己设计App的需求,特别是在Windows决定不渲染亚克力效果的时候,比如设备在低电量模式下运行,或者窗口非激活状态下,很多系统默认画刷会让我们App的界面变的很丑。 比如,这是正常的亚克力效果: 窗口inactive的时候竟然变成了: 这时候就需要我们自定义亚克力的参数,并且定义fall back的配色方案。比如我的"Character Map UWP",就是使用自定义亚克力的一个例子。 正常状态显示自定义透明度的黑色: 全屏或者inactive状态,显示系统主题色: 这样的效果,是通过自定义AcrylicBrush...

UWP

在UWP应用中响应键盘快捷键

一个优秀的Windows应用不仅要面向鼠标、触屏用户,同时还需要兼顾到键盘操作,特别是一些常见的快捷键,比如撤销(CTRL + Z),以提供全面的用户体验。 那么在UWP里如何定义键盘快捷键呢,以我的《描图》APP为例,我需要实现撤销的快捷键(CTRL + Z)。首先,我们需要定义快捷键的操作,是用户当前焦点在哪个控件上的,如果需要整个应用界面都监听键盘操作,那么这个UI控件就是XAML页面最外层的容器:GRID 所以,首先我们在Page下面的第一级Grid,也就是最外层容器上,定义2个事件:KeyDown和KeyUp,如下: 接下来,因为我们想操作的快捷键(CTRL + Z)是个组合键,所以我们需要知道用户是否按同时按下了CTRL键和Z键,为此,我们要定义一个布尔变量用来标识CTRL是否已被按下的状态: private bool _isCtrlKeyPressed; 然后定...

UWP

Show Confirm Dialog When User Close UWP App

When our UWP Application deal with user data in it, e.g. like drawings or documents, we usually want to make sure user won't close the App by accident and lose their work. Just like what you see in a Office application, it will ask you if you want to save your document before close the App. For a long time, UWP could not do that in a normal way. Because it is not a general public API and it is st...

UWP

Windows 10 秋季更新上用编程方式重启UWP应用

有时候,我们的UWP应用会要求用户重启,以应用一些设置。通常情况下,用户只能手工关闭App并再次打开完成重启的步骤。其实,在Windows 10秋季更新里,开发者已经可以通过编程方式,让用户一键完成自动重启App的工作。 比如我的“Character Map UWP”这个应用,在用户更改设置后,需要重启生效。那么第一步,就是在设置页面加一个重启按钮“Restart Now”: 然后,我们需要通过秋季更新中的全新牛逼API RequestRestartAsync(String) 来完成重启。 这个API的签名如下: public static IAsyncOperation RequestRestartAsync(String launchArguments) 如果只是为了完成重启,不需要参数,那么lauchArguments是可以留空的。 所以,在我的这个例子里,最简单...

UWP

在 Windows 10 秋季更新上安装 Linux 子系统

纳德拉说,微软爱Linux。这真的不只是说说,居然还做到了!最近的Windows 10 v1709 秋季更新里,Linux子系统的支持得到了相当大的改进,只需要2步就可以安装使用Linux子系统! 那么,在Windows 10秋季更新上安装Linux究竟有多简单呢? 那么,在Windows 10秋季更新上安装Linux究竟有多简单呢? 1. 启用 Windows Subsystem for Linux 由于控制面板被故意藏起来了,现在打开经典“添加删除程序”界面的最快方式是运行 appwiz.cpl 然后勾选“Windows Subsystem for Linux” 安装完后重启机器。 2. 在应用商店安装你需要的Linux版本 搜索"Linux"即可 目前在应用商店中的有3种Linux:Ubuntu 16.04及openSUSE的2个版本,这次我选择Ubun...

Windows Linux