.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.
.NET 3.0, Programming, VS2005, VS2008, WPF
In Programming on 8 December, 2007 at 5:46 am
Yeah, how time flies! Near the end of the year already. Visual Studio 2008 has finally been released just 2 or 3 weeks ago. It is definitely a must for any .NET 3.0 developer to check out VS2008. With its built-in XAML editor whereby you can finally drag and drop UI controls from the toolbox, this is definitely a big step forward compared to VS2005.
I’ve also developed a VisionBoard program using WPF. It is a software that let you pin any pictures on to its board like surface. This is so that you can pin pictures of your goals that you want to achieve and thus remind you of what your goals are. The installation file is small, but I need to find a way to store those installation file. So stay tuned!
.NET 3.0, CTP, RC, Software, WPF
In Programming on 2 September, 2006 at 6:00 pm
Hot on the heels of Windows Vista RC1 (or is it the other way around?), Microsoft has released the set of tools that developers can use on Windows Vista RC1 (or use to develop applications that can work on Windows Vista RC1).
The Windows SDK has been updated to be compatible with RC1 of Windows Vista. Hopefully, all the header files that had been breaking since Windows Vista interim build 5483, has been fixed and applications build using Windows SDK July CTP will not crash on Windows Vista RC1 (they have been crashing on interim build 5536).
The .NET Framework 3.0 has been bump up to Release Candidate status. Thus any developer that feels more comfortable in Windows XP (hmmm….. that’s a thought) can install this build of .NET Framework 3.0 (together with Windows SDK RC1) and still be able to program applications that can work on Windows Vista RC1.
Strangely, the Visual Studio 2005 extension for .NET Framework 3.0 (codename Orcas) has not been updated to support RC of .NET Framework 3.0. It has been missing ever since Windows Vista July CTP and .NET Framework 3.0 July CTP. I hope this will be release soon.
Lastly, designers who wish to get onto the RC1 bandwagon, have to wait patiently. This is because Microsoft Expression suite of applications has not been release for RC1 just yet. Soon. I hope.
.NET 3.0, Programming, WPF
In Programming on 14 July, 2006 at 3:00 pm
With the release of the June CTP .NET Framework 3.0, transparent background and window with rounded corners can finally be easily tweaked in XAML. Lauren Lavoie, from Microsoft, blog about how you can go about doing it. The trick is in Window.AllowsTransparency, just set this property to “True” and then setting the Window.Background to “Transparent” will get you a transparent window. With the whole background being transparent you can then achieve rounded-corner window by drawing a Border with a CornerRadius defined. Below is a snippet of the XAML code that Lauren did:
- <Window x:Class=”WindowTransparency.Window1″
- xmlns=”http://shcemas.microsoft.com/winfx/2006/xaml/presentation”
- xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
- Title=”WindowTransparency” Height=”300″ Width=”300″
- AllowsTransparency=”True” WindowStyle=”None”
- Background=”Transparent”
- >
- <Border CornerRadius=”50″ Background=”Blue” Opacity=”.7″>
- <Button Click=”CloseWindow” Height=”30″ Width= “100″>
- </Button>
- </Border>
- </Window>
and the result:

Don't forget to check out her blog.