XAML Power Toys for Visual Studio 2008 v5.0.0.1 Released

October 25, 2009

At the request of a XAML Power Toys user I have updated XAML Power Toys for Visual Studio 2008 to version v5.0.0.01.

This update adds one new feature and corrects the v5 known issue.

The ViewModel creation window now allows selecting the name of the method that is used to raise the  PropertyChanged event.  You can thank Ted Warring for the suggestion.  Awesome Ted, appreciate the feedback and feature suggestion.

ViewModel Creator Gets New Feature

The ViewModel creator tool makes building a ViewModel class a snap.  This feature is sensitive to C# and VB.NET and will create the correct code for you.

The yellow highlight indicates the new feature added in v5.0.0.1.  You can now select or type in the name of the method that will be called when raising a PropertyChanged event.

This name value is also used if you selected the Implement INotifyPropertyChanged option.

This name feature enables you to use any name in your ViewModel base classes and have the generated code us it.

v5001ViewModel

As always, you can download XAML Power Toys for Visual Studio 2008 here:

http://karlshifflett.wordpress.com/xaml-power-toys/

Close

Hope you use and enjoy XAML Power Toys for Visual Studio 2008.

Have a great day,

Just a grain of sand on the worlds beaches.


Much Improved .NET 4.0 WPF Text Rendering

October 22, 2009

In .NET 4.0 WPF text rendering has been greatly improved.

However this new feature is not enabled by default.

You can read the complete feature write up on the WPF Text Blog.

The scenario where you get the most payback for using this feature is with text that is sized 15pt and below.

Line of Business forms containing TextBlocks, Labels, CheckBoxes, RadioButtons, Buttons and TextBoxes will have FontSizes below 15pt and will receive the most benefit of this new feature.

The feature is enabled by placing the “TextOptions.TextFormattingMode” attached property on the UI Element or on a parent UI Element.

<TextBlock Text=".NET 3.5 rendering" />
        
<TextBlock Text=".NET 4.0 improved rendering" TextOptions.TextFormattingMode="Display" />

The below XAML demonstrates how to have all text rendering use the new text rendering feature by placing the “TextOptions.TextFormattingMode” attached property on the Window.

In the below example, all child controls of the Window will use the new text rendering.

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525" 
    TextOptions.TextFormattingMode="Display">
    <Grid>

        <TextBlock Text="Inherited the .NET 4.0 improved rendering" />

    </Grid>
</Window>

Visual Studio 2010 Beta2 and .NET 4.0 have a lot of new goodness, go check it out!

Have a great day,

Just a grain of sand on the worlds beaches.


Visual Studio 2010 Beta2 Sample Data Project Templates

October 21, 2009

Silverlight 3 application demonstrating Sample Data.

SilverlightSampleData

Displaying Sample Data in the WPF and Silverlight Designer for Visual Studio 2010 Beta2 is now very easy with the design time DesignData markup extension.

The below video is a complete tutorial for using Sample Data in your WPF and Silverlight applications.  Please take a view few minutes to view it.

The Sample Application templates have many comments in them, walking you through Sample Data.  Please take a few minutes and review the projects created by the Sample Application Templates.

Beta2 Template Information

For Beta2, you need to use these templates to consume sample data in your projects.  The reason is the winfx.targets file for was not updated with the Sample Data Build Actions in time for Beta2.

These project files have been modified to include the DesignData Build Action for the Sample Data files.  All Sample Data files must have their Build Action set to DesignData in the properties window.

These templates will not be required for the final version of Visual Studio 2010.

There are really two templates.

1.  <Language> <Platform> Empty Application – this template consists of an empty project file and the added Build Action DesignData.

2.  <Language> <Platform> Sample Application – this template consists of a sample application that has sample data files and a UserControl that demonstrates how to consume the sample data.  It also includes the added Build Action DesignData.

WPF Templates

VB WPF Application DesignData – Empty VB.NET WPF Application template with sample data support.

VB WPF Application DesignData Sample – VB.NET Sample WPF Application that demonstrates consuming sample data.

CS WPF Application DesignData – Empty C# WPF Application template with sample data support.

CS WPF Application DesignData Sample – C# Sample WPF Application that demonstrates consuming sample data.

Silverlight Templates

VB SL Application DesignData – Empty VB.NET SL Application template with sample data support.

VB SL Application DesignData Sample – VB.NET Sample SL Application that demonstrates consuming sample data.

CS SL Application DesignData – Empty C# SL Application template with sample data support.

CS SL Application DesignData Sample – C# Sample SL Application that demonstrates consuming sample data.

Sample Application Template Usage

The WPF and Silverlight sample application template creates an application complete with sample data files, entity classes, a UserControl consuming the sample data files and

xmlns:d – How To Easily Add The d: Namespace

All design time properties live in a design time namespace that is part of this schema: http://schemas.microsoft.com/expression/blend/2008.

Examples of design time properties are, d:DesignWidth, d:DesignHeight, d:DesignInstance, d:DesignData, d:DataContext, d:Source.

In order to use the d: properties you must have a xmlns declaration in your XAML.  In Visual Studio 2010 there is a very easy way to add it to a Window, UserControl or Page .xmal file.

If you select the root control, you’ll see a Root Size Mode button displayed in the lower right hand corner.  Clicking this button changes the size mode of your root container from Auto to Fixed or from Fixed to Auto.

If the d: namespace has not been added to the root control yet, clicking this button will do it for you.  In addition to the d: namespace, mc: is added and the mc:Ignorable is added also.

AutoSizedRoot

I have modified each of the starter templates below to automatically add this for you.  However, as you add new Windows, Pages or UserControls, those templates may not have the d: namespace declarations, so the above trick comes in handy.

Adding a New Sample Data File

Open an existing Sample Data project or Create a new project using one of the Sample Data templates.

Add a resource dictionary to the project naming it <my entity class name>SampleData.xaml.

For example:  Customer sample data file would be named, “CustomerSampleData.xaml”

The the file properties as pictured below:

SampleDataSettings

Build Action: DesignData

Copy to Output Directory: Do not copy

Custom Too:  <blank>

Editing a New Sample Data File

This is an example of a single instance sample data file.

<local:Customer
    xmlns:local="clr-namespace:WPFApplication2"
    Age="21" Email="jim@hotmail.com" 
    FirstName="Jim" LastName="Smith" />

Sample Data files allow you to construct your objects in XAML.  You can set the required properties as illustrated above.

The below code illustrates how to create a collection of items in a sample data file.

<local:Customers xmlns:local="clr-namespace:WPFApplication2">
    <local:Customer 
        Age="21" Email="jim@hotmail.com" 
        FirstName="Jim" LastName="Smith" />
    <local:Customer 
        Age="22" Email="jane@hotmail.com" 
        FirstName="Jane" LastName="Smith" />
</local:Customers>

The above Customers class derives from the Generic List of Customer.

Consuming Sample Data in WPF

<!-- DataGrid Sample-->
<Grid d:DataContext="{d:DesignData Source=/SampleData/PeopleSampleData.xaml}" 
      Grid.Row="1" Margin="7">
    <DataGrid ItemsSource="{Binding}"/>
</Grid>

Sample Data is exposed through the d:DataContext design time property.  Design time properties are not compiled into your applications.

In WPF this is how you start at the root, navigate to SampleData folder and get the xaml file.

Consuming Sample Data in Silverlight

<!-- DataGrid Sample-->
<Grid d:DataContext="{d:DesignData Source=../SampleData/PeopleCollectionSampleData.xaml}" 
      Grid.Row="1" Margin="7">
    <data:DataGrid ItemsSource="{Binding}"/>
</Grid>

In Silverlight you have to ../ up to the root, then navigate to SampleData folder and get the xaml file.

Slight difference between WPF and Silverlight.

Video

PLEASE view this short tutorial video.  You will get a full and quick understanding of this great feature.

This video link supports right click, save as…

  Sample Data Tutorial Video (22 minutes)

Installing Templates Using The Download

For VB.NET copy the download to:

C:\users\<your user name>\Documents\Visual Studio 2010\Templates\ProjectTemplates\Visual Basic

Unzip the download in this folder.  You should have 4 zip files in the folder.  You are ready to go.

For C# copy the download to:

C:\users\<your user name>\Documents\Visual Studio 2010\Templates\ProjectTemplates\Visual C#

Unzip the download in this folder.  You should have 4 zip files in the folder.  You are ready to go.

Downloads

After downloading one or both template downloads, you’ll need to rename the file extension from .doc to .zip.  This is a requirement of WordPress.com.

Requires:  Visual Studio 2010 Beta2

Silverlight Templates require:  Silverlight 3

VB.NET Project Templates (61KB) (updated 10-28-2009)

C# Project Templates (58KB) (updated 10-28-2009)

Installing Templates From Within Visual Studio 2010 Beta2

The sample data templates are also be individually available on the Visual Studio Code Gallery.

To use a single template open the New Project Dialog and select the Online Templates tab at the bottom left.  You can browse all available templates or search for “design” and all the templates will be listed.

Close

Hope you use and enjoy Sample Data in Visual Studio 2010 Beta2.

Gentle reminder, please watch the above video too.

Have a great day,

Just a grain of sand on the worlds beaches.


Developers – Must Learn – Booting Windows 7 from a VHD

October 9, 2009

For the past few months I’ve been sharpening my Windows 7 skills and discovered what many systems people already know; “you can easily setup and boot Windows 7 or Server 2008 R2 VHD.”

Someone may already be thinking, why do I need to boot a VHD?

It’s no secret that Microsoft will be shipping Visual Studio 2010 Beta2.  If you want to be notified when Beta2 ships you can sign up here:  http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx

Some developers prefer to install beta software on a non-production machine or set up a multi-boot box.

This is where VHD’s come into play.  You can setup a VHD on your desktop or laptop, then from the boot menu, select to boot that VHD or boot the operating system.  I’ve been doing this at home and work for awhile now and love it.

VHD’s also enable you to have a x32 O/S boot and a x64 O/S boot on the same machine.   Possibilities are endless.

When you’re done with the VHD, just delete it and make a new one.

VHD’s sport great performance.  If you use the fixed size VHD, the total performance cost is 3%.  When I boot a VHD on my laptop I don’t see any drop in performance from booting the original O/S.

VHD’s do not require Hyper-V to boot them.  Server 2008 R2 does have a Hyper-V feature that allows you to log onto a VHD.  But what I’m explaining here does not require Hyper-V.  This is why I love this feature, it just works.

Recommendations

Before creating a new VHD, defrag the volume you want to add the VHD to.

I always create a fixed size VHD to ensure maximum performance.  Dynamic sized VHD’s offer flexibility with respect to size but pay a performance hit.

I’ve been allocating 45GB for all my VHDs.  This leaves plenty of room for Windows 7, Visual Studio, Microsoft Office and other applications and data on the VHD.  After you have created and configured a few of these, you’ll determine what works best for you.

I created a c:\vhd folder and locate all my VHD files here.

Possible Configuration Scenarios

Computer has Windows 7 or Server 2008 R2 installed and one or more Windows 7 or Server 2008 R2 VHD’s.

Computer does not have any O/S installed, but has one or more VHD’s that can be booted.  How cool is this?

Possible VHD Installation Options

Create a new VHD and install Windows 7 from a DVD or network location.

Create a new VHD and use imagex.exe to restore a .wim file to the VHD.  This is my favorite.  This saves so much time.  You install an O/S, configure it and install all the other software you need (except Visual Studio).  Then use imagex.exe to save a copy of the O/S and software to a .wim file.  You can then use imagex.exe to restore that .wim file to a VHD or if you need to a boot partition.  I do this at work every 1-2 weeks.  Takes a few minutes to pave my box.  Awesome software imagex.exe is!

On my laptop and desktop systems, I keep an extra VHD file that is all ready to go.  It’s configured and has all the software I need except Visual Studio.  Then when I want to load up another version of Visual Studio, I copy the files I need, delete the old VHD, copy the standby VHD to another new VHD, boot the new one and install Visual Studio.  Even on my laptop with the 45GB file copy and installing a new Visual Studio I’m up and running quickly.

Imagex.exe

What is imagex.exe?  Read this: http://technet.microsoft.com/en-us/library/cc507842.aspx

Where can I get imagex.exe?  Here: http://www.microsoft.com/downloads/details.aspx?familyid=696DD665-9F76-4177-A811-39C26D3B3B34&displaylang=en.  

Read how Scott Hanselman uses imagex.exe.  Great blog post!  Step-By-Step: Turning a Windows 7 DVD or ISO into a Bootable VHD Virtual Machine

Links

Rather that create a new blog post with pictures, etc, I’m going to provide the links that I’ve used to be successful with VHD’s.

Scott Hanselman: Step-By-Step: Turning a Windows 7 DVD or ISO into a Bootable VHD Virtual Machine

Microsoft TechNet: Windows 7 Boot from VHD.  This is actually the home page for a 3 part series on VHD files.  Very well written and covers the scenarios I’ve listed above. 

Microsoft Evangelist Keith Combs: 

Video:  Dual Boot from VHD with Windows 7 and Windows Sever 2008 R2
Article:  Dual Boot from VHD Using Windows 7 and Windows Server 2008 R2

Close

I hope you find this information informative and useful. 

Have a great day,

Just a grain of sand on the worlds beaches.


Follow

Get every new post delivered to your Inbox.

Join 244 other followers