A Custom Storyboard Component in Xaml

In WPF & Silverlight, a Storyboard is a collection of animations running in parallel.  Not everyone likes the name “Storyboard” though.  The idea behind the name was that that list of timelines running in parallel are like a list of plot lines in the plan for a movie. In any case, just like you can…

0

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

Building read-only objects in Xaml

We often use Xaml to instantiate and initialize objects.  For example, given “<Foo Bar=’1’/>”, a Xaml loader creates a Foo object, and sets the Bar property to 1.  That works when the Bar property is settable, but what can you do if it isn’t?   An example of this scenario in .Net today shows up…

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

Tip: Using XamlWriter and XamlReader to clone an object

There are multiple ways to clone objects, and multiple definitions of what “clone” should even mean.    The main issue is usually about cloning “deep” vs. “shallow”.  For example, if you have a Customer object that points to an Address object, and you clone the Customer object, does the Address object get cloned too (this…

4

Limited generics support in Xaml

In a post to the WPF forum, Zhou Yong had the idea to use a MarkupExtension to make it possible to create a generic dictionary (Dictionary<K,V>) from Xaml.  It’s a cool idea, so I played with it a bit, with the result shown below.  The end result is that you can do the following, for…

12

Xaml Inspired Markup

A lot has been written about how Xaml maps tags and attributes to objects and properties.  (Here’s a standard Xaml overview.)  But it’s not necessary that Xaml actually be used to create .Net objects.  For example, XPS is markup that can be treated like Xaml and used to create/initialize objects, but it can also be…

1

Being written by XamlWriter

A big part of WPF (Avalon) is the Xaml format for creating object trees.  You can also go in the other direction – take an object tree and write it out to Xaml – with the XamlWriter class.   It’s frequently easy for XamlWriter to convert an object into a good Xaml representation.  Sometimes, though,…

5