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:
The download link has been updated. CLick the following link to download the source code:
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.
New source code link updated here
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.
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:
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.
Sample code (all XAML) posted here
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? 😛
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 🙂
August 14, 2007
The other day I was searching around for examples of Office 2007 like “Smart Tag” type of popup implemented in WPF, but I could not find any with source code available. As you know that the tooltip control in WPF/XAML does not allow any controls you put inside a tooltip to receive focus or mouse click events, you have to use the primitive Popup control instead to achieve such functionality. So I decided to build one myself. It turns out the process is quite simple. The only trick that I find out and still not know how to solve elegantly is wiring up the delayed popup solely in XAML. Currently my implementation utilizes a custom service class that wires up the mouse events between the popup and the target control. The XAML part of the control is very simple:
Inside your Popup definition, you can define your Smart Tag popup as you would in any other XAML elements. The following is an example of a toolbar enclosed inside thepopup:
In order to support positioning the popup control in arbitrary location close to (but not border-to-border) its target control, you need to wire the MouseMove and MouseLeave events of both the Popup control and the target control. And you need a delayed hide/show service to ensure that the popup won’t flash if you quickly move your mouse around. This is achieved through a delayed DispatchTimer in the DelayedPopupService code.
This is a screen shot of the Smart Tag popup:
To see the Smart Tag in action, you can view the following screen clip:
Let me know what you think of this.
The complete source code of the sample is uploaded.
New source code link is posted.