Edi Wang

All Posts 293


Automatically Set Text Color on Accent Background in UWP

Windows 10 allows users to set accent color for the system, and in UWP apps, we usually honor those settings by using XAML pre-defined resource keys like {ThemeResource SystemControlBackgroundAccentBrush}. But regardless of how the user set default app mode to dark or light, when we apply text on accent colors, it may have some problems. For example, when the App is in light mode, the default...

XAML UWP

Get Client IP Address in ASP.NET Core 2.0

In classic ASP.NET we used to get client IP Address by Request.UserHostAddress. But this does not apply to ASP.NET Core 2.0. We need a different way to retrieve HTTP Request information. 1. Define a variable in your MVC controller private IHttpContextAccessor _accessor; 2.  DI into the controller's constructor public SomeController(IHttpContextAccessor accessor) { _accessor = accessor;...

ASP.NET .NET Core

Configure VSTS Build for UWP Apps

UWP Apps usually require a lot of time to compile a "release" package for submitting to Windows Store, and if you are working in a team, TFS/VSTS can help your team ensure that each check-in has a success build, and make it easier for deployment and testing. Let's see a basic example of how to setup a CI build for a UWP App on VSTS. Important Pre-condition: Before you do that, please ensure...

UWP VSTS

Windows 10 UWP: Switching Languages in Your App

By default, a UWP App's UI language is automatically fits the system current language settings. However, what if the user need the ability to set a particular UI language just for your App without having to change system language? In my App, I supports Simplified Chinese and English. The user can override the system language in App's settings page: So how to do it? First, you need to have res...

UWP Localization

Windows 10 UWP: How to Read and Save Settings Easily

In the UWP Application model, reading and saving settings are very similar to WinRT API. The class we are using is ApplicationData.Current.LocalSettings It is using key-value-pair to store settings. LocalSettings will stay on the user's current computer, and not being synced with thier Microsoft account. The API to save settings is: LocalSettings.Values[key] = value; To read settings:  if (Lo...

Windows 10 UWP

Windows 10 UWP: How to Debug OnFileActivated Launch Failure

Today I am working on my Image Portray App, and I get my code blown up. The problem is, when the App is already started, it can open .ink file with double click from a file. But when the App is not launched, opening a .ink file to start the App will make it crash. As other UWP that supports file type association, I also use OnFileActivated event to launch my App. This kind of problem could not be...

Debug Visual Studio UWP

10 Tricks and Tools for Windows 10 UWP Development

After Windows 10's launch. More and more UWP applications are coming as well as more Windows developers. I am doing UWP development besides my job for more then 2 years. Today, I will share some tips and tricks from my UWP development experience as well as some handy tools, so that you can do your development more quicker and easier. 1. Automatically Set Color to Title Bar The default color...

UWP

一个死忠软粉亲身经历的Surface产品的品控和售后

这几天关于Surface硬件质量差的问题,在国内闹得沸沸扬扬,起因是美国消费者协会因为发现25%的Surface用户在使用2年内机器都会爆,所以将Surface系列移出了推荐。加上国内大环境本来就是吹苹果黑微软的多,这下可真够热闹的。然而这一次,我觉得Surface真是自找的,尤其是国内。今天我就整理一下我亲身经历过的品控事件。 首先,我保证本文的内容均为可以考证的100%事实,不吹不黑。我本人是个死忠软粉,拥有Surface RT, Surface Pro 3, Surface Pro 4, Surface Pro 2017, Surface Laptop, Lumia 520, 625, 640, 720, 928, 1520, 950XL, 正版Windows自费购买5份,国内没有的我还专门美国代购过,都是Pro版, Office 365(家庭版), Visio, Proj...

Surface

Windows 10 UWP: Undo / Redo Ink with Surface Dial

The Surface Dial is the first wheel device in a new input device class. I got my hand on one as soon as it came to market in China. I have a UWP App named "Image Portray", as a drawing app that can make use of the Surface Dial. One of it's useful application to undo / redo the ink by turning the Surface Dial. You can download it from Windows Store these days to see the changes. So, let's begin w...

UWP Surface Dial

Windows 10 UWP: Undo / Redo on InkCanvas

The InkCanvas in UWP only got pens by default, it can not perform Undo or Redo. To implement this, we will need to code for ourselves. Official document covered Undo functionalilty, but not redo. Today, I have successfully done it, and I'd like to share with you. First, you need to add two custom buttons on the InkToolbar for Undo / Redo 1. Undo the Ink We need a few A...

Stack UWP InkCanvas