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 …
In the recent Windows 10 v1709 Fall Creators Update, the Windows subsystem for Linux has been improved a lot. Let's see how easy it is now to install Linux on Windows. 1. Enable Windows Subsystem for Linux Because the classic control panel has been hidden, now the quickest way to access Programs and Features is to run appwiz.cpl And then check "Windows Subsystem for Linux" under "Turn Windows …
In classic .NET Framework applications, we have used System.Net.NetworkInformation.Ping class to Ping a host address. This API is not included by default in .NET Core, even in version 2.0. Here is how to do it in a .NET Core way. First, we need to reference a package System.Net.Ping Install-Package System.Net.Ping This will give us the same API set as .NET Framework. Then, in your .NET Core code, …
There's official update for NLog targeting ASP.NET Core 2.x, for the latest methods please refer to https://github.com/NLog/NLog.Web/wiki/Getting-started-with-ASP.NET-Core-2 Recently I am porting a classic ASP.NET MVC 5 project to .NET Core 2.0, in order to run it on Linux. One of the parts that has differences between .NET Fx and .NET Core is logging. I choose NLog as my logging providor, let's …
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 …
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; …
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 that …
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 …
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 ( …
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 …
After Windows 10's launch. More and more UWP applications are coming as well as more Windows developers. I have been doing UWP development besides my job for more than 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 quicker and easier.
1. Automatically Set Color to Title Bar
The default color …
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 …
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 APIs. To …
These days I am developing an App that need to be tested on multiple languages environment. I can set my local dev box to different language, and restart or sign out / sign in to Windows again to test different languages. But this is very inconvenient. I want to setup a Windows 10 virtual machine with Chinese language and let Visual Studio 2017 deploy and debug the App right into the VM. Back the …
It has been a while since Azure DNS went GA on Azure. It's like "dnspod" in China, offers a third party DNS services besides your domain register. The power of Azure has already been witnessed by the entire human race. Now that, it has got DNS services, it would surly be the best in class DNS on the planet. Thus, what we have to do, is to migrate our DNS servers to Azure DNS. So that your website …
Today I am trying new DevOps tools in VS2017 and Azure, my goal is to automate the process from development to production for an exsiting ASP.NET Core project. I have encountered some issues, and with the help of Microsoft Support, I was able to solve them and share with you guys. First, there are two ways to configure CD for Azure Web Apps. I prefer create a website first, then configure it from …
The InkCanvas control in Windows 10 UWP is not like WPF where you can save as image file easily. If you want to save user ink to an image file, there's by far only one way to do it: 1. Install Win2D.UWP via NuGet into your project. PM> Install-Package Win2D.UWP 2. Because we need to access user's picture library, so we need to apply the permission in manifest file. Select "Pictures Library" …
A year ago, I wrote an UWP application that can generate QR Code. However, at that time, the QR Code library I used was ZXing.Net, the last update for this package was in 2014. Now, time has changed, the author of ZXing.Net seems not to update the package any more. However, we have to move on, so I found a fantastic new library to generate QR Code in .NET applications: QRCoder To use that package, …
Recently, I have been organizing my blog data and needed to perform an operation to merge article categories. On my blog, articles and categories have a many-to-many relationship. That is, one article can belong to multiple categories, and one category can contain multiple articles. This is a very typical many-to-many relationship, and I use a many-to-many table with a composite primary key to associate this data. What I need to do is move articles from the "DotNetBeginner" category to the "CSharpAndDotNet" category. However, since some of the articles originally in the "DotNetBeginner" category also belong to "CSharpAndDotNet", directly updating the association table would result in duplicate composite keys, which would cause issues.
There used to be a {x:Static Fonts.SystemFontFamilies} in WPF that can bind to system font list very easy. However, this is gong in UWP! How stupid it is!
These days I wrote a character map UWP application, that would use system fonts, so I did some research.
In order to get system font in UWP, we must use DirectX.
Install these 3 NuGet pacakges into your project:
"SharpDX": "3.0.1",
" …