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 to access a Control inside the data template in C# Metro UI in the code behind

Try the following: private DependencyObject FindChildControl<T>(DependencyObject control, string ctrlName) { int childNumber = VisualTreeHelper.GetChildrenCount(control); for (int i = 0; i < childNumber; i++) { DependencyObject child = VisualTreeHelper.GetChild(control, i); FrameworkElement fe = child as FrameworkElement; // Not a framework element or is null if (fe == null) return null; if (child is T && fe.Name … Read more

DataTrigger in WinRT?

DataTrigger is not currently supported in WinRT XAML. Addendum by Mike Brown The DataTrigger API has been replaced with the VisualStateManager a similar API to Data Triggers was provided by the Blend SDK for Silverlight. Since the Attached Behavior Pattern works in WinRT, it is possible to do the same.

Yet Another MinGW “gcc: error: CreateProcess: No such file or directory”

You shouldn’t add C:\MinGw\libexec\gcc\mingw32\4.7.2 to the path. Add: c:\MinGW\bin You may need to reboot to ensure that the path is made available to all processes properly. Another suggestion is to use a different MinGW distribution. It’s been a long time since I used an ‘official’ MinGW distribution because the installation steps were so byzantine and … Read more

Launching a Desktop Application with a Metro-style app

If you simply want to run a desktop application like (notepad, wordpad, internet explorer etc) then go through Process Methods and ProcessStartInfo Class try { // Start the child process. Process p = new Process(); // Redirect the output stream of the child process. p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = “C:\Path\To\App.exe”; p.Start(); } // Exp 2 … Read more

How can I make SmartScreen Filter trust a self-signed certificate

To quote from MSDN’s website: Detractors may claim that SmartScreen is “forcing” developers to spend money on certificates. It should be stressed that EV code signing certificates are not required to build or maintain reputation with SmartScreen. Files signed with standard code signing certificates and even unsigned files continue to build reputation as they have … 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 to download/upload files from/to SharePoint 2013 using CSOM?

Upload a file Upload a file to a SharePoint site (including SharePoint Online) using File.SaveBinaryDirect Method: using (var clientContext = new ClientContext(url)) { using (var fs = new FileStream(fileName, FileMode.Open)) { var fi = new FileInfo(fileName); var list = clientContext.Web.Lists.GetByTitle(listTitle); clientContext.Load(list.RootFolder); clientContext.ExecuteQuery(); var fileUrl = String.Format(“{0}/{1}”, list.RootFolder.ServerRelativeUrl, fi.Name); Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContext, fileUrl, fs, true); } } Download … Read more