Visual Brush in XAML

August 30, 2007

Visual brush in XAML is really easy and yet extremely powerful to use. Here I’ve included a list of examples I’ve gathered over the past few days. You may find them interesting 🙂


Another chart in WPF

August 21, 2007


A few weeks back I posted a WPF-based chart in my blog. Currently in one of my projects I need to deploy charts that support displaying multiple data series side-by-side and showing the value tick on the top similar as Google Finance charts does. So based on my previous WPF chart, I developed this “another chart” that can support multiple series. Here I also used the performance optimization with streamGeometry to enhance the chart memory consumption and response speed. I have to admit this chart is heavily inspired by the features in the Google Finance charts.

You can take a look at the final chart in action:

[Updated 8/4/2008]

The download link has been updated. CLick the following link to download the source code:

http://www.box.net/shared/tsk8so30gc


Mini Task Pane in WPF

August 20, 2007


I was searching for a sample task pane implementation in WPF that I can use in one of my applications. What I was looking for is something that works similar as the mini task pane that exists in Windows XP Explorer.Originally I thought templating the Expander should be easy. But after couple of trials, I gave up and instead went the route to build my own composite User Control to completely customize the look and feel I need. It turned out building such task pane in XAML is fairly straightforward and not difficult at all. This again proves the “Power of Composition” in the design philosophy in WPF. The animation and the effects are pretty standard: ScaleTransform animation for the bottom panel and the RotateTransform animation on the header image icon when the expander is clicked. I really like WPF more and more comparing to the old days when I was working with Win Forms. This will be a non-trivial task if implemented in Windows Forms.

Here is the results of the mini task pane I’ve built.

You can get the source code of the demo project here.

[Updated: 1/16/2009]

New source code link updated here


Formatted Text in WPF

August 19, 2007

WPF has very rich support for displaying and manipulating formatted text. I’ve recently came across couple articles at MSDN on this topic. You can get an overview of the rich format support from this article. And then you can read the in-depth article on drawing formatted text.

This compares very nicely with this excellent book on .Net 2.0 Windows Form GDI+ graphics and text drawing by Eric White. Overall I am very impressed with the rich format text rendering support in WPF, despite some unresolved anti-alias issues I have on Windows XP workstations.


A Data-Bound progress bar in WPF

August 15, 2007

Several weeks ago I posted a sample progress bar using rectangle overlay to achieve gradient looking and text overlay. But that control was C# code-driven to update the UI. Here I’ve improved it to utilize ValueConverters and Data Binding, so you can update its source data and the UI can automatically updates.

The XAML part of the ProgressBar control is listed as following. I am using two-column grid to simulate the progress bar container:

Then you can define your custom ValueConverter to convert percentage progress values to grid column widths. The following shows the ValueConverter for the ProgressBar Column Width property inside the parent grid:

You can create other types of ValueConverter to suit your needs.

Once you are done , then in your code you can easily adjust your progress data without manually coding against the Progress Bar UI anymore:

This has advantages in situations where you need to implement data-driven applications without in-depth knowledge of the visualization layer.

The finished UI will look like this:

[Update 8/27/2007]

After some study of the ControlTemplate in WPF, especially those special meaning PART elements in a control template, I realized this could be implemented with a ControlTemplate with all XAML approach. 

The key to the control template is to use the PART_Track and PART_Indicator element to contain the rectangle areas.

[Update: 1/16/2009]

Sample code (all XAML) posted here


Excellent demo of building Line-of-Business Apps using WPF

August 14, 2007

The other day I was reading this blog post by Tim Sneath about building Outlook 2007 look-like Line-of-Business applications. Find it very helpful to grasp the layout and styling concepts in XAML if you are also building similar applications.

Here is a screenshot of the application:

If this can be ported into Silverlight then we don’t need Outlook Web Access anymore, or do we? 😛


Off-topic: The free screen cast you can use

August 14, 2007

I am using the free screen cast utility CamStudio to capture my XAML/WPF demos in action. Here is a screen shot of this little handy utility:

It can capture your screen cast in AVI format and then you can upload to YouTube for online demo.

Hope you will find it useful 🙂