Posts Tagged ‘WPF’

WPF Performance

February 4, 2010 2 comments

I’m doing some work on performance in WPF. One curious standout is dashed lines. A pen with the DashStyle set to DashStyles.Solid is very much faster than one with DashStyles.Dash. Obviously this will only make a difference if you’re drawing a lot of them, but if you have a hundred or so on a Canvas, you will notice a severe degredation in the smoothness of scrolling the Canvas.

Categories: Uncategorized Tags:

GlyphRun and So Forth

July 3, 2008 17 comments

In WPF there are a number of ways to get text painted, ranging from Label at the simple end, all the way down to GlyphRun if you want to get your hands dirty.

The latter stuff seems very thinly documented. Want to know what the bidiLevel parameter to the constructor of GlyphRun means? According to the documentation, it is "a value of type Int32". Very helpful.

This is a problem because it is your only option if you want to be able to control the positions of individual characters. The layer above is based around the FormattedText class, but it adds wrapping and rich text support, which you may not need, and exposes no ability to individually adjust the character positions.

Read more…

Categories: C#, WPF Tags: ,


June 7, 2008 3 comments

The executive summary of this post is as follows:


That line of code is all you need to make a blank window open in today’s Visual C++. And if you’re a veteran of the dark days of Petzold and Win32, that has to be viewed as a major improvement. (Even if that % operator does look like gibberish.)

Read more…

Categories: C#, WPF Tags: ,

WPF and Symmetry in Coordinate Systems

April 29, 2008 Leave a comment

WPF provides some types for representing geometrical concepts. The simplest one is Point, which is roughly like this:

public struct Point
    public double X { get; set; }
    public double Y { get; set; }

This is fine but it misses an important fact about the X and the Y fields, which is that if you tip your head over 90 degrees and look at your monitor sideways, the X and the Y swap over. Which is which is merely a matter of your point of view. And so it is frequently useful to support exactly the same operations in both dimensions, which means that you have to write very nearly exactly the same code twice.

Read more…

Categories: C#, WPF Tags: ,

Simpler Animation in WPF

December 21, 2007 Leave a comment

WPF has a very powerful animation system built into it. But you can tell just by looking at the design that Microsoft created it before certain features became available in C#.

It works by storing a reference to an object that has the ability to modify the value of a property on another object. That’s not very clear in abstract, so an example will be helpful. The "other object" might be a rectangle painted on the screen. The property on that object might be its opacity (the inverse of transparency). So an animation is an object that contains code that modifies the opacity of the rectangle, causing it to fade out of existence in a visually satisfying way.

Read more…

Categories: lambdas, WPF Tags: ,