November 2007 - Posts
This article represents something new for me, normally my articles are a bit fanciful and are geared around some loose interest that I have. This time I decided to tackle a really old problem (well not so much of a problem but at least something old). I decided to write a game of Snakes, yes that right a game of snakes, but in WPF. For those of you new to WPF, WPF does not really have any low level rendering methods such as OnPaint(..) (well it does but thats not what WPF is all about). As you will see the games of Snakes is not as easy as one might think. This article will be using a lot of WPF tips and tricks along the way. What I will be doing is showing you a couple of screen shots along the way and discussing the requirements (self impossed) that the Snakes game has, and how and why these requirements were solved the way they are.
This article attempts to explain the thought processes I went through while designing and implementing a solution to a problem using WPF. If you are fairly new to WPF and are just starting to ascend its infamous learning cliff, perhaps this article will help to shed some light on why and how one might put many of the WPF concepts to use. I am not claiming that my way of approaching WPF is the "right" or "best" way, but simply the way I think about it.
This document tries to help answer the question “I’m displaying many items in an ItemsControl. How can I make scrolling / panning faster?”
Though WPF does its best to be as fast as possible, in some cases it’s necessary to write some things yourself. This is a guide to how to do that; it describes the performance bottlenecks you’ll see and suggests ways to get around them.
By reading this article you will learn how to create UserControls with WPF in a Control-library (Assembly) and use them in a WPF Application. In this example we will implement a UserControl that renders a 3D-Cube.
Microsoft's recent release of it's new web development technology, Silverlight, has generated a lot of interest. Originally code-named "WPF/E" (Windows Presentation Foundation / Everywhere), it was intended to be an online version of WPF. Silverlight certainly did a great job of that, and currently offers a wide selection of built in element and a number of classes seen in WPF, along with ones exclusively for Silverlight. In this article, I'll demonstrate how to take advantage of a number of Silverlight features to create a real-world application: a video player.
Take a look at a couple of the language enhancements in C# 3 (Visual Studio 2008) that can speed up your development and make your code cleaner: automatic properties and initializers.
The DockPanel probably offers you a better option than the UniformGrid in many cases. However, this layout panel too is not without its eccentricities and you can spend a lot of time tweaking and fiddling with settings in order to get the exact display you want.
However, if your needs are simple then the DockPanel works well. You do have to be aware of the effect of its "Pecking Order" approach to layout and distribution of space. What this means is that, if the user resizes the window to height/width ratios that result in the elements that are higher in the pecking order grabbing all the available real estate then some lower status elements may become unacceptably distorted or even disappear completely.
You can partly control this by use of MaxWidth, MinWidth, MinHeight and MaxHeight settings, but this isn't guaranteed to do the trick. It appears that the demands of elements higher up the pecking order override the requests of the lower, as you will see when we work through the samples that follow.