Skip to content
wpdev

.NET / C#

WinRT

[UWP] NavigationService with back button handler priority

2016-02-21
By: Kevin Gosse
On: February 21, 2016
Tagged: .NET, C#, universal apps, WinRT, wpdev

There’s an issue I’ve encountered in every single of my UWP applications, so it’s very likely you know about it. In Universal Apps, you can subscribe to the SystemNavigationManager.GetForCurrentView().BackRequested event. It’s usually done firsthand to mimic Windows Phone’s behavior where pressing the back button loads the previous page in the back stack. So far, so good. But then comes the moment when you need to implement a back button behavior that is specific to a page. For instance, you have a popup and you want to dismiss it when the user presses the back button. So you subscribe once more to the SystemNavigationManager.GetForCurrentView().BackRequested event, implementRead More →

[UWP] Bandwidth adaptive image control

2016-01-13
By: Kevin Gosse
On: January 13, 2016
Tagged: .NET, C#, universal apps, WinRT, wpdev

There’s a dilemma you probably faced if you’ve written a mobile application displaying a large number of pictures. You could display gorgeous hi-resolution pictures, but if you do so, you’ll provide a poor experience to users who use your app on the go. Particularly, users with a poor mobile connection who will have to wait minutes before the pictures are displayed. You may also discontent users with limited data plans, who don’t want to eat gigabytes of data just to display your pictures. On the other hand, if you settle for low-resolution pictures, you’ll provide a sub-optimal experience you are at home, with an unlimited andRead More →

Should I await the last call in a method

2015-09-12
By: Kevin Gosse
On: September 12, 2015
Tagged: .NET, C#, WinRT, wpdev

I came to write a code looking like this: Then I stepped back a bit and thought: OnNavigatedTo is an event, and its return type can’t be changed from void. Therefore, is there a point in awaiting the last asynchronous call of the method, as this will provide no information at all to the caller? Would it result in a useless call to the dispatcher, just to execute an empty callback? Actually, is the compiler smart enough to detect this case and remove the seemingly useless await? Understanding what’s going on How to figure out whether the last await call has any impact? Let’s say I add some code atRead More →

Dispatcher.Yield – When and how to use it on WinRT

2015-05-15
By: Kevin Gosse
On: May 15, 2015
Tagged: .NET, C#, WinRT, wpdev

That’s an issue happening from time to time. You need to do some lengthy computation on the UI thread (for instance, a page navigation), and you want to display a progress indicator to ease up the user waiting. It’s possible on WinRT thanks to the compositor thread: a dedicated thread for animations that don’t impact the page layout, making them run smoothly even when the UI thread is busy. Some built-in controls automatically use the compositor thread, such as the ProgressRing. So, what the issue could be? Letting the UI refresh Let’s say that when the user taps on a button, we want to displayRead More →

Inspecting unhandled exceptions – You’ve got only one chance

2015-04-12
By: Kevin Gosse
On: April 12, 2015
Tagged: C#, WinRT

That’s a surprising behavior, brought to my attention by this question of Anthony Wieser on MSDN forums. Basically, he noticed that in the global exception handler, he could read the stacktrace of the exception only once. On the subsequent tries, the value would be null. The debugging part We’ll start by making a simple program to reproduce the issue. When the user click on a button, we throw a custom exception: In the App.xaml.cs file, we subscribe to the unhandled exception handler, and print twice the stacktrace of the exception:  Sure enough, the stacktrace is printed only once. The second time, the property is null. What’sRead More →

Ken Burns effect with WinRT

2015-03-28
By: Kevin Gosse
On: March 28, 2015
Tagged: C#, WinRT, wpdev

In a mobile application, we often face the challenge of fitting a large picture in a limited, fixed-size space. One of the common solutions is to generate a thumbnail, but depending on the ratio of the picture the result will not necessarily meet the quality standards. In my case, I decided to try an alternative approach and mimic the built-in effect when pinning a picture as a secondary tile on Windows Phone, where the picture slowly scrolls from top to bottom (Ken Burns effect). There is no control on Windows Phone to produce this kind of effect, so I had to put together my own. FirstRead More →

Windows 10 SDK – SplitView

2015-03-03
By: Kevin Gosse
On: March 3, 2015
Tagged: C#, Windows 10, WinRT, wpdev

Another new addition to the Windows 10 SDK is the SplitView. It’s used to display a side menu, such as the one usually called “hamburger menu”. It’s quite straightforward to use. The “Pane” property contains the code of the menu itself. The page content goes into the control itself. The “OpenPaneLength” sets the width of the menu. Lastly, the “PanePlacement” property indicates on which side of the page the menu will appear (currently limited to left and right, top and bottom doesn’t seem to be supported). The menu is opened by setting the “IsPaneOpen” property to true, and closed when the property is set toRead More →

Recent Posts

  • Uncovering a bug in Attribute.GetHashCode
  • [UWP] NavigationService with back button handler priority
  • [UWP] Bandwidth adaptive image control
  • [uwp] Animation orchestration using Caliburn.Micro coroutines
  • Should I await the last call in a method

Archives

  • March 2017 (1)
  • February 2016 (1)
  • January 2016 (1)
  • October 2015 (1)
  • September 2015 (2)
  • August 2015 (1)
  • May 2015 (1)
  • April 2015 (1)
  • March 2015 (3)
  • October 2014 (1)
  • September 2014 (1)
  • November 2013 (1)
  • August 2013 (1)
  • May 2013 (1)
  • February 2013 (1)
  • December 2012 (1)
  • October 2012 (2)
  • July 2012 (1)
  • May 2012 (1)
  • February 2012 (1)
  • January 2012 (4)

Follow me on Twitter

My Tweets

Designed using Dispatch. Powered by WordPress.