February 2006 Blog Posts
Rob Reylea has posted a XamlMigrate tool that helps migration of Xaml files to Feb CTP, really nice job!
posted @ Sunday, February 26, 2006 5:33 PM | Feedback (44)
WinFX Feb CTP Available

WinFX Feb CTP has just been released.
No EID (Sparkle) available yet for this CTP but it will be soon :-)

Karsten has an interesting list of breaking changes.

posted @ Wednesday, February 22, 2006 9:07 PM | Feedback (48)
Upcoming XAML changes

Rob Reylea announces some changes that we're gonna find on next WPF CTP.
Apart renaming renaming of xml urins it looks like that we won't need PI instructions anymore for CLR mapping, really hope Cider will handle this better as it does now...
Happy to read that an upgrade tool will be available...

posted @ Saturday, February 18, 2006 2:02 PM | Feedback (154)
EID: Applying style using triggers

“In XAML you can define a style and have it applied based on an Event,Property or DataBinding property change.
To give you an idea, here's a XAML fragment that sets some properties of a button when mouse is over it.

<Style TargetType="{x:Type Button}">
    <Trigger Property="IsMouseOver" Value="True">
    <Setter Property="FontSize" Value="20" />
    <Setter Property="Foreground" Value="Red" />

To have the same result using EID (a.k.a “Sparkle”) you have to follow some steps.
Let's try, as demo, to have the background of a button changing when IsMouseOver property is true.

  • Start by drawing a button on scene's document root.
  • Right click and select to Edit a copy of the style (BTW: You can see the structure of original style on EID timeline)
  • Click on Timeline's Create new state button, you should now have a new [No Triggers] tab
  • On Timeline Properties Palette, press Add button and type IsMouseOver on left textbox and true on right one.
  • Now change the backcolor of the button, when finished press Return to scope root button.
  • Test the scene

You'll see backcolor change on MouseOver.
Editing is far than complete, I'm still not able to edit some properties (e.g. Opacity) and looks like that Event/DataBiding triggers are still work in progress, but you should have an idea of how thing should work.”

posted @ Wednesday, February 15, 2006 10:50 PM | Feedback (102)
Using BitmapEffects

“You can easily apply effects like Blur or DropShadows to a UI element using BitmapEffects property.

This xaml sample:

<Image HorizontalAlignment="Left" VerticalAlignment="Top" Source="cor.jpg">
      <BlurBitmapEffect Radius="2"/>
<TextBox Text="Hello WPF">
      <OuterGlowBitmapEffect GlowColor="Green" GlowSize="5" Noise="3"  />
Produces this effect:

As you can see various effects can be applied to the same element, just keep in mind that effects are processed in sequence so the order of appearance inside counts.”
Unfortunately Sparkle does not support direct editing of this property yet.

posted @ Friday, February 10, 2006 5:52 PM | Feedback (653)
Databinding using "Sparkle"

How to create a user interface that displays data from an external DataSource using Expression Interactive Designer (“Sparkle“)

  • Create a new Visual C# Library project named PersonsDataSource
  • Remove Class1 and add both Person and Persons class (described in my previous blog)
  • Compile project, you should now have a PersonsDataSource dll.
  • Open Sparkle and create a new Project (File ->New Project) name it as you like.
  • Now let's add a reference to our PersonsDataSource.dll using Project->Add Item to browse to the previously created assembly.
  • You'll now see the dll listed under Project references.
  • Open the Data Palette (View->Data) and select Add new CLR DataSource, browse to PersonsDataSource and select Persons item, you should now see Persons listed inside Data palette.
  • Select Persons item from Data palette and drag it to Document root surface
  • You'll be asked to select how the Persons datasource will be displayed, select ListBox and click Ok.
  • The Create Data Template appears: This dialog allows you to 'shape' the DataTemplate associated to Person object, you can select what items and what controls to map to various Person fields (in this case dialog defaults to TextBlocks) leave defaults and click Ok.
  • You'll should see the listbox filled with Persons items.
  • We now want to add 2 texboxes that will be populated with Listbox selected item.
  • Select Library palette and drag two textboxes on DocumentRoot surface.
  • Select first texbox and, on Properties palette, click on Text field and select DataBind...
  • You'll now see the Create Data Binding dialog, we need to bind to Listbox selected item so click on Element Property and select ListBox.
  • Select SelectedItem among ListBox properties.
  • Listbox contains instances of Person classes so, select Use custom path expression and type “SelectedItem.Name” (without quotes) on related textbox, then click Ok.
  • Do the same with other textbox using “SelectedItem.Age” as custom path expression.
  • Press F5 and you'll see that selecting a listbox item selection will be reflected on both textboxes and that changes on textbox contents will be moved to underlying DataSource.
posted @ Friday, February 10, 2006 1:59 PM | Feedback (73)
A little bit of WPF DataBinding...

Let's assume you wish to use DataBinding to manage a set of Person class instances.

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;

 public class Person
  public Person (string name, int age)
   this.Name = name;
   this.Age = age;

  private int mAge;
  public int Age
   get { return mAge; }
   set { mAge = value; }

  private string mName;
  public string Name
   get { return mName; }
   set { mName = value; }

  public override string ToString ()
   return this.Name + " : " + this.Age.ToString();

Now we create a Persons class inheriting from generic ObservableCollection

public class Persons:ObservableCollection<Person>
  public Persons ()
   base.Add(new Person("Corrado",22));
   base.Add(new Person("Giulia",1));
   base.Add(new Person("Stefania",10));

We now use ObjectDataSource to create Persons instance and have it available as DataContext inside xaml.

<?Mapping XmlNamespace="tds" ClrNamespace="Demo" ?>
<Window x:Class="Demo.Window1"
  <ObjectDataProvider x:Key="Persons" ObjectType="{x:Type tds:Persons}"  />
  <DataTemplate DataType="{x:Type tds:Person}">
   <StackPanel Orientation="Horizontal">
    <TextBlock Foreground="Red" Text="{Binding Name}" FontSize="14" />
    <TextBlock Foreground="Blue" Text="{Binding Age}" FontSize="14"/>


   <ListBox ItemsSource="{Binding Source={StaticResource Persons}}" />    
Red lines are namespace to Xml mapping instructions (syntax is probably going to be modified on next CTP)
Magenta line is the ObjectDataProvider definition that allows us to use Person list as datasource on the listbox.
Green lines indicates that both ObjectDataProvider and DataTemplate objects are part of Windows Resources.
DataTemplate (in blue) describes how the UI should display the Person instance (otherwise the ToString() method it will be invoked) in this case I decided to use a StackPanel containing two textblocks both binding to Person properties.
Data are databound to listbox by ItemSource attribute (in orange)
Datatemplates are required because on WPF ItemsControls (like ListBox) are not limited to strings but can contain virtually everything.

Just a simpe demo, but as you know, we all need a starting point... :-)

posted @ Thursday, February 9, 2006 11:34 PM | Feedback (50)
Borland leaves the IDE arena...
Looks like Borland is targeting new horizons... more here
posted @ Wednesday, February 8, 2006 11:25 PM | Feedback (36)
A little help from Reflection...
Today a friend of mine asked me how to define enums containing white spaces, after my initial response (”Why the *** you want to do that?”) i ended up with this code that demonstrates how 'flexible' is .NET (in this case using VB but, as you know, language is just a detail...)

Created a custom attribute...

<AttributeUsage(AttributeTargets.Field)> _
Public NotInheritable Class EnumDisplay : Inherits
Private mText As
Public Sub New(ByVal text As String
 mText = text
 Public ReadOnly Property Text() As

...and a simple helper function that uses both Generics and Reflection...

Public Class EnumHelper
  Public Shared Function EnumToString(Of T As Structure)(ByVal value As T) As
  Dim sourceEnum As Type = value.GetType()
  Dim name As String = [Enum].GetName(sourceEnum, value)
  Dim fi As FieldInfo = sourceEnum.GetField(name)
  Dim att As EnumDisplay = TryCast(Attribute.GetCustomAttribute(fi, GetType(EnumDisplay)), EnumDisplay)
  If (att IsNot Nothing) Then Return att.Text
  Return name

Now you can define your own Enum and decorate it with EnumDisplay where needed...

Public Enum TempState
 <EnumDisplay("Hi Temperature"
)> HiTemperature

And get a string representation of enum field using:

Console.WriteLine(EnumHelper.EnumToString(TempState.HiTemperature)) ' Hi Temperature


posted @ Wednesday, February 8, 2006 10:47 PM | Feedback (35)
How to save custom types using Fx 2.0 settings

Here you can download a demo (VB & C#) that demonstrates how to save a custom type (in this case a Person Class) using Visual Studio 2005 settings, basically all you have to do is to associate the type with a custom TypeConverter so that settings engine is able to serialize your type inside user.config file.
More details on my
Italian blog

posted @ Wednesday, February 8, 2006 10:13 PM | Feedback (24)
HotFix for Windows Designer

If you, like many, suffer of Visual Studio 2005 designer crashed (often requiring you to restart VS) you'll be happy to know that a hotfix is now available (you have to query for it)
More details


posted @ Wednesday, February 8, 2006 10:06 PM | Feedback (46)
I was playing with Application.OpenForms and gone lost figuring that it doesn't work if you try it with an unmodified Form (e.g. Form2), after a search on LadyBug discovered that it depends on the fact that Form's name is actually formalized only after you add some controls or specifically set it using Name property.
I'd love to have this behaviour reported on MSDN... :-(
posted @ Wednesday, February 8, 2006 10:04 PM | Feedback (27)
WPF - January CTP
It looks like that WPF January CTP is binary compatible with December CTP, so if you're not interested on WCF or WWF (that has changed a lot...) you can skip downloading. :-)
posted @ Wednesday, February 8, 2006 10:01 PM | Feedback (180)

This is my personal blog.
These postings are provided "AS IS" with no warranties, and confer no rights.