Posts
133
Comments
328
Trackbacks
0
September 2011 Entries
Enabling Frame Rate Counters for HTML Applications in Windows 8

 

Introduction

Just the other day I blogged about “Enabling Frame Rate Counter for XAML Applications in Windows 8”. At the very end of that post, I reminded everyone that that method does not work for HTML / JS Metro Applications. But, we are in luck as Mathias Jourdain provided sample code for accomplishing this in HTML / JS in his Build talk. The only problem was that he didn’t describe how to hook this into a new application to actually use. That is going to be the focus of today’s blog post.

Let’s get started

Unlike XAML Applications, this must be done using code. So, click on “Visual Studio 11” to begin.

image

Go ahead and click on “New Project…”

Select JavaScript –> Windows Metro Style –> Blank Application. Finally, give it a name and hit OK.

image

Our default.html will be displayed. We are going to keep things simple and only add a <p> tag between the body and give it an id. Below is some sample code:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>FRCounter</title>
    <!-- WinJS references -->
    <link rel="stylesheet" href="/winjs/css/ui-dark.css" />
    <script src="/winjs/js/base.js"></script> 
    <script src="/winjs/js/wwaapp.js"></script>
    <!-- FRCounter references -->
    <link rel="stylesheet" href="/css/default.css" />
    <script src="/js/default.js"></script>
</head>
<body>
    <p id="myText" />
</body>
</html>

This paragraph tag will display our framerate when the application is running.

Now, if you switch over to the /js/default.js then you will see the following code.

(function () {
    'use strict';
    // Uncomment the following line to enable first chance exceptions.
    // Debug.enableFirstChanceException(true);
 
    WinJS.Application.onmainwindowactivated = function (e) {
        if (e.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
            // TODO: startup code here
        }
    }
 
    WinJS.Application.start();
})();

You are going to replace it with this code:

var lastUIRefreshFPS = 0;
var frameCounter = 0;
 
(function () {
    'use strict';
    // Uncomment the following line to enable first chance exceptions.
    // Debug.enableFirstChanceException(true);  
 
    WinJS.Application.onmainwindowactivated = function(e) {
        if (e.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
               renderLoopFPS();
        }
    }
    
    WinJS.Application.start();
})();
 
(function renderLoopFPS() {
    var now = new Date().getTime() % 1000;
    
    if (now < lastUIRefreshFPS) {
        // Display the FPS
        myText.innerText = frameCounter + " frames";
 
        // Reset the FPS counter
        frameCounter = 0;
    }
 
    // Increment the FPS counter
    frameCounter += 1;
    lastUIRefreshFPS = now;
    msRequestAnimationFrame(renderLoopFPS);
})();

I made some very minor changes to this code and hooked it up to the onmainwindowactivated event. This uses the msRequestAnimationFrame method. You can read it’s documentation here.

If you run the app you should get the following framerate in the middle of the screen as shown below:

image

It is quite a ways off compared to the detail of the XAML version of the framerate counter and was also more difficult to do (screenshots of XAML version below).

image

image

Now it is time for you to make the decision, do you develop in XAML / C# or HTML / JS? In this blog, we will be diving into XAML / C# with Metro, but may post the occasional HTML / JS app. =)

Thanks for reading!

mike_new_avatar Michael Crump is a Silverlight MVP and MCPD that works for Telerik as a XAML Evangelist. He has been involved with computers in one way or another for as long as he can remember, but started professionally in 2002. After spending years working as a systems administrator/tech support analyst, Michael branched out and started developing internal utilities that automated repetitive tasks and freed up full-time employees. From there, he was offered a job working at McKesson corporation and has been working with some form of .NET and VB/C# since 2003.

You can follow Michael on Twitter or keep up with his blog by subscribing to his RSS Feed.
Posted On Thursday, September 29, 2011 6:04 AM | Feedback (0)
Killer Build Interviews and XAML Sessions.

 

I have been watching the influencer interviews with Richard Campbell as well as the Build Sessions recently published on Channel 9. Like most of you, I am trying to learn as much as I can about this new platform in the shortest amount of time. That is why I’m going to share my list of Killer Build Interviews and XAML Sessions.

Note: Click on the image thumbnail to watch the video.

First up, Interviews

Working at Telerik means that you get big influencers and great hosts at events like Build. I have listed several interviews that I enjoyed below.

Billy Hollis

Billy discusses the importance of user experience, stipulating that design principles have and will continue to play a key role in that. He looks forward to seeing more UX examples, beyond Metro, for the variability of purposes that applications serve. He also discusses ‘if’ and ‘how’ the Microsoft ecosystem will change for component vendors.

image

Tim Huckaby

Tim expresses his excitement about the news from //build/, ‘It’s all good for .NET people, and it’s all good for the future.’ Other topics include what applications make sense for Metro and what don’t, Kinect, 3D cameras, and the future of touch.


image

Miguel Carrasco

Miguel discusses the importance of UX in Windows 8 and where he falls in the Silverlight vs. WPF vs. HTML5 debate. XAML plays a particular role in scaling UI elements for the different sized screens on which Windows 8 works. Nevertheless the key thing is that all technologies are brought under one umbrella. Kendo UI and all the existing Telerik controls from Telerik will continue to work on Windows 8.

image

Telerik has also posted a lot of other great influencers that you may want to check out.

Great Build Sessions – If you haven’t watched the Keynote then you may want to start there.

Tim Heuer – Build world-ready Metro style app using XAML.

image

Tim Heuer – Tips and tricks for developing Metro style apps using XAML.

image

Alnur Ismail – Build accessible Metro style apps using XAML

image

Alnur Ismail – Make great touch apps using XAML.

image

Joe Stegman – Metro style apps using XAML: What you need to know.

image

John Papa – Stand out with styling and animation in your XAML app.

image

If you want to watch other great XAML sessions then check out this post by Tim Heuer.

Thanks for reading!

mike_new_avatar_thumb1_thumb_thumb Michael Crump is a Silverlight MVP and MCPD that works for Telerik as a XAML Evangelist. He has been involved with computers in one way or another for as long as he can remember, but started professionally in 2002. After spending years working as a systems administrator/tech support analyst, Michael branched out and started developing internal utilities that automated repetitive tasks and freed up full-time employees. From there, he was offered a job working at McKesson corporation and has been working with some form of .NET and VB/C# since 2003.

You can follow Michael on Twitter or keep up with his blog by subscribing to his RSS Feed.
Posted On Friday, September 23, 2011 12:20 PM | Feedback (1)
Enabling Frame Rate Counters for XAML Applications in Windows 8

 

Introduction

One of the things that we all look at before we ship software is the performance of our apps. Last November, I posted a quick and easy way to do it in Silverlight. Today, I am going to walk you through doing it in Windows 8 for your Metro XAML applications.

After the Build event was over, I was interested in learning how to do this for my Windows 8 Metro Apps. I started watching videos from the Build RSS Feed and noticed this one from Tim Heuer that did just that.

Let’s get started

Click/Touch the “Developer Command Prompt” to begin. 

image

That will open a Developer Command Prompt. At the command prompt, simply type in “regedit” without quotes as shown below.

image

Add the Registry Key

Now, depending on the version of Windows 8 you have installed navigate and add the following key.

32-bit version of Windows 8

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Xaml]

"EnableFrameRateCounter"=dword:00000001

64-bit

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Xaml]

"EnableFrameRateCounter"=dword:00000001

In my case, I was using Windows 8 64-bit. I had to create a new key called XAML and added a DWORD (32-bit) named EnableFrameRateCounter with a value of 1

image

image

Let’s test it

All you have to do now is to run any XAML / C# Metro Application.

image

Ok, so what do these numbers mean? Again, thanks to Tim Heuer for the nice slide.

image

You will notice that any application built using XAML / C# will display this framerate counter. Even the ones that ships with Windows 8. (For example: The Memories application)

image

What about HTML / JS apps?

It will not work with HTML / JS Metro Applications as I tried it. I think that is why the registry key starts with “XAML”. =)

image

image

Thanks for reading!

mike_new_avatar_thumb1_thumb Michael Crump is a Silverlight MVP and MCPD that works for Telerik as a XAML Evangelist. He has been involved with computers in one way or another for as long as he can remember, but started professionally in 2002. After spending years working as a systems administrator/tech support analyst, Michael branched out and started developing internal utilities that automated repetitive tasks and freed up full-time employees. From there, he was offered a job working at McKesson corporation and has been working with some form of .NET and VB/C# since 2003.

You can follow Michael on Twitter or keep up with his blog by subscribing to his RSS Feed.
Posted On Wednesday, September 21, 2011 7:08 AM | Feedback (0)
My guest-blog post on Silverlight 5 for the MVP Award Program Blog

 

Introduction

I’m sure by now you have heard that the Silverlight 5 Release Candidate has been released. I recently had a chance to Guest Blog for the Microsoft MVP Award Program Blog on “Getting Started with the Silverlight 5 Release Candidate”. Now before we get started learning about it, let’s look at a few new features:

What is new in the Silverlight 5?

  • Multiple Window Support - Trusted app can create additional Windows.
  • Ancestor RelativeSource Binding – Enables a DataTemplate to bind to a property on the control that contains it.
  • Implicit DataTemplates – Allows you to target a data template for a specific data type.
  • ClickCount - Enables Multi-click input on left/right mouse buttons.
  • Binding on Style Setter – Allows binding to be used within styles.
  • Realtime Sound (low-latency Audio) - Enables pre-loading of an audio source for precision timing of playback. (Multiple playback is ok)
  • Variable Speed Playback (“Trick Play”) – Fast-Forward or review at variable speeds.
  • Linked Text Containers - Text will overflow from one to the next.
  • Custom Markup Extensions – Allow you to run custom code from XAML.
  • XAML Binding Debugging - Setting breakpoints in XAML
  • 3D Graphics API - accelerated visualization and rich user experiences.
  • P/Invoke – Enables managed code to call native code.
  • Much, much more.

The Full Article

The full article is hosted on the Microsoft MVP Award Program Blog. You can also access it by clicking on the screenshot below. Don’t forget to rate it and leave comments if you wish.

image

Thanks for reading!

mike_new_avatar_thumb1 Michael Crump is a Silverlight MVP and MCPD that works for Telerik as a XAML Evangelist. He has been involved with computers in one way or another for as long as he can remember, but started professionally in 2002. After spending years working as a systems administrator/tech support analyst, Michael branched out and started developing internal utilities that automated repetitive tasks and freed up full-time employees. From there, he was offered a job working at McKesson corporation and has been working with some form of .NET and VB/C# since 2003.

You can follow Michael on Twitter or keep up with his blog by subscribing to his RSS Feed.
Posted On Tuesday, September 20, 2011 3:00 PM | Feedback (3)
Download all the Build Videos with RSS

 

image

Introduction

The conference sessions are starting to appear on the Channel 9 RSS feeds right now. If you are like me then you probably want to download all of them and watch them later. Here is the method that I use to grab all the videos and thought that it would help others.

Note: You can use either Juice or PowerShell (which is located at the bottom of this post).

Let’s do this with Juice

Navigate over to http://channel9.msdn.com/Events/BUILD/BUILD2011/ and select the option to Subscribe to this event:

image

I wanted all Build2011 session in WMV with High quality. (surprising… isn’t it)

That gives me this URL: http://channel9.msdn.com/Events/BUILD/BUILD2011/RSS/wmvhigh

I can plus that into my browser and see the following:

image

But if you click on one of them then it just takes you to the page:

image

I could care less about this page as I only want the videos and I may not have an internet connection later on.

Let’s solve this

Step 1- Download Juice and run the installer.

Step 2 – Once it is installed then hit the Add Button.

SNAGHTML6e84953

Step 3 – Copy and Paste the URL of the feed you want to download.

SNAGHTML6e90aae

Step 4 – That’s it. You are ready to start downloading. Please note that the files that have a 0.0 MB have not been added to the feed yet. Give it a day or so and it should appear. 

SNAGHTML6ea5a34

If you really don’t want to install juice software then you can use PowerShell.

Let’s do this with PowerShell

The good news is that if you are using Windows 7 right now then you already got PowerShell installed.

Go ahead and create a folder somewhere on your computer named: Build11. If you want to follow my example then just put it on the root of C:

Now open up your favorite text editor and copy/paste the following code:

cd "C:\build11"
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
$a = ([xml](new-object net.webclient).downloadstring("http://channel9.msdn.com/Events/BUILD/BUILD2011/RSS/wmvhigh"))
$a.rss.channel.item | foreach{ 
    $url = New-Object System.Uri($_.enclosure.url)
    $file = $url.Segments[-1]
    $file
    if (!(test-path $file))
    {
        (New-Object System.Net.WebClient).DownloadFile($url, $file)
    }
}

Note: The PowerShell script code is taken from a post by Scott Hanselman and variations of it exist all over the web.

Go ahead and save the file as downloadall.ps1.

You should have a folder named build11 and one file in it named downloadall.ps1.

image

The only thing you will need to do now is go to a command prompt and type “powershell”.

SNAGHTML6f7afc3

Navigate over to the directory you created earlier. I created one called build11.

Once you have navigated over to it, do a “dir” to see the contents. If you see your downloadall.ps1 script then your good to go.

SNAGHTML6fd176b

Enter the command ./downloadall.ps1

If your having trouble actually running that command then refer to this post.

SNAGHTML6fdd58b

Give it a few minutes (depending on your internet connection) and the files should start appearing in your build11 folder.

image

Conclusion

I hope this guide cleared up some of the confusion that people had with downloading all of the videos. If you would like to read more about Build from my perspective then check out the links below:

Bullet Points from Build–Day 1 and my thoughts

From Soup to Nuts: Using VirtualBox with Windows 8 Developer Preview

Thanks for reading!

mike_new_avatar Michael Crump is a Silverlight MVP and MCPD that works for Telerik as a XAML Evangelist. He has been involved with computers in one way or another for as long as he can remember, but started professionally in 2002. After spending years working as a systems administrator/tech support analyst, Michael branched out and started developing internal utilities that automated repetitive tasks and freed up full-time employees. From there, he was offered a job working at McKesson corporation and has been working with some form of .NET and VB/C# since 2003.

You can follow Michael on Twitter or keep up with his blog by subscribing to his RSS Feed.
Posted On Thursday, September 15, 2011 2:48 PM | Feedback (3)
From Soup to Nuts: Using VirtualBox with Windows 8 Developer Preview

 

I am like everyone else when it comes to Preview OS Software. I don’t want it on installed on my primary machine and I don’t want to lug around another laptop to try stuff. I am not a fan of booting of VHD (which I will explain in a second). Scott Hanselman made a great post on how to do this if you are interested however. The main issue that I see with this approach is that the bootloader on my MAIN MACHINE is replaced with the Windows 8 Preview one. Yikes! I don’t want any preview software with that kind of control of my system. So, what did I do? I installed VirtualBox and then installed Windows 8 Developer Preview onto it. I captured almost every screen, so it may be helpful to even a beginner.

Let’s get started.

Update: If you want to use a adjust the resolution to something like 1920x1080x32 then follow Mister Goodcat’s tutorial located at http://www.pitorque.de/MisterGoodcat/post/Installing-Windows-8-Developer-Preview-in-a-virtual-machine.aspx.

Step 1

Before you download any software, go ahead and make sure you have Virtualization Technology turned on in your BIOS. Here is a great guide on how to do that.

Step 2

Install and download VirtualBox 4.1.2 or later (if it exist).

http://www.virtualbox.org/wiki/Downloads

Go ahead and double click on the installer and go through the following screens:

SNAGHTML6a05dda

I left this page at the default settings.

SNAGHTML6a09e63

Same on this page.

SNAGHTML6a0c67c

This next page will warn you that it will reset your Network Interfaces:

SNAGHTML6a0f153

..almost finished.

SNAGHTML6a1256d

And your done.

SNAGHTML6a22eb0

Step 3

Now would be a great time to download the .ISO if you haven’t already. There are a couple of different versions of the .ISO. Since you are reading a developers blog then I would assume you want the one on the top that comes with the Developer Tools.

image

The other versions do not include the tools, but Microsoft has provided a x64 / x32 as well.

Step 4

Brett Stanley – http://www.objectsplus.net gave a great tip that I failed to mention: I wanted to add that in the First Run Wizard, Select Installation Media screen you can choose an .iso directly, negating the need to mount the image with another tool. :-)

or

Once that is downloaded, then you might want to go ahead and mount the .ISO using CloneDrive.

image

The process is simple as it’s just a right click on Mount Drive then browser to the .ISO Image.

Step 5

Now it is time to setup VirualBox. Go ahead and run it and select “New”…

SNAGHTML6a331bc

SNAGHTML6a700be

On the OS Type, I selected Windows and Vista 64-bit as obviously VirtualBox does not support Windows 8 yet. Other people have commented that Windows 7 x64 works as well.

SNAGHTML107e583

The next screen is Memory. I actually have 8GB in this machine but wanted to see the performance of 512mb. I would recommend setting this to at least 1-2GB.

SNAGHTML6a81ce5

For Hard Disk, I simply created a new one.

SNAGHTML6a888e0

I set this to VDI as I never plan on using this VM with other virtualization software.

SNAGHTML6a8eb3b

I opted for dynamically allocated because it will only use my physical hard drive if the VM requires it. (such as adding new programs, etc)

SNAGHTML6a91c58

For this next screen, you DO NOT want to make this around 10GB as the install will alert you it needs more space. 15GB is the minimum but I would recommend at least 20GB.

SNAGHTML6a9d5b8

After clicking Next, you will have a VM ready to use.

SNAGHTML10f80e7

Before we run the VM, go ahead and right click it to make a few adjustments to the settings.

SNAGHTML110262b

Go ahead and click on System and make sure you Extended Features looks like the following:

SNAGHTML111041a

Make sure the next tab called Processor has the following checkbox checked.

SNAGHTML112083f

On the last tab, called “Acceleration” Make sure it looks like the following:

SNAGHTML1131875

One last tweak is to enable 3D Acceleration on the Display Menu.

SNAGHTML113c8ef

Step 6 – Liftoff

We are finally ready to run our machine. Hit the Start button.

SNAGHTML1155f73

You will get the following screen. You may want to read it if your not used to virtualization software.

SNAGHTML6aaf7e8

SNAGHTML6ab3757

You should point it to the drive letter assigned to the .ISO image you mounted.

SNAGHTML6ac0ea3

SNAGHTML6ac407b

After you hit “Start” it should start copying files over…

SNAGHTML6acabfa

Finish up with clicking next and the rest is as they say history.

SNAGHTML51d79a

After it finishes installing, you can start enjoying Windows 8.

SNAGHTMLea7218

Pro Tip: For those having troubles with Win 8 apps running in VirtualBox: Increase your screen resolution to at least 1024x768. Thanks to @ArielBH for the tip.

Links

Some keyboard shortcuts for Windows 8.

You also may enjoy reading my blog post titled, “Bullet Points from Build Day 1”.

mike_new_avatar_thumb[1] Michael Crump is a Silverlight MVP and MCPD that works for Telerik as a XAML Evangelist. He has been involved with computers in one way or another for as long as he can remember, but started professionally in 2002. After spending years working as a systems administrator/tech support analyst, Michael branched out and started developing internal utilities that automated repetitive tasks and freed up full-time employees. From there, he was offered a job working at McKesson corporation and has been working with some form of .NET and VB/C# since 2003.

You can follow Michael on Twitter or keep up with his blog by subscribing to his RSS Feed.
Posted On Wednesday, September 14, 2011 2:24 PM | Feedback (14)
Bullet Points from Build–Day 1 and my thoughts

 

I usually do a bullet points from major conference events like this one from Mix11. The purpose of this post is to get you up to speed quickly with news and links you may enjoy.

Build – Day 1 Keynote

  • Windows 8 takes about half the amount of RAM to run compared to Windows 7.
  • Windows 7 usage by consumers is now greater than Windows XP.
  • Like the Metro Interface? Well, you better as the interface is similar to the Windows Phone 7.
  • You can unlock your touch-enabled PC by tapping certain spots on a picture. Even using swipe gestures.
  • Want to use a keyboard/mouse instead of touch? Well you can, so stop worrying.
  • Get used to the word – Charms.
  • You can use either XAML/C#/VB/C++/C or HTML/JS/ to write Windows 8 Applications.
  • Expression Blend 5 will support HTML and CSS Editing as well as XAML.
  • Windows 8 will have better security with things such as Defender and the ability to detect malicious virus at the bootstrapper level.
  • Everything is hardware accelerated (uses the power of your GPU).
  • WinRT – Stands for Windows Runtime – 1800 Objects in their new API.
  • Spellcheck in everything; everywhere.
  • The new version of Visual Studio has templates to create metro applications.
  • There will be a new Windows Store that will allow you to deploy your application from within Visual Studio 11.
  • Microsoft provides guidance on how your app should look.
  • Windows Store lets you determine the price/trial period of your app. Includes a certification process.
  • Silverlight to Windows 8 looks painless. The demos included one line of code for Windows Phone 7.
  • Additional features for Accessibility. (It will increase tiles and so forth)
  • Windows 8 boots freakin’ fast. Some pcs were showing Windows 8 as fast as they could open the lid to the machine.
  • IE 10 is designed to be used for Windows 8.
  • Live DOM in Expression Blend allows Drag-and-Drop of Elements in HTML5.
  • Everyone in the audience got a tablet equipped with Windows 8 and tools necessary to build applications.
  • Multi-monitor support – think UltraMon but better.
  • If your PC has USB 3.0 support – Windows 8 will use it. File copy demo was amazing.
  • Windows 8 is not just for play. Several demos showed them using it with a mouse/keyboard combo.
  • Windows Live will allow you to connect devices together. Example: browser photos from other PCs.
  • ASUS and Toshiba have ultra-thin laptops under 2.5 lbs.

My thoughts on the Keynote:

Let me go ahead and say that I am excited about what I heard today. I am a Silverlight MVP and I also love Silverlight very much. But what I’m really in love with is XAML and C#.  That is NOT going away with developing Windows 8 applications. We can take our existing XAML skills and write Windows 8 applications. This doesn’t mean our existing Silverlight applications won’t run as they will. Nor does it mean that we won’t be creating new Silverlight applications. Silverlight 5 is being released at the end of this year.

The Visual Studio 11 Templates for XAML/C# look very easy to build plus its just a few lines to convert Silverlight application into the Metro Interface (if that’s what you want). The same is true with developing Windows Phone 7 apps. I am also excited that we are getting support for HTML/JS in Blend 5.

I feel that Microsoft got this one right by addressing the tablet device and changing the look and feel of Windows. From the looks of things, developers have a lot to be excited about in the future.

Helpful Links:

Microsoft

Windows 8 Platform Preview will be downloadable tonight around 8PM PST. This comes with the dev tools and either 32 or 64 bit versions. 
Sessions have been announced and you can view after 24 hour after the session.

Others
Todd Anglin’s post on Top 10 Moments from Build Day 1 Keynote
Telerik’s post “Your Investments are Safe with Telerik”
Jeremy Likness post on Windows 8 and Build Day 1 Keynote

mike_new_avatar_thumb[1] Michael Crump is a Silverlight MVP and MCPD that works for Telerik as a XAML Evangelist. He has been involved with computers in one way or another for as long as he can remember, but started professionally in 2002. After spending years working as a systems administrator/tech support analyst, Michael branched out and started developing internal utilities that automated repetitive tasks and freed up full-time employees. From there, he was offered a job working at McKesson corporation and has been working with some form of .NET and VB/C# since 2003.

You can follow Michael on Twitter or keep up with his blog by subscribing to his RSS Feed.
Posted On Tuesday, September 13, 2011 4:10 PM | Feedback (2)
I am proud to announce that I have joined Telerik.

Telerik

 

2011 has been a very exciting year for me so far.

  1. I was awarded the Microsoft Silverlight MVP.
  2. I was renewed as the DZone MVB.
  3. I was awarded as a GeeksWithBlog Influencer.
  4. I won the CodeProject Windows Phone 7 Competition.
  5. I’ve been invited to speak about Silverlight at UserGroups as well as several major conferences such as SSWUG, CodeStock and devLINK.
  6. My first e-Book on Producing and Consuming Silverlight in an OData application was published.
  7. I’ve been asked to be a technical editor for two Silverlight Books.
  8. I started a UserGroup that was XAML-focused called “All About Xaml”.
  9. I’ve been featured on a ton of podcast including: Windows Phone Dev Podcast, Dream-in-Code, SSWUG SelectViews and several others.
  10. I was awarded the WindowsPhoneGeek Valued Blogger.
  11. I was accepted as a CodeProject Associate and Mentor.
  12. As well as created 69 blog post on XAML technology on michaelcrump.net.

… but the thing that I’m the most proud of is Telerik offering me a position at their company.

For the back story, I have been involved with Telerik for several years. I know a majority of their staff in the USA as they have sponsored my UserGroup as well as my “Monthly Silverlight Giveaways”. While working with the staff at Telerik my respect for them has only grown stronger. I feel like I’ve joined the “big leagues” now and I am very honored that they would have me. So, I will be joining Telerik as a XAML Evangelist starting 9/12/2011.

So, I know you are probably wondering what this mean for my blog? Well nothing changes at all. I now have even more time to help developers by creating screencast, blog post and speaking engagements. Yes, I will be blogging about Telerik products as I usually blog about whatever I am working on. But, I wouldn’t blog about a product that I do not believe in 100%. I will still deliver the same blog post regarding everything XAML that everyone is used to reading. I feel that everyone benefits from this.

If you see me at an event, be sure to stop by the booth and say hello.

P.S. I just noticed after looking at the stats by Justin Angel, the Telerik WP7 SDK is the leading WP7 3rd party control manufacture and the 18th most used WP7 3rd party controls (including the free ones). Very cool stuff, indeed.

alt Subscribe to my feed

Posted On Friday, September 09, 2011 10:10 AM | Feedback (8)
Yet another Beeping P/Invoke Demo (SL5 RC)

image

Introduction

You might have noticed that the Silverlight 5 (Release Candidate) is out. One of the new features included in the RC is the ability to call P/Invoke. In this short demo, we will write a Silverlight 5 application that uses the feature.

Tools needed:

Getting Started

Go ahead and open Visual Studio 2010 SP1 and select File->New Project then Silverlight Application.

SNAGHTML425f655

By default, we have a new option called “Silverlight 5” selected as the Silverlight Version. Let’s go ahead and leave it at that. You also have the ability to select Silverlight 3 or 4 from this drop-down.

SNAGHTML427e8ce

Let’s go ahead and Right click on our project and select Properties.

image

Put a check in “Enable running application out of the browser”.

image

Now go ahead and put a check in “Require elevated trust when running outside the browser”.

SNAGHTML2b29bb45

Switch back over to the MainPage.xaml and add in the following code:

<Grid x:Name="LayoutRoot" Background="White">
    <Button Height="23" HorizontalAlignment="Left" Margin="169,132,0,0" VerticalAlignment="Top" Width="75" x:Name="btnclick" Content="click" Click="click_Click" />
</Grid>

This will simply put a no thrills button on the page that the user can press to call the P/Invoke code we will add shortly.

Let’s go ahead and add a new class to the project.

image

Let’s call it PlatformInvokeTest.cs and add the following code (Note: If your having a problem getting it to work then use my solution at the bottom of the post):

using System;
using System.Runtime.InteropServices;

namespace SilverlightApplication26
{
    public class PlatformInvokeTest
    {
        [DllImport("kernel32.dll")]
        public static extern bool Beep(int frequency, int duration);

    
        public static void PlaySound()
        {
            Random random = new Random();
            for (int i = 0; i < 50; i++)
            {
                Beep(random.Next(10000), 100);
            }
        }
    }
}

Let’s switch back over to the MainPage.xaml.cs and add the following code:

using System.Windows;
using System.Windows.Controls;

namespace SilverlightApplication26
{
 
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void click_Click(object sender, RoutedEventArgs e)
        {
            PlatformInvokeTest.PlaySound();
        }
    }
}

Now when the user fires up this project the application will go out of browser and the computer will beep multiple times in a different frequency each time.

You can also get this same functionality in-browser by going back to the Properties page and selecting “Require elevated trust when running in-browser”.

image

The only thing to note is that the .aspx page is no longer set to the default in your web project so you will need to do a “View in Browser” on your .aspx page in order to test.

image

Conclusion

As you can see it is very easy to use P/Invoke in a Silverlight 5 application. This sample was pretty simple but image the possibilities such as detecting when a USB key is inserted into a PC and copying files onto it through a Silverlight 5 application? Pretty cool stuff!

If you want the source code to this application and other Silverlight 5 demos then be sure to check out Michael’s “Mega Collection of #Silverlight 5" Demos.

Other Silverlight 5 resources by me are listed below:

My webinar on “Getting started with the Silverlight 5 Beta”.

Getting Started with the Silverlight 5 RC
Getting Started with the Silverlight 5 Beta!
Game Changing Features in the Silverlight 5 Beta (Part 1)
Game Changing Features in the Silverlight 5 Beta (Part 2)
Game Changing Features in the Silverlight 5 Beta (Part 3)

alt Subscribe to my feed

Posted On Friday, September 09, 2011 6:44 AM | Feedback (0)
Getting Started with the Silverlight 5 RC

image

Today the release candidate of Microsoft’s Silverlight 5 was released to the public. If you want to know “What’s new in Silverlight 5” then check out this page on Silverlight.net and continue reading the article below.

Getting Started


First, we are going to need to download the required tools to install the Silverlight 5 RC. Before getting started, please note that you can install the Silverlight 5 RC on top of the final release of Silverlight 4. If you have the Silverlight 5 Beta installed, then you might want to go ahead and remove those first.

Tools needed:

This download will install all components necessary for Silverlight 5 RC and Microsoft WCF RIA Services V1 SP2 Preview (April 2011) development including:

  • Silverlight 5 Beta Developer Runtime
  • Silverlight 5 Beta SDK (software development kit)
  • Update for Visual Studio 2010 Service Pack 1 and Visual Web Developer Express 2010 Service Pack 1 (KB2502836)
  • Microsoft WCF RIA Services V1.0 SP2 Preview (April 2011)

If you want a direct link to the files then you can click here.

Documentation:

There are also a couple of optional files you can install at this point. They are not required, as long as you followed my guide so far. Most of these tools are automatically installed when you installed the Silverlight 5 Tools.

Extras:

PS: Lots of other great Silverlight 5 links are at the bottom of this post!

 

At this point, you will have the bits downloaded and are ready to get setup with the Silverlight 5 RC. So, go ahead and double-click on the Silverlight5_Tools.exe and you will see the following screen:

SNAGHTML35a97dd

This is going to install the required software to build Silverlight 5 Application. You can go ahead and click the “Next” button.

SNAGHTML35ad182

I suggest placing a check in both checkboxes if you agree to send anonymous feedback of the installation experience, as I believe it will help Microsoft improve the final release. Go ahead and click the “Next” button.

SNAGHTML35b17a6

At this point, the program will begin installing the required files.

SNAGHTML3664d65

After it is complete, then go ahead and hit the “Finish” button. You can optionally view the log file and you should see “Installation completely successfully” as shown below:

SNAGHTML366f058

You can now load Visual Studio 2010 Service Pack 1 or Visual Web Developer Express 2010 Service Pack 1. Once you have it loaded, go ahead and click “File”, then “New Project”.

image

Go ahead and Select “Silverlight Application” and give it a name to continue.

SNAGHTML425f655

You may notice that, by default, we have a new option called “Silverlight 5” selected as the Silverlight Version. You also have the ability to select Silverlight 3 or 4 from this drop-down.

SNAGHTML427e8ce

Once you hit “OK”, then you are ready to start developing Silverlight 5 RC Applications.

Right now the release just came out and if you want to play with a few Silverlight 5 samples then you check out some of the other resources by me listed below:

My webinar on “Getting started with the Silverlight 5 Beta”.

Michael’s “Mega Collection of #Silverlight 5" Demos
Getting Started with the Silverlight 5 Beta!
Game Changing Features in the Silverlight 5 Beta (Part 1)
Game Changing Features in the Silverlight 5 Beta (Part 2)
Game Changing Features in the Silverlight 5 Beta (Part 3)

Older resources by me:

Silverlight 5 – What’s New? (Including Screenshots & Code Snippets) 

Other resources by other Silverlight MVPs and Community Leaders:

Silverlight 5 Release Candidate is now Available - Download Silverlight 5 RC
Silverlight 5 RC Released - Using PInvoke
Silverlight 5 RC Now Available
Silverlight 5: Remote control and MediaCommand Support

 

alt Subscribe to my feed

Posted On Thursday, September 01, 2011 4:47 PM | Feedback (1)
Extracting a SQL CE DB from Isolated Storage in WP7 Mango.

Introduction

By now, most of you have heard that Windows Phone 7 – Mango release will support Local Databases (SQL CE) using Linq to SQL. But what you probably haven’t heard much about is how to extract the .SDF that is created in isolated storage to your local computer and view the contents. I find this extremely important for debugging application and making sure my database is setup exactly like I want it. So, that is what we are going to do today.

Getting Started with a sample application:

Local Database Sample

For this tutorial, we will need a sample application that uses a local database. If you are already using a local database (SQL CE) in your mango application then you can skip this section otherwise go ahead and download the “Local Database Sample” from MSDN.

Below is an excerpt from the MSDN Page

On Windows Phone OS 7.1, you can use LINQ to SQL to store relational data in a local database that resides in your application’s isolated storage container. This sample is a to-do list application that uses a multi-table local database. Items that appear in the list are added, updated, and deleted from a local database, where they will persist between application launches. For step-by-step information about how to develop this application, see How to: Create a Local Database Application with MVVM for Windows Phone.

Download Sample: C# | VB

The Database Structure

We see code that defines our database name in App.xaml.cs. It is simply called ToDo.sdf:

// Specify the local database connection string.
string DBConnectionString = "Data Source=isostore:/ToDo.sdf";

And code that creates a table and defines the columns

[Table]
public class ToDoItem
{
    [Column( IsPrimaryKey = true )]
    public int ToDoItemId { get; set; }
 
    [Column]
    public string ItemName { get; set; }
 
    [Column]
    public bool IsComplete { get; set; }
 
    [Column]
    public int _categoryId { get; set; }
 
    [Column]
    private Binary _version { get; set; }
}

Please note that I removed all code relating to MVVM to simplify this example. If you wish to see the code then please review Model –> ToDoDataContext.cs. This sample also has another Table called ToDoCategory that was not included in this tutorial. 

Now that we have reviewed what the database looks like, lets see what it takes to extract the .SDF file from isolated storage to our local pc.

Get the required tools if you haven’t already.

  1. Download the Windows Phone SDK 7.1 RC and install it if you already have not.
  2. Grab the Silverlight Toolkit for Mango.
  3. Download the “Local Database Sample” from MSDN if you want to use this example.

Go ahead and run the application and enter some data. My screen looks like this:

image

This should be enough data for us to work with.

 

Leave the emulator running and navigate to the Properties –> WMAppManifest.xml file. Open up notepad and copy/paste the ProductId into it.

image 

Go ahead and navigate over to your “C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.1\Tools\IsolatedStorageExplorerTool” and run the following command:

ISETool.exe ts xd 888a966b-516e-4f9d-a6c3-343454e07466 "C:\Users\MichaelCrump\Desktop\IsoStore"

You should:

  • Replace the GUID with your own.
  • Give it a proper file location to output the file.

Here is what my command window looks like:

SNAGHTMLcd2a9

Note: I kept getting this message that is was already being used but it actually built the file anyways.

Navigate over to the directory that you specified earlier and you will see your .SDF file from IsolatedStorage. Pretty cool huh?

SNAGHTMLf7cfc

 

Go ahead and switch over to Server Explorer inside of Visual Studio 2010 and let’s add that SDF to the project. Right click on Data Connection then select “Add Connection”.

 

image

 

Make sure you select the Data Source to be: SQL Server Compact 3.5 and then hit Browser and select the .SDF file just created.

Please note that I could not get SQL Server Compact 4.0 Data Source to work with this sample.

SNAGHTML129bd1

Hit OK and you should see your database that you crated in Mango (that was living in Isolated Storage) inside of Visual Studio.

image

Now if you right click on a table then you can “Show Table Data” kind of like we are used to with normal SQL Server DBs.

image

 

Exactly the data shown in the first screen shot!

 

image

One thing to note here is that this is simply a way to VIEW what was in isolated storage. You may want to read up on modifying IsolatedStorage using the same tool if that is your intention.

Conclusion

Of course, the IsolatedStorageExplorerTool is for more than SQL CE db’s. Basically anything in Isolated Storage in your app it can extract. It also works with devices as well as allows you to add files to IsolatedStorage from your local PC. With every release of Windows Phone we are seeing the tools become better and better. I am very excited to see what is coming in future releases. I hope this helps someone out there troubleshooting a bug with their Windows Phone 7 application. Until next time, thanks again for reading.

alt Subscribe to my feed

Posted On Thursday, September 01, 2011 5:53 AM | Feedback (1)
Tag Cloud