A Comparable DataTrigger

Property triggers today only check for equality.  We’d like to add support for other comparison operators, but that hasn’t happened yet.  But I needed them for a project, and wrote a workaround for it.  It’s a bit hacky in a couple of places, but if you can get past that, it’s a handy way to…

7

Compact CheckBox Sample

I was creating a view of an object that had a bunch of boolean properties, but I wanted to keep the visual representation small.  So I created a look for a compact CheckBox that I liked enough to post. As an example scenario, say I’m visualizing a the attributes of a file (hidden, system, archive,…

2

Trying out Binding.StringFormat

  StringFormat is a new property in .Net 3.5 SP1, which is currently in Beta.  See Scott’s blog for more info on the beta.     When you bind data into a property on an element, it’s automatically type converted for you.  For example, this markup:   <StackPanel xmlns:sys=”clr-namespace:System;assembly=mscorlib”>     <StackPanel.DataContext>         <sys:Int32>123</sys:Int32>     </StackPanel.DataContext>…

7

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

Binding to anonymous types in an Xbap or Silverlight application

It’s easy to use Linq queries to create objects, and to use {Binding}s to bind properties of those objects into your view.  If you’re doing this for an application that will run as an Xbap (“WPF Browser Application”) or as a Silverlight app, just note that you need to generate nominal types rather than anonymous…

5

Simple way to create a gradient brush in Xaml

  Rob, Nikhil & I were talking today about the early days of Xaml when you could create linear gradient brushes as an attribute value.  E.g. (borrowing from Rob’s post on this subject) instead of creating a LinearGradientBrush for the fill of a rectangle with this Xaml: <Rectangle Width=”300″ Height=”200″ >     <Rectangle.Fill>         <LinearGradientBrush>…

1