WPF- WPF/E Hello World
From 2001-2005 I worked on the Avalon team (now called WPF) creating the next generation user-interface and graphics
platform. One of the more disappointing things about leaving in 2005 is that the things I’d been working
on where not ready for prime time yet, and it would be years before it would make sense to really dive in
again for real-world projects. The other issue is just that the size of the platform (huge download) and
big app model changes (Avalon/WPF is mostly code-first so existing web-sites would need to be really rethought
to adopt it.
Yesterday Microsoft put the community preview of WPF/E (E is for Everywhere). They took the core graphics
concepts of Avalon, the XAML language and packaged it in a 1MB download, with an object model designed to work
inside web pages and be programmed from Javascript. Even better it works in Firefox and on the Mac. This is a huge
breakthrough- a 1MB download really isn’t that big of a deal and the broad platform support (hopefully Linux?)
and consistent programming model makes it way easier to buy in to the technology.
Without further delay, here is my first “Hello World” thing in WPF/E. Just a little rotating text on a
gradient, but doing this with existing browser platforms would have been a big pain.
Note- this probably won’t work in most blog readers, if you want to check it out, visit my site. If
WPF/E is not already installed it should take you to the download site. Downloads are available for Windows
and the Mac.
var TheWPF= new agHost(”wpfeControl1Host”, // hostElementID (HTML element to put WPF/E
// ActiveX control inside of — usually a
“wpfobj”, // ID of the WPF/E ActiveX control we create
“300″, // Width
“300″, // Height
“#ffB42600″, // Background color
null, // SourceElement (name of script tag containing xaml)
“helloworld.xaml”, // Source file
“false”, // IsWindowless
“24″, // MaxFrameRate
null); // OnError handler (method name — no quotes)
var CurAngle = 0;
function DoTick()
{
wpf = document.getElementById(”wpfobj”);
var rotate = wpf.findName(”RotateID”);
// Determine whether the object was found.
if (rotate != null) {
rotate.Angle = (++CurAngle);
}
window.setTimeout(”DoTick()”, 50);
}
function onHelloWorldLoaded(sender, eventArgs)
{
window.setTimeout(”DoTick()”, 50);
}
Here is the XAML used in this sample:
Hello, world
And here is the Javascript:
// aghost.js is a library from Microsoft for constructing a WPF/E object on all browsersvar TheWPF= new agHost(”wpfeControl1Host”, // hostElementID (HTML element to put WPF/E // ActiveX control inside of — usually a) “wpfobj”, // ID of the WPF/E ActiveX control we create “300″, // Width “300″, // Height “#ffB42600″, // Background color null, // SourceElement (name of script tag containing xaml) “helloworld.xaml”, // Source file “false”, // IsWindowless “24″, // MaxFrameRate null); // OnError handler (method name — no quotes) var CurAngle = 0; function DoTick() { wpf = document.getElementById(”wpfobj”); var rotate = wpf.findName(”RotateID”); // Determine whether the object was found. if (rotate != null) { rotate.Angle = (++CurAngle); } window.setTimeout(”DoTick()”, 50); } function onHelloWorldLoaded(sender, eventArgs) { window.setTimeout(”DoTick()”, 50); }]]>
posted in WPF | 0 Comments
Advertising
Calendar
December 2006 S M T W T F S « Nov Jan » 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Archives
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006
- December 2005
- November 2005
Categories
- Aviation (17)
- Books (2)
- Business (54)
- Canon TX1 (4)
- Casio (2)
- Cooking (7)
- Developers (23)
- Facebook (8)
- Food (8)
- Games (5)
- General (2)
- Graphics (9)
- Hardware (55)
- Hiking (7)
- Home (2)
- iPhone (1)
- Jobs (5)
- Launch21 (1)
- Mac (10)
- Management (2)
- Marketing (1)
- Microsoft (8)
- Misc (4)
- Music (32)
- Network Magic (2)
- Networking (5)
- Outdoors (2)
- Photography (9)
- Politics (6)
- PR (4)
- Presentations (2)
- Pure Networks (2)
- Rafting (1)
- Silverlight (1)
- Skiing (7)
- Software (19)
- Space (1)
- Sports (3)
- Standards (2)
- Storage (6)
- Technology (241)
- Travel (8)
- TV (6)
- Virtualization (1)
- Vista (17)
- Wine (1)
- WPF (5)