.NET 3.0, C#, Programming, WPF, XAML
In Programming on 25 July, 2008 at 7:00 am
To expand on what I’ve mentioned in my previous post. The list box declared in XAML will look something like this:
<ListBox
x:Name="CheckList"
ItemTemplate="{DynamicResource CheckListTemplate}"
ItemsSource="{Binding Source={StaticResource CheckedSource},
Mode=Default}">
</ListBox>
Under the <Windows.Resources>, the data template will be declared as:
<DataTemplate x:Key="CheckListTemplate">
<StackPanel Margin="0,3,0,2" Orientation="Horizontal">
<CheckBox IsChecked="{Binding Path=IsShown}"/>
<TextBlock Text="{Binding Path=Name}"/>
</StackPanel>
</DataTemplate>
At the same place or inside a style XAML’s ResourceDictionary, the data source is declared as:
<source:SColorList x:Key="CheckedSource"/>
Inside the C# file the classes are declared as:
public class SColor : INotifyPropertyChanged
{
private string displayName;
private Color clrShow;
private bool permanent;
private bool show;
public bool IsShown
{
set
{
show = value;
OnPropertyChanged("IsShown");
}
get
{
return show;
}
}
public string Name
{
set
{
displayName = value;
OnPropertyChanged("Name");
}
get
{
return displayName;
}
}
public event PropertyChangedEventHandler
PropertyChanged;
private void OnPropertyChanged(String info)
{
if (PropertyChanged != null)
PropertyChanged(this, new
PropertyChangedEventArgs(info));
}
}
public class SColorList :
ObservableCollection<SColor>
{
}
Under an initialization method, you should then do the following:
SColorList colorList =
(SColorList)FindResource("CheckedSource");
After that is done, the binding is complete and you can then add data item into the colorList and it will show up in the list box control. And the best thing is your designer can do “magic” on the DataTemplate.
C#, Programming, Windows Vista
In Programming on 19 May, 2006 at 3:00 pm
I have a comment asking me “how do i add instal the shell api on my xp machine”. The answer to this question is actually quite simple; Just install the latest Windows SDK onto your XP machine and you will get the header file to those Aero API.
However, you can’t test your program under Windows XP; Those API will simply fail. Desktop Window Manager’s API will only function under Windows Vista. So you will need the latest compatible Windows Vista CTP build to verify your program. Have fun!
C#, Programming, Windows Vista
In Programming on 20 April, 2006 at 2:01 pm
Using the aero glass API, developer can bring in more glass into the application window, instead of just at the chrome (which is provided free of charge by Windows Vista).
Tim Sneath, Windows Vista Technical Evangelist, blog about how to add glass to a Windows Form application using, you guess it, C#.

The one single API that is important here is the DwmExtendFrameIntoClientArea(). From the name of the API, it seems that it is just instructing Desktop Windows Manager (DWM) to extend the chrome area into the client area. I should think that when the theme change to Aero Diamond, then we will also get diamond free!
OK, where’s my glass?