Avalon Beta 1 RC Breaking Changes

Breaking changes are a fact of life when living on the bleeding edge of betas and CTPs, especially for technologies like Avalon and Indigo which haven't officially shipped yet.  There have been lots of changes between the March CTP and Beta 1 RC, and there will be lots more to come.  Remembering the CLR/.NET Framework changes between Beta 1, Beta 2, and the RTM of v1.0, I know we're still in for quite a ride!  At least this time I don't have to try to keep a 1600-page book in sync with all the changes! :)  Good luck, Chris and Chris!

I thought I'd share the changes I ran into with my playing cards sample as I moved it from the March CTP to Beta 1 RC.

In source code, the only change I made (in Hand.xaml.cs) was to make Hand derive from Viewbox rather than Grid.  I could have left it alone, but it felt more natural to have Hand be a Viewbox rather than a Grid containing a Viewbox.  The March CTP compiler had prevented me from doing the former.

Of the four XAML files in the complete sample, I only had to change one of them (Card.xaml).  But there were lots of changes, indeed:

  • x:StyleID changed to Name
  • TransformCollection changed to TransformGroup
  • *Alias(Target=Background) changed to {TemplateBinding Background}
  • SourceId and TargetId (in EventTriggers) changed to SourceName and TargetName
  • DeactivateAction (in EventTriggers) changed to StopAction
  • On the ParellelTimelines, I had to play around with Duration and FillBehavior settings to get the desired effects when pairing the MouseEnter/MouseLeave animations.  It was hard to get right, but there should be some changes in this area in the future to make things easier.
  • I had to alter the paths in my SetterTimelines in order to animate my transforms.  For example, (Grid.RenderTransform)[0].(RotateTransform.Angle) changed to (Grid.RenderTransform) .(TransformGroup.Children) [0].(RotateTransform.Angle)
  • In all of my DrawingBrushes, I removed the Viewbox attribute (Viewbox="0 0 1468 2053").  Another option would have been to set ViewboxUnits="Absolute" .  Why?  The meaning of the coordinates has changed, with the default now being ViewboxUnits="RelativeToBoundingBox".  But since the coordinates now get calculated automatically if you don't specify them, I just removed them altogether.
  • On the button, ID changed to Name.  This was a big change to FrameworkElements that all Avalon components are likely to run into.

There were a lot more breaking changes that my sample managed to avoid because there were two ways to do certain things in the March CTP and now there's only one way to do them.  I chose the way that survived the upgrade, but you could easily run into these changes.  For example:

  • The deprecated attribute syntax described here (such as using  *null instead of {x:Null} ) was still supported in the March CTP, but not in Beta 1 RC.  Upgrading means you're now forced to make the switch.
  • You can no longer use System.Windows.Shapes inside of a DrawingBrush.  Instead, you must use the new Drawing classes: DrawingGroup, GeometryDrawing, & ImageDrawing.  This is a big change, but it has lots of benefits.  A DrawingBrush can now exist in a Resources dictionary, and since the Drawing classes inherit from Animatable (rather than FrameworkElement), a lot of properties are removed (which were never supported inside a DrawingBrush anyway), giving a much smaller memory footprint.
  • There have been a number of changes to the way styles are defined.  For example, you no longer embed controls or a VisualTree inside them.  You set properties, such as the "Template" property, which holds a ControlTemplate much like what the VisualTree used to be.

Are you struggling with any other breaking changes that I didn't cover?  Let me know and I'll see if I can help!