TreeView and HierarchicalDataTemplate, Step-by-Step

I’ve never found TreeView to be terribly confusing by itself.  But usually I want to data bind a TreeView to a collection with some hierarchy, which leads me to HierarchicalDataTemplate, which didn’t always just write itself for me.  If you look at it in steps, though, there really is a pretty nice progression from ListBox…

27

Why is it called a "DependencyProperty"?

When we create new classes and members we spend a lot of time and effort to make them as usable, understandable, and discoverable as possible.  We follow the .Net Design Guidelines in general, and in particular we constantly look at how this new class relates to other classes, future plans, etc.   So we went…

7

ICommand is like a chocolate cake

(This has been updated with some information about the origin of a routed command’s route, and of focus scopes.)   ICommand in WPF is a pretty simple thing at its core.  But it gets more interesting and complicated as you build up functionality on top of it, and integrate it into the higher layers of…

13

Of logical and visual trees in WPF

This post is about the “logical tree” in WPF, and how it differs from the visual tree.  For the most part you don’t need to understand this.  But if you want to understand some of the nit-like details of property inheritance, {DynamicResource} references, and ElementName bindings, this may be interesting. A long time ago, I…

9

Model-see, Model-do, and the Poo is Optional

Like a lot of people, I’ve developed software professionally for a lot of different environments:  PC systems and embedded systems; high- and low-level languages; kernel mode, user mode, real mode, and protected mode; system services; domain controllers; bootstrappers; image processors; a debugger; a compiler; a search engine; small systems and really big systems; file systems;…

4

A look at stretchy elements

There are several elements in Wpf that have a “Stretch” property.  The basic idea of these properties is to allow you to specify how an element adapts itself to a layout container, such as a Grid.  For example, if you have a 100×200 pixel image, and it’s being positioned in a 150×300 pixel cell in…

1

Namespaces in Xaml

If you’re really into Xml conformance, and you’ve really wondered how Xaml uses Xml namespaces, read on; I can cover the most relevant details in 1160 words or less …   Namespaces on tags   (I’m using the term “tag” here instead of the more correct term “element”, so that I don’t get confused with…

1

Expandos in xaml

This post has a couple of suggestions on ways to accomplish expandos in Xaml.  First some background …   On an HTML page you can define your own new “expando” properties on the fly, such as in this example:   <HTML>   <BODY onload=’paragraph1.innerText = paragraph1.testing’>     <P ID=’paragraph1′ testing=’1, 2, 3’/>   </BODY> </HTML>…

1

Where does a Binding find its data?

If you’ve look at much WPF Xaml you’ve probably seen bindings like this:   <TextBlock Text=”{Binding Name” />   … which binds the Text property of the TextBlock to the Name property of some data object.   The question that begets is:  where does the data come from?  The rest of this post looks at…

5

Parameterized templates; and how to create reusable, custom-looking buttons without code

I’ve talked to a few people recently about parameterized templates, and so I wanted to write some of it down.  Here’s the scenario … I want to create an application that has a main window with several buttons on it.  Clicking one of the buttons navigates you to part of an app.  For example, in…

1