What is new in WPF and Cider on the .NET Framework 4 and VS2010 beta 2 release

Jaime Rodriguez
On Windows Phone, Windows Presentation Foundation, Silverlight and Windows 7

What is new in WPF and Cider on the .NET Framework 4 and VS2010 beta 2 release

Rate This
  • Comments 0

This post is a quick recap of the most important changes for WPF and Silverlight developers in this Beta 2 release. I definitely will return to a few of these topics over the next few weeks, so stay tuned for updates and new posts. Please note that this post is NOT all-inclusive; there are lots of features and smaller bug fixes that I am leaving out. I will try to dig those up as we go along in the next few weeks!

Also, I've listed links to the Beta 1 posts at the bottom of the post for those needing a refresh. I've also sprinkled links to the videos in our “WPF in VS2010 Beta 2 series” throughout the post, as well as listing them at the end.


New in the Visual Studio 2010 Cider designer

You can see a video with most of the Beta 2 updates in this 14 minute video with Mark Wilson Thomas.
In the video, Mark shares a MUST USE registry key to improve the performance of Visual Studio 2010 Beta 2.

For the record, this is in the readme, it is not a hack and Mark has documented it on his announcement:

Registry Switch for improved performance
Because of a late-breaking change, you will need to make a configuration change to see the best designer performance. This configuration change will not be necessary in the final released versions of the product.
NOTE: Editing the registry can cause serious problems that may require you to reinstall Windows. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk. Refer to the article on registry editing for your OS (e.g http://support.microsoft.com/kb/136393) for advice. 
1. Close any open VS instances
2. Open RegEdit (as an administrator as needed)
3. Select the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0 key
4. Right click and add key, type ClrHost
5. In the newly created key, right click and add a DWORD32 with the name StartupFlags
6. Set its value to 5
7. Close RegEdit
8. Start up Visual Studio and use as normal

[10/28 update. Mark now has a disclaimer and it is in bold red on his page, so it must be important, go read it:

  1. The registry hack might create instability or increased Virtual Memory Usage in some VS scenarios.  If you see this, feel free to remove the config change and report it on Connect.
  2. Also, if you are not using Cider designer a lot (for WPF and Silverlight) the configuration change is not helping you. So don't enable it unless you are using the designer a lot. ]

Here are my cliff-notes from the video:

For WPF developers

  • The designer continues to stabilize.  All the features introduced in Beta1 – including improvements on the designer, brush editor, IntelliSense on binding markup extensions, data sources window- have been cleaned up and the performance has been boosted. 
  • The property browser has been updated with a new view that tells you what is the source for the value of a property (e.g. is the source set locally, from a style, binding, etc.).   This feature is proving incredibly handy based just on my one week of using it!
  • Support for StaticResources in app.xaml. Finally! No more long pack://application,,,/ syntax required.
  • Improved error handling, much like Blend, where the designer can isolate errors to a specific user control; the designer now ‘recovers’ and gives you meaningful information about the error.
  • Now there is design-time data support; compatible with Blend. 

For Silverlight developers,

  • You finally get an interactive designer where you can drag & drop and get all the designer features available in WPF -  zero to 70 MPH in a single release- Cha-Ching!!

New Graphics (minus text) features for the WPF run-time?  
       You can watch demos for most of these in this video with David  Teitlebaum.  You can get the demos for this video here.

  • Cached Composition. This feature allows you to “cache” any UI Element as a bitmap that can be persisted in video memory. The cache supports dirty regions, so it redraws when needed (with out you needing to detect it).  
    Cached elements can be live objects (e.g. a textblock) and can be transformed, rotated, etc.
    This feature is incredibly powerful for WPF scalability. If you watch David’s video you will see how he went from ~10fps on a live drawing, to 60fps when he cached it. I recently had a similar experience in a 3D viewer; my CPU decreased by 80% for all my drag & drops once I cached the 3D scene during the drags.
  • Layout Rounding allows WPF to avoid the blurriness that results in images and text when they are using layout with sub-pixel positioning.  This feature is in Silverlight 2; again, nice to have compatibility.
  • Pixel Shader 3 support expands the effects pipeline significantly since PS3 has a lot more instructions. A good reference on difference on # od instructions between PS2 and PS2 is at wikipedia.
    Note: The gotcha for this features is that Pixel Shader 3 does not default back to software rendering, so you will need to test to see if hardware supports the feature before you use it.
  • Animation easing functions allow designers to create more realistic, fluid animations. This feature matches the easing functions in Silverlight 3 and provides XAML compatibility.  Out of the box, you get  CircleEase, BackEase, ExponentialEase, Quadraticease, CubicEase, QuarticEase, Quinticease, PowerEase, Elasticease, BounceEase, and SineEase.  There is also an interface (IEasingFunction), so you can create your own easing functions and plug them into any of the existing animations via a new Dependency property on all stock animations. 
  • RenderOptions.ClearTypeHint allows you to turn ClearType on in scenarios where the system previously turned it off.

New Text Features
You can watch most of these improvements with insightful explanations in this Channel9 video with Chipalo Street.

  • A new text rendering stack improves the clarity and puts  the application developer in control of the rendering and formating options. With this new stack you choose between the old world WPF text (which worked well for some scenarios), and new text with comparable sharpness to Win32/GDI. 
    Configuring the text enhancements is handled mostly via two new attached properties:
    • TextOptions.TextFormatingMode allows you to control the metrics for formatting text. You get two options:
      • Ideal – is the old WPF, the glyphs maintain high fidelity with their outlines, and placement of the final glyph is not taken into account
      • Display – uses GDI compatible metrics and ensures glyph widths are in whole pixels (clarity of the text is much higher when text aligns to whole pixels)
    • TextOptions.TextRenderingMode allows you to control how the text is rendered.
      • Auto – respects the system setting; this is usually ClearType for most systems
      • ClearType – forces the rendering to Cleartype -this is what we were doing in earlier versions of WPF
      • GrayScale – renders grayscale, antialiased text
      • Aliased –  no antialiasing is used.
        Note: Per Chipalo, aliased vs. antialiased does not lead to perf differences; this surprised me.
  • Embedded bitmaps adds support for (mostly) East Asian fonts that contain bitmaps for some characters at small sizes.
  • Bindable Run is simply the old Run, fixed so that Run.Text is a dependency property and can be data bound.
  • Customization support for Caret Brush allows you to replace the Caret in TextBox, PasswordBox and RichTextBox. You can replace the CaretBrush with any brush. Go crazy!  You can also customize SelectionBrush and SelectionOpacity on all controls that support selection –including TextBox, RichTextBox, PasswordBox, FlowDocumentPageViewer, FlowDocumentScrollViewer and FlowDocumentReader.
  • Custom Dictionaries allows you to customize the dictionary used for spell checking in WPF applications. In previous releases, WPF used the OS dictionary, but did not allow you to extend it. Now with Custom dictionaries you can extend the dictionary to include your specialized industry lingo. 

New Control & Data binding features

  • VisualStateManager support. VSM actually ships in the platform and all the controls have been tweaked to support Visual States. This means you can now customize Control templates using VSM and get higher compatibility with Silverlight.
    Note: Despite the VSM support in all the controls, the actual control templates were not changed, you will need to replace the template to use VSM.
  • Inheritance Context for Input Binding enables the MVVM scenario of  binding InputBinding.Command to a command in a ViewModel.  The Key and Modifiers property in KeyBinding are now Dependency Properties; same for MouseAction and MouseBinding.
  • DependencyObject.SetCurrentValue  is a new method introduced mostly for Custom Control authors.  SetCurrentValue method changes the effective value of the property, but existing triggers, data bindings, and styles will continue to work because the ValueSource for the property is not changed.  A lot of the controls in WPF were tweaked to use this, so their old SetValue calls were replaced with SetCurrentValue. I hear the recommendation is for custom control authors to use this method instead of SetValue; reccomendation makes sense, I am not sure if it applies 100% of the time, or just 99%; so use with 1% caution.
  • Databinding support for DynamicObjects.  With .NET 4’s support for dynamic keyword, a lot of people will be using DynamicObject (and I DynamicMetaObjectProvider).  You will be able to bind to these dynamic objects using the same syntax than a property of any other object. You will even be able to use typed DataTemplates (as long as you are using concrete typesthat derive from DynamicObject.

New Windows 7 features

  • MultiTouch is fully functional in Beta2. WPF now has full support for multitouch including  manipulation, inertia, and raw-touch events.   The support is at UIElement, UIElement3D and ContentElement –which means every thing with LIFE in WPF supports Multitouch. 
    This topic is going to get its own blog post (and hopefully a video) soon, so stay tuned.
  • Taskbar support for Windows 7, including jumplists, progress bar, overlay icon, and thumbnail buttons (with WPF commanding support).  This topic will also get its own blog post soon.

Deployment update
You can watch a demo and get the whole picture from this Channel 9 video interview with Jossef Goldberg.

  • Client profile is critical to the deployment of the framework outside of managed enterprises. By subsetting the full framework to a client SKU, we will decrease download size, and improve the framework install times. 
    In Beta 2, client profile is near feature complete:
    • You can see it as its own separate, serviceable SKU
    • The tools have support for it, including the References dialog in VS2010 filtering for assemblies only in client profile SKU if that is what you are targeting. 
    • A few assemblies that were not in client profile SKU are now included, this increased the size to 30 MB, which is still a great improvement compared to full framework. 

Hopefully this gets you caught up on beta2.  Time to play! Download visual Studio 2008 beta2.  Stay tuned for a few more posts on the topics above.

LINK ROLL!!

Beta 2 links:

Beta 1 (but still relevant links)