AdaptiveTrigger and DataTemplate

Try wrapping your DataTemplate inside a UserControl like this – <DataTemplate> <UserControl> <Grid> <VisualStateManager.VisualStateGroups> … </Grid> </UserControl> </DataTemplate> Looks like any Control that has got a Content property will work. That’s why UserControl works, so does a ContentControl. So if you replace the UserControl with a ContentControl and give it an empty Style. It should … Read more

WinRT/UWP Frame and Page caching: How to create new page instance on Navigate() and keep the page instance on GoBack()

Because there was no solution to this problem, I had to reimplement all paging relevant classes: Page, Frame, SuspensionManager, etc… The solution can be downloaded here: https://github.com/MyToolkit/MyToolkit/wiki/Paging-Overview Update: The page class now also provides the OnNavigatingFromAsync method to show for example an async popup and cancel navigation if required…

How do I get a Unique Identifier for a Device within Windows 10 Universal?

That is the complete solution for Windows Desktop: Add the Extension reference “Windows Desktop Extensions for the UWP” like Peter Torr – MSFT mentioned. Use this Code to get the HardwareId: using System; using Windows.Security.ExchangeActiveSyncProvisioning; using Windows.System.Profile; namespace Tobit.Software.Device { public sealed class DeviceInfo { private static DeviceInfo _Instance; public static DeviceInfo Instance { get … Read more

Correct way to get the CoreDispatcher in a Windows Store app

This is the preferred way: Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // Your UI update code goes here! }); The advantage this has is that it gets the main CoreApplicationView and so is always available. More details here. There are two alternatives which you could use. First alternative Windows.ApplicationModel.Core.CoreApplication.GetCurrentView().CoreWindow.Dispatcher This gets the active view for the app, … Read more

Get Screen Resolution in Win10 UWP App

To improve the other answers even a bit more, the following code also takes care of scaling factors, e.g. for my 200% for my Windows display (correctly returns 3200×1800) and 300% of the Lumia 930 (1920×1080). var bounds = ApplicationView.GetForCurrentView().VisibleBounds; var scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; var size = new Size(bounds.Width*scaleFactor, bounds.Height*scaleFactor); As stated in the other … Read more

How to resize Image in C# WinRT/winmd?

Example of how to scale and crop taken from here: async private void BitmapTransformTest() { // hard coded image location string filePath = “C:\\Users\\Public\\Pictures\\Sample Pictures\\fantasy-dragons-wallpaper.jpg”; StorageFile file = await StorageFile.GetFileFromPathAsync(filePath); if (file == null) return; // create a stream from the file and decode the image var fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); BitmapDecoder decoder = await … Read more

How do I print WebView content in a Windows Store App?

Sure, here you go. First, you can resize the WebView to the actual content. Then, you scale the WebView back to the original size. It would require a script invoke and a ScaleTransform. Pretty simple, really. Like this: <Grid Background=”{StaticResource ApplicationPageBackgroundThemeBrush}”> <WebView x:Name=”MyWebView” Source=”http://www.stackoverflow.com” /> </Grid> void MyWebView_LoadCompleted(object sender, NavigationEventArgs e) { var _Original = … Read more

Async implementation of IValueConverter

You probably don’t want to call Task.Result, for a couple of reasons. Firstly, as I explain in detail on my blog, you can deadlock unless your async code is has been written using ConfigureAwait everywhere. Secondly, you probably don’t want to (synchronously) block your UI; it would be better to temporarily show a “loading…” or … Read more

tech