Wednesday, 11 July 2012

Creating a ScaleTransform animation in C# for WinRT/ Metro Apps

I thought this one would be easy as I’ve done Silverlight, WP7 and WPF apps before, but actually took a while and quite a lot of frustration. AS with most WinRT stuff, you can’t just copy and paste XAML and code and expect it to work.I needed this animation to indicate that an item is clickable by providing visual feedback similar to the one provided by the PointerUpThemeAnimation and PointerDownThemeAnimation provided by the Animations library. I had to wrap my clickable items in buttons to meet the ‘also Keyboard only accessible’ requirement, but the buttons Click-event hindered the PointerReleased event so the PointerUpThemeAnimation wouldn’t run. The result was items that would shrink in size when pointer was pressed, but they would not return to their normal state/size when the pointer was released.

Look, this might not be the best way to go about it, but at the moment there isnt so much information, if you google PointerDownThemeAnimation you will only get ten hits) So, as always, please let me know (email or twitter) if you can clean up my code, provide feedback, information or some magical code


Creating a ScaleTransform animation in C# for WinRT/ Metro Apps


Read full article here

Writing Windows Runtime (WinRT) Components

Earlier today, I opined the finer points of JavaScript/HTML development after earlier on the same day pointed out something that couldn’t be done in JavaScript and I added a WinRT component written in C#.

This is one of the best parts of Metro style app development: WinRT components.

Pay attention closely to this graph, it will come up again and again. In fact, you may want to save this image, print this out, and hang it up next to your computer.

It’s a great reminder of the versatility and ingenuity of the Windows 8 platform.

Plus, it’ll be handy to have when some chump tells you that “X is better than Y” for building Metro style apps or some such other nonsense.

Writing Windows Runtime (WinRT) Components


Read full article here

Using the Windows 8 Simulator & VS 2012 to debug the IE10 touch events & your responsive design

I’m currently working around the touch events of IE10 and even if I’m lucky enough to have a Windows 8 tablet, I was looking for a simpler way to do basic tests on my classical laptop without switching to the tablet each time. While looking for that, I’ve discovered several tips & tricks that may help you debugging the IE10 touch events in your code without even using a touch device. Nice side effect: the same approach will also help you to test & debug your responsive web design!

Pre-requisites: to follow this tutorial, you need first to:

1 – Download & install Windows 8 Release Preview on your machine: http://preview.windows.com
2 – Download & install Visual Studio 2012 RC Express for Windows 8: http://msdn.microsoft.com/en-us/windows/apps/br229516

Read Full article here

How to implement FileExistsAsync method in C#/XAML Metro App

Today I share with you a small (but useful) piece of code.

Indeed, for now WinRT does not provide a method to test the existence of a specific file. You can only try/catch an GetFileAsync call and it can be disappointing.

So here is a little solution:

public async static Task<bool> FileExistsAsync(this StorageFolder folder, string name)
{
    var files = await folder.GetFilesAsync();

    return files.Any((f)=>
    {
        return f.Name == name;
    });
}


To use it, just call the following code:

if (!await ApplicationData.Current.LocalFolder.FileExistsAsync(filename))
    return;

StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync(filename);

Source

Consuming WCF SOAP Service in Windows 8 Metro Application

n this post we will consume WCF SOAP Service in C#/XAML based Metro Application. This is level 100 post showing basic steps to create simple WCF Service and consume that in Metro Application.

Very first let us create a WCF Service using VS2012. Form File menu create a new project by choosing WCF Service Application project template from WCF tab.

Consuming WCF SOAP Service in Windows 8 Metro Application


Read full article here

Process Lifetime Management (PLM) and Managing State in Windows 8 Metro C# Applications

In the traditional Windows environment, the user manages the lifetime of their applications. The user launches the application and it continues to run until the user decides to close it. The problem with this model is that applications continue to drain system resources, including memory and CPU, even when they are not in the foreground. This impacts the performance of the application the user is using as well as drains the battery faster when the device is not plugged in.

Windows 8 Metro applications only run when they are in the foreground. This allows the user to focus on the primary application they wish to interact with. Applications in the background go into a suspended state. In the suspended state the threads for the application are literally frozen in place. The application will no longer take up system resources or impact battery life. Most of the time, the application will remain in memory. This allows fast application switching, so when the user swipes back to a different application, it resumes immediately as if it were already running.

Read full article here

The taming of the Metro GridView

This article describes how to restyle the Metro GridView to host a single page app like the sample Weather and Finance apps. I'll show you how to get rid of the default disco effects of this control - like the swiping behavior and the pressed animation. For this article, I started with my own lightweight version of the weather app, but I got bored very soon. So I upgraded the app to a tribute to the iconic rock band CPeX, with some pictures, some overflowing RichTextBox controls with lyrics, and WebView controls revealing the band's web site and wikipedia page; there's even a YouTube video in it:

The taming of the Metro GridView

Read full article here

Handling the virtual keyboard in C#/XAML Metro app

As we saw in a previous post (http://blogs.msdn.com/b/eternalcoding/archive/2012/07/03/tips-and-tricks-for-c-metro-developers-the-flyout-control.aspx) it is really easy to create a flyout control.

But if this control is used to type text, you must consider handling the virtual keyboard in order to move your flyout so that it can always be visible:


Read full article here

Play sounds in Metro-style apps

Wordastic for Windows 8 is close to completion. As a part of enhancing the app, I updated word count from 5k to 25k. I also added some sounds. Bach in the background and some sounds depending upon correct user guess.

So I did it all and I came to the sounds… figured out how to play background music but was not how to play multiple sounds. Here’s what I did
.
I added an instance of MediaElement and set the source to sound 1. Set another 2 instance and set the source to sound 2 and sound 3.

Read full article here
Web Informer Button