-
It hasn't been nearly as long as I thought but it's certainly been a while since I've posted. I helped out with one of the MIX09 keynote demos - the Silverlight 3 "Gratuitous Graphics" demo. Instead of keeping it tied up on my machine, I thought I'd share it:)
Try it here! (click “Open” if prompted)
I'm fixing a problem with the linked source; for now, you'll need to download and build the project (see link below.)
The Demo
Some of you may recall a very similar demo from MIX08 done with WPF. When the internal builds of SL3 included the new Perspective 3D feature as well as custom pixel shader support, I thought, "I wonder how hard it would be to replicate the WPF demo?" Turns out it wasn't very hard.
While visually they're very similar, the mechanism for creating the 3D look is different. WPF uses a 3D model and 3D rendering. In SL3, it's a perspective transform exposed as the Projection property on UIElement. It's of type ProjectionPlane which allows you to apply a perspective transform by specifying rotations about the X, Y and Z axes.
· SL3 Projection Property
o The 3D effect was created with UIElement.Projection property.
· Custom Effects
o I used the ones for WPF found on codeplex. These are written in HLSL (looks very similar to C.) I added some custom properties to these exposed on the defined Effects classes (e.g. I created the “ColorKey” property on the ColorKeyAlphaEffect so that you can dynamically pick which color to key from.) If you’re going to edit or create any of your own effects, you’ll need the Microsoft DirectX SDK to compile the shaders.
· Custom Physics Model
o I built a very simple physics model to create the bounce effect. I could have used the animation easing functions but I geeked out and used some long lost stuff I learned in college.)
· DataGrid & Validation
o Aside from video and images, the demo shows how you can apply the bouncy effect to standard controls. Inside the DataGrid, I took advantage of some of the new validation support in SL (try entering a 3 or more letters for the State and press “tab”.)
Net, you get something that looks like the following (RippleEffect applied):
And for pure gratuitousness, double-click on the top 5-10% of the top edge of the floating frame; you should get a nice little flip:

Otherwise, I’ve zipped up the entire solution (after doing some simplification) and made it available for download. If you have any questions about the code, let me knowJ
Download here:
Thanks
Henry
-
Traditionally, when you first get to the PDC and stop by the registration desk, you get a bag of all kinds of goodies, including a handful of CD's or DVD's that might contain relevant bits for attendees. This year, we're handing out the bits on a 160GB USB hard drive!
Since I'm helping organize the PDC this year, I just got to check it out (I'm actually writing this as I'm sitting in one of the many weekly PDC meetings that I attend) - they are HOT! Not only are the drives themselves sweet - PDC-branded, black, sleek - we hope that a single, USB drive for your bits will be more convenient than a handful of DVD's. Plus, you get to re-use it:) Get a peek at it in this Channel 9 video.
So, how do you get one of these? Register and attend the PDC - you've still got time!!
-
Just a quick cross-reference: If you register before Aug 15 for the PDC you'll receive $200 off. Register here.
-
Visual Studio and .NET Developers, along with their customers, got a nice treat today with the release of VS 2008 SP1 and .NET 3.5 SP1! You can get the laundry list of features and download it here but there's some work that I'm particularly excited about.
.NET 3.5 SP1 includes some excellent improvements in cold startup for WPF applications. These aren't just 3-5% improvements; these are 20, 30 and even 40%+ improvements! The best part is that applications don't need to do anything to get the benefit in most cases! Imagine, one day your application just got significantly faster to start!
The second improvement I'm very excited about is the .NET 3.5 SP1 Client Profile. Basically, this is a subset of .NET 3.5 SP1 targeted at those building client applications. It weighs in at around 26.5 MB, a nearly 86% reduction from the 197 MB of the entire Framework. Additionally, it allows for a customized install experience of the Framework! The sum is dramatically improved install experiences for Windows applications built using .NET!
-
I've participated in several PDC's in the past, mostly as a speaker, but this year I'm helping to do some of the organization. Recently, I've been in a lot of meetings with Mike Swanson, a Technical Evangelist here at Microsoft. Mike is one of the key ring leaders in producing the PDC content. If you were ever interested in how the PDC gets pulled off and some of the thinking that goes into it, check out this video featuring Mike and colleague Jennifer Ritzinger.
-
Save the date!
http://msdn.microsoft.com/pdc.
-
Yahoo just released their Yahoo! Messenger for Vista. I haven't yet installed it but I do know that's its based on WPF. Check out some of the blog postings about it, below.
http://eric.burke.name/dotnetmania/2007/12/06/0.05.32
http://blogs.msdn.com/tims/archive/2007/12/06/great-wpf-applications-16-yahoo-messenger-for-windows-vista.aspx
http://blogs.zdnet.com/Stewart/?p=661
http://www.ymessengerblog.com/blog/2007/12/05/yahoo-messenger-for-vista-preview-release-available/
-
Get it here! The WPF team is very excited about this release because we've been able to follow-up on a handful of issues we heard from you so soon after the release of our V1 in NET FX 3.0. Below, you'd find a quick summary of some of the work that you'll see in NET FX 3.5 B2 related to WPF in addition to general bug fixing; it's not all inclusive but it represents a pretty good chunk.
- UIElement3D, a 3D element which supports UIElement-type of platform behavior including layout, databinding, and input.
- Indic Script support in 14 different languages!
- IDataErrorInfo support
- Smoother Animations
- Handful of performance fixes across the platform
- More granular debugging spew control in databindings
- Firefox Plug-in for XBAP's/ClickOnce apps
- File extension support for ClickOnce applications.
- RichTextBox extensibility allows greater control of non-text content for allowing interactive, embedded elements like hyperlinks.
- Several IME fixes
- TextSelection exposed on
DocumentViewer FlowDocumentReader, FlowDocumentScollViewer & SinglePageViewer*.
- WPF Support for the CLR AddIn model
- And more!
*Correction on 10/23/07
-
Rob Eisenberg recently posted that he was experiencing performance issues related to recent Windows auto updates that he received. The issue was caused by a .NET Framework security update on 7/10.
From the information I have it appears that a significant number of assemblies are being ngen'd after reboot. The NGEN'ing itself can use a significant number of CPU cycles but if you happen to be running .NET applications before the NGEN'ing completes you'll likely see the results of JIT'ing as well. The overall experience can be very poor performance. Once NGEN'ing is complete, though, the problem shouldn't continue. The right people are looking into the issue now; if/when I've got new info I'll post.
-
In the WPF ListBox and ListView, some form of virtualization takes place. The consequence is that loading (either app or the control itself) is faster since less work is done at the get go; additionally, it can help keep working set down. We didn't do this for ComboBox (I don't have all the background; we're discussing that right now.) While we try to figure out if this is something we can fix for the Orcas release, there's a relatively easy fix - you can switch to using the VirtualizingStackPanel yourself. You need to set the ItemsPanel property; see the following:
<ComboBox>
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
…
</ComboBox>
-
The WPF performance tool WPFPerf is now available as a stand-alone download. Check it out: x86 and x64!
-
Kiran has posted the latest and greatest version of his WPF Performance Whitepaper here. Check it out!
-
Tim Cahill, a developer on the WPF Performance Team, posted a great article on optimizing 3D collections in WPF. Check it out!
-
Check it out: http://www.microsoft.com/downloads/details.aspx?FamilyId=19E21845-F5E3-4387-95FF-66788825C1AF&displaylang=en
-
In this post, I’m going to talk about two key API’s for performance in WPF. These are RenderCapability.Tier and Storyboard.DesiredFrameRate. In this post, I’m going to show:
- How to leverage RenderCapability.Tier to scale your app up or down.
- How to use RenderCapability.Tier in markup.
- How to apply DesiredFrameRate to reduce CPU consumption.
RenderCapability.Tier
For the machine on which it’s run, RenderCapability.Tier signals the machine’s hardware capabilities. Tier=0 means software rendering; Tier=2 is hardware rendering (for those features that can be rendered in hardware); Tier=1 is a middle ground (some things in hardware and some in software.) You can probably see how this might be useful to scale up or down the richness of an application depending on the hardware.
(Note: RenderCapability.Tier is an integer value using the high word to indicate the tier. You’ll need to shift by 16 bits to get the corresponding tier values. Adam Smith posts about why this was chosen.)
Storyboard.DesiredFrameRate
The second API I mentioned was Storyboard.DesiredFrameRate (DFR.) DFR allows you to specify, manually, what the frame rate “should” be (the animation system attempts to get as close as possible to the DFR value but there are no guarantees.) By default, WPF attempts 60 fps. The up side to this is that animations look better; the down side is that you may not need 60 fps but you may be spending the extra CPU cycles.
Putting Them Together
You can use RenderCapability.Tier in markup with a small helper class. The trick is to wrap up the property in a DependencyProperty. From there, the property can be used to set DFR. Below, you’ll find both the code for the RenderCapability.Tier, how to use it in markup and how to set DesiredFrameRate. I picked different DFR values for the different Tiers. The resulting UI isn't that exciting (a spinning Button) but it demonstrates the concept.
using System;
using System.Windows;
using System.Windows.Media;
namespace PerformanceUtilities
{
public static class RenderCapabilityWrapper
{
public static readonly DependencyProperty TierProperty =
DependencyProperty.RegisterAttached(
"Tier",
typeof(int),
typeof(PerformanceUtilities.RenderCapabilityWrapper),
new PropertyMetadata(RenderCapability.Tier >> 16));
public static int GetTier(DependencyObject depObj)
{
return (int)TierProperty.DefaultMetadata.DefaultValue;
}
}
}
<Border
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Perf="clr-namespace:PerformanceUtilities;assembly=PerfTier"
Background="silver"
>
<Border.Resources>
<Style x:Key="{x:Type Button}" TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger
Property="Perf:RenderCapabilityWrapper.Tier" Value="2">
<Setter Property="Tag" Value="60"/>
</Trigger>
<Trigger
Property="Perf:RenderCapabilityWrapper.Tier" Value="1">
<Setter Property="Tag" Value="30"/>
</Trigger>
<Trigger
Property="Perf:RenderCapabilityWrapper.Tier" Value="0">
<Setter Property="Tag" Value="15"/>
</Trigger>
</Style.Triggers>
</Style>
</Border.Resources>
<Button Width="80" Height="80" Name="MyButton"
Content="{Binding RelativeSource={RelativeSource Self}, Path=Tag}">
<Button.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever"
Storyboard.DesiredFrameRate="{Binding ElementName=MyButton,
Path=Tag}">
<DoubleAnimation
Storyboard.TargetName="MyAnimatedTransform"
Storyboard.TargetProperty="(RotateTransform.Angle)"
From="0.0" To="360" Duration="0:0:10" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
<Button.RenderTransform>
<RotateTransform CenterX="40" CenterY="40"
x:Name="MyAnimatedTransform"/>
</Button.RenderTransform>
</Button>
</Border>