ASP.NET Beratung & Entwicklung   ·   helpyoo.de - The friendly computer people

xs.Serialize(brainstream,deedee)

# Wednesday, December 13, 2006

« Windows und MacOSX Anwendungen... | Home | WPF/E der Flashkiller? »

WPF/E HelloWorld

WPF/E ist ein Control das per Object/Embed ähnlich dem Flashplugin in HTML-Seiten eingebunden werden kann um WPF Inhalte im Browser darzustellen. WPF/E basiert auf der neuen Windows Presentation Foundation Technologie von Microsoft.NET 3.0  und XAML (eXtensible Application Markup Language).
Derzeit ist das Plugin für Windows und MacOSX als CTP verfügbar [1] [2] und läuft unter Internet Explorer 6.0/7.0 und Mozilla Firefox 1.5.0.8/2.0 unter Windows sowie Safari und Firefox 1.5.0.8 unter MacOSX 10.4.8.

Zum Erstellen von WPF/E Projekten gibt es ein Template für Visual Studio, das allerdings mehr verwirrt als Erleichterung zu bringen. Deshalb hier zur Einführung in die grundlegende Erstellung eines WPF/Projekts anhand des obligatorischen Hello World Beispiels.

HelloWorld.xaml
Der Inhalt der XAML-Datei ist die Basis der WPF/E Anwendung. Hier werden das grundlegende Interface sowie Animationen definiert. Zur Erstellung kann man Expression Blend, Expression Designer, Visual Studio oder ganz simpel Notepad verwenden. Mit Visual Studio hat man Intellisense was durch Code Vervollständigung die Sache erleichtert, da XAML aber XML basiert ist kann man auch jeden beliebigen XML-Editor verwenden.
Unser HelloWorld Beipiel benötigt ein sogenanntes Canvas als Root-Element mit zwei Namespace Definitionen und enthält einen simples TextBlock Element:

   1:  <Canvas xmlns="http://schemas.microsoft.com/client/2007"
   2:      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
   3:    <TextBlock> Hello world! (WPF/E)</TextBlock>
   4:  </Canvas> 

HelloWorld.html
Genau wie bei Flash wird eine WPF/E Applikation per OBJECT/EMBED tag in die HTML-Seite eingebunden. Um die Sache zu erleichtern stellt Microsoft ein Javascript Names aghost.js zur Verfügung das den korrekten Code erstellt. (Download aghost.js). Hier die HTML-Seite um unsere HelloWorld Anwendung einzubinden:

   1:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
   2:  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   3:  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
   4:   
   5:  <head>
   6:      <title>Hello World</title>
   7:   
   8:     <!--  Import the ObjectEmbed JavaScript file -->
   9:    <script type="text/javascript" src="aghost.js"></script>
  10:  </head>  
  11:  <body>
  12:   
  13:   <!-- Where the WPF/E ActiveX control will go --> 
  14:  <div id="agControl1Host">
  15:  </div>
  16:   
  17:   
  18:      <script type="text/javascript">
  19:      // Create the WPF/E ActiveX control.
  20:          // Doing it this way avoids the user having to click on the
  21:          // ActiveX control before WPF/E will receive input.
  22:         new agHost("agControl1Host",              
  23:                                   // hostElementID (HTML element to put WPF/E 
  24:                     // ActiveX control inside of -- usually a <div>)
  25:                         "agControl1",            
  26:                                  // ID of the WPF/E ActiveX control we create
  27:                         "420px",                
  28:                                // Width
  29:                         "20px",                 
  30:                               // Height
  31:                         "#CCCCCC",               
  32:                              // Background color
  33:                         null,                    
  34:                           // SourceElement (name of script tag containing xaml)
  35:                         "HelloWorld.xaml",       
  36:                           // Source file
  37:                         "false",                 
  38:                           // IsWindowless
  39:                         "24",                   
  40:                             // MaxFrameRate
  41:                         null);            
  42:                           // OnError handler (method name -- no quotes)
  43:                         
  44:  // for convenience, create a global variable for the WPF/E ActiveX control,
  45:  // which we can use to find Name'd xaml elements
  46:          var agControl = document.getElementById("agControl1");                               
  47:      </script>
  48:      
  49:  </body>
  50:  </html>

Das ist im Prinzip alles was benötigt wird. Um weitere Funktionalität hinzuzufügen können natürlich Javscript-Funktionen eingebunden werden um mit den Elementen in der XAML-Datei zu kommunizieren. Für grundlegene Tests mit WPF/E reicht aber im Prinzip das installierte Plugin sowie Notepad und ein Browser. Das Ergbnis kann man hier sehen (falls das Plugin installiert ist.):


[1] WPF/E Plugin Windows
[2] WPF/E Plugin MacOSX
Geschrieben am , Comments [0]
Categories: .net 3.0 |  WPF/E
Technorati Tags:  |  | 518 words in this post.
| Artikel bookmarken: Beitrag zu Mr.Wong hinzufügen   Beitrag zu YiGG.de hinzufügen   Beitrag zu Digg.com hinzufügen   Beitrag zu del.icio.us hinzufügen   Beitrag zu Google Bookmarks hinzufügen   Beitrag zu Linkarena hinzufügen   Beitrag zu WindowsLiveFavorites hinzufügen   Beitrag zu WindowsLiveFavorites hinzufügen  



OpenID
Please login with either your OpenID above, or your details below.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview

Aktuelle Empfehlungen


Suche

RSS Feed

FeedBurner Feed Count Subscribers

Tag cloud

About (1) .net (134) .net 3.0 (10) ADO (2) ASP 2.0 (81) Community (26) Compact Framework (7) CSharp (17) Enhancements (36) Framework (28) patterns & practices (13) Silverlight (8) SQL (19) Visual Studio (62) WebServices (6) WPF (7) WPF/E (9) XNA (6) About (5) AJAX (11) Apple (25) Blogging (50) RSS (17) Themes (7) dasBlog (74) dasBlog (1) Design (14) Gadgets (2) Gaming (36) Geschenkideen (13) GIS (24) Google (14) Javascript (2) Medien (16) Microsoft (147) Mobile (52) Movies (9) Music (28) Netzwelt (136) Office (12) Offtopic (48) Fun (69) OS (9) Linux (29) MacOSX (71) Windows (205) Vista (72) Other Interests (16) Brain&Consciousness (2) Brainfood (16) Food (4) Fussball WM 2006 (20) HitchHikers Guide (14) Programming (9) Security (57) Antispam (2) Antispam  (3) Sony (1) tagged (1) Technology (125) 3D (1) Browser (72) CSS (10) Flash (11) iPhone (8) iPod (28) Kommunikation (6) Media (56) PocketPC (19) PS3 (3) PSP (25) Standards (11) Video (1) Web 2.0 (30) Webserver (4) XML (8) SearchEngines (59) Tools (169) VJ (4) Werbung (3) Windows Live (31) Windows Live Writer (16) XBOX (81) Zeitgeist (4) Zune (5)

Aktuelle Artikel

Blog Archiv

Über mich

vj deedee
 vjdeedee
XING

    Links

    Einkaufen

    Brainstream Shop

    Buttons

    Blogverzeichnis - Blog Verzeichnis bloggerei.de

    PageRank Verifizierung deedee.brainstream.net
    Suchmaschinenoptimierung mit Ranking-Hits
    prontoo.de - Pagerank Anzeige ohne Toolbar

    Blog Statistik

    Total Posts: 1045
    This Year: 1
    This Month: 1
    This Week: 1
    Comments: 277

    Letzter Update: Tuesday, January 06, 2009 7:59:49 PM (Mitteleuropäische Zeit, UTC+01:00)
    Erstellt mit: newtelligence dasBlog 2.2.8279.16125

    Login

    InfosClient