XAML/C#: What event fires after reordering a gridview?

You cannot reorder a GridView unless the ItemsSource is bound to an ObservableCollection and CanReorderItems, CanDragItems, and AllowDrop are set to true. It is not necessary to use a CollectionViewSource to enable reordering in your gridview. In fact, a collectionviewsource is often used for grouping a gridview and reordering is not possible when data is … Read more

RunAsync – How do I await the completion of work on the UI thread?

I found the following suggestion on a Microsoft github repository: How to await a UI task sent from a background thread. Setup Define this extension method for the CoreDispatcher: using System; using System.Threading.Tasks; using Windows.UI.Core; public static class DispatcherTaskExtensions { public static async Task<T> RunTaskAsync<T>(this CoreDispatcher dispatcher, Func<Task<T>> func, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal) { var … Read more

Page Navigation using MVVM in Store App

There are 2 ways to do this, a simple way is to pass a relay command action from the view to the view model. public MainPage() { var vm = new MyViewModel(); vm.GotoPage2Command = new RelayCommand(()=>{ Frame.Navigate(typeof(Page2)) }); this.DataContext = vm; } <Button Command={Binding GoToPage2Command}>Go to Page 2</Button> Another way is by using an IocContainer … Read more

WinRT apps and Regional settings. The correct way to format dates and numbers based on the user’s regional settings?

It’s been a while, but the question is not fully answered, so let me share my little research. Depechie is mostly right, but he provided only a link and wasn’t really sure. Yes, this unexpected change is intentional. We shouldn’t use CultureInfo anymore as it contains legacy codes and Microsoft want us to use Windows.Globalization … Read more

Is the List.ForEach() method gone?

It’s indeed gone: List<T>.ForEach has been removed in Metro style apps. While the method seems simple it has a number of potential problems when the list gets mutated by the method passed to ForEach. Instead it is recommended that you simply use a foreach loop. Wes Haggard | .NET Framework Team (BCL) | http://blogs.msdn.com/b/bclteam/ Very … Read more

How to uninstall an app that another user installed?

My process above still works, but it simply gets around a race condition issue, where Windows Update (yes, oddly enough) is in charge of wiping out “staged packages.” According to Microsoft, the “other fix” – and I still consider this issue to be a bug – is: Cause of the problem: Windows Update (WU) downloads … Read more

Is it possible to create a Windows 8 Store App from Visual Studio 2013?

It’s easy – create a new 8.1 project and remove the following lines from the .csproj file: <TargetPlatformVersion>8.1</TargetPlatformVersion> <MinimumVisualStudioVersion>12</MinimumVisualStudioVersion> Reopen the file and voila – it’s a Windows 8 project! Additionally, you might want to change the following as well: In MainPage.xaml: – <Grid Background=”{ThemeResource ApplicationPageBackgroundThemeBrush}”> + <Grid Background=”{StaticResource ApplicationPageBackgroundThemeBrush}”> In Package.appxmanifest: – <m2:VisualElements + … Read more

send byte array by HTTP POST in store app

It will be more straightforward to use System.Net.Http.ByteArrayContent. E.g: // Converting byte[] into System.Net.Http.HttpContent. byte[] data = new byte[] { 1, 2, 3, 4, 5}; ByteArrayContent byteContent = new ByteArrayContent(data); HttpResponseMessage response = await client.PostAsync(uri, byteContent); For text only with an specific text encoding use: // Convert string into System.Net.Http.HttpContent using UTF-8 encoding. StringContent stringContent … Read more