The Power of the One Line Demo
Sometimes the simplest demos can be the best.
Catherine Heller is our team expert on the myriad of new Windows Vista unmanaged APIs, but she also knows how to get people excited about WPF with less than 100 bytes of code. This is what she typed into a blank file:
<InkCanvas Background="Yellow" xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" />
Click here to see the results if you've got a Beta 2 or more recent build of WPF. This shows off loose XAML running locally in the browser, along with demonstrating how easy it is to add ink support to your WPF application.
Another one line demo I like to do is this (alright, I confess, I've wrapped it onto multiple lines to make it easier to show on this blog):
<RichTextBox FontFamily="Palatino Linotype" FontSize="72"
SpellCheck.IsEnabled="True" Typography.NumeralStyle="OldStyle"
Typography.HistoricalLigatures="True" Typography.DiscretionaryLigatures="True"
xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" />
Click here to see the results, and try typing a sentence like this: "The affliction started in 1776 and spread. Quickly!" You'll notice cool effects like the swash on the Qu, ct, st and sp pairs, as well as the book-style numerals. If you're particularly eagle-eyed, you might catch the subtle Th ligature that prevents the rightmost descender from the T clashing with the serif of the h, as well as the ffl ligature. If you misspell a word, you'll see the red wiggly line underneath it - evidence that you get spell checking for "free" with WPF.
What's the most impressive WPF demo you can construct in a single line of XAML? Can you improve on these?
Comments
Anonymous
August 17, 2006
The comment has been removedAnonymous
August 17, 2006
The comment has been removedAnonymous
August 17, 2006
Charles Petzold seems to have taken this as a personal challenge - check out http://www.charlespetzold.com/blog/2006/08/170855.htmlAnonymous
August 18, 2006
It seems Charles Petzold took up the challenge and put some one-liners on his blog: http://www.charlespetzold.com/blog/blog.xmlAnonymous
August 18, 2006
I like this one:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Clip="M 100,100 L 100,300 120,300 130,150 140,200 160,200 170,150 170,300 300,300 300,180 240,180 240,120 300,120 300,100 220,100 220,200 280,200 280,280 190,280 190,100 170,100 150,150 120,100"
Opacity="0.5" AllowsTransparency="true" WindowStyle="None" Background="Blue"
/>
The following one can match your functionality:
<Frame xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Width="1000" Height="1000" Source="http://www.live.com"/>
and this one can annoy users:
<Popup IsOpen="true" StaysOpen="true" Placement="Absolute" HorizontalOffset="0" VerticalOffset="0" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Width="2000" Height="2000"/>Anonymous
August 18, 2006
The comment has been removedAnonymous
August 18, 2006
Wow, up to nine entrants already, counting the three from digitalnetbizz and six from Charles Petzold. Some more malicious than others!
Frank, yes, I think that's a fair interpretation.Anonymous
August 19, 2006
So why do I always get security exceptions any time that I try to run anyone's demos except for Petzold's? Does he know something that the actual Microsofties don't? Or is it that he is just using an older version of WPF.
I'm not looking for you to debug my issue but I'm getting a little worried about the fact that I can't view 99% of the WPF stuff out there. Are "normal" users going to experience this or is this just a Beta thing? If it is the former then all these demos don't mean squat.
I'm on Vista Beta2 and get the following error:
Startup URI: http://www.sneath.org/tim/rtb.xaml
Application Identity: file:///C:/Windows/WinFX/v3.0/WPF/XamlViewer/XamlViewer_v0300.xbap#XamlViewer_v0300.application, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ed9f9a6c9f3a9db8, processorArchitecture=msil/XamlViewer_v0300.exe, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ed9f9a6c9f3a9db8, processorArchitecture=msil, type=win32
System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at MS.Internal.PresentationFramework.SecurityHelper.DemandUnmanagedCode()
at MS.Internal.AppModel.AppSecurityManager.SafeLaunchBrowserDemandWhenUnsafe(Uri originatingUri, Uri destinationUri, Boolean fIsTopLevel)
at System.Windows.Navigation.NavigationService.GetObjectFromResponse(WebRequest request, WebResponse response, Uri destinationUri, Object navState)
at System.Windows.Navigation.NavigationService.HandleWebResponse(IAsyncResult ar)Anonymous
August 19, 2006
Hi Matt, you ought to be able to see this, certainly. You're right that if this experience were typical of the RTM version then it wouldn't be good, but I'm pretty confident there's just something spurious about your machine or this build. (I tested these demos on a near-RC1 drop, but they ought to work unchanged on Beta 2.) Let me loop in one of my colleagues and see if we can figure out what's going wrong here.Anonymous
August 20, 2006
The comment has been removedAnonymous
August 21, 2006
The comment has been removedAnonymous
August 22, 2006
Just wanted to update this thread to say that we're still investigating what's causing Matt and Judah's problem, but all indications are that it's a bug that's only present in Beta 2 under certain conditions. Clearly this is a sub-optimal experience and one that we wouldn't ship in a released product. As you say, Matt, running this in full trust will work fine.
Sorry for the inconvenience - on the positive side, RC1 is just around the corner!Anonymous
August 22, 2006
I really missing about <style>somelement{behavior:url() url()}</style> dynamic behaviors,it Makes any element anything you want without any overhead.Yes,I miss AOP style programming in WPF-dependency properties is not enough,it's only beginning.I believe AOP is cornerstone of successful declarative model.Anonymous
August 23, 2006
Thanks Tim!
I've pre-ordered Charles Petzold's new WPF book and will be waiting for RC1 before really getting rolling with WPF anyway. So no big deal.
Keep up the great work.
MattAnonymous
August 23, 2006
Yeah, same here, saving the file to disk and opening it up in IE6 works.Anonymous
August 23, 2006
Please,look at first comment from Charlie Hubbard http://ajaxian.com/archives/qooxdoox-releases-version-06-rc1 ,entirely agree with him.Anonymous
May 08, 2007
PingBack from http://www.kintespace.com/rasxlog/?p=626Anonymous
May 28, 2007
PingBack from http://www.technewsrssfeed.com/2007/05/29/rails-app-1-the-typer/Anonymous
June 11, 2007
When Windows 2000 launched, there was a new typeface included called Palatino Linotype. What was specialAnonymous
June 11, 2007
PingBack from http://msdnrss.thecoderblogs.com/2007/06/11/a-blast-from-type-past/Anonymous
October 13, 2007
PingBack from http://www.technewsrssfeed.com/2007/10/14/episode-20-steelpixel/Anonymous
January 28, 2009
A lot, it turns out. Some long-time readers may remember my post of a year or two back where I set a