2
Введение в Microsoft
ВТОРОЕ ИЗДАНИЕ
®
Silverlight 2 ™
Лоуренс Морони
ǑDZǴdzǴǼǷǴ DZ Microsoft Silverlight 2
ǑȁǽǿǽǴ ǷǶdzǯǼǷǴ
ǚǽȂǿǴǼȀ ǛǽǿǽǼǷ
Microsoft Silverlight Microsoft Silverlight -
Silverlight 2 Silverlight
Microsoft Silverlight
Silverlight
[email protected]. Microsoft Silverlight
ɈɉɍȻɅɂɄɈȼȺɇɈ Microsoft Press A Division of Microsoft Corporation One Microsoft Way Redmond, Washington 98052 6399 &RS\ULJKW E\ /DXUHQFH 0RURQH\ ȼɫɟ ɩɪɚɜɚ ɡɚɳɢɳɟɧɵ ɇɢ ɨɞɧɚ ɱɚɫɬɶ ɞɚɧɧɨɣ ɤɧɢɝɢ ɧɟ ɦɨɠɟɬ ɛɵɬɶ ɜɨɫɩɪɨɢɡɜɟɞɟɧɚ ɜ ɥɸɛɨɣ ɮɨɪɦɟ ɢɥɢ ɥɸɛɵɦɢ ɫɪɟɞɫɬɜɚɦɢ ɛɟɡ ɩɢɫɶɦɟɧɧɨɝɨ ɪɚɡɪɟɲɟɧɢɹ ɢɡɞɚɬɟɥɹ. Ʉɨɧɬɪɨɥɶɧɵɣ ɧɨɦɟɪ Ȼɢɛɥɢɨɬɟɤɢ Ʉɨɧɝɪɟɫɫɚ: 2008920565 Ʉɚɬɚɥɨɝɢɡɚɰɢɨɧɧɚɹ ɡɚɩɢɫɶ CIP ɷɬɨɣ ɤɧɢɝɢ ɩɪɟɞɨɫɬɚɜɥɟɧɚ Ȼɪɢɬɚɧɫɤɨɣ ɛɢɛɥɢɨɬɟɤɨɣ. Ʉɧɢɝɢ Microsoft Press ɪɚɫɩɪɨɫɬɪɚɧɹɸɬɫɹ ɩɨ ɜɫɟɦɭ ɦɢɪɨɦ ɨɩɬɨɦ ɢ ɜ ɪɨɡɧɢɰɭ Ⱦɥɹ ɩɨɥɭɱɟɧɢɹ ɞɨɩɨɥɧɢɬɟɥɶɧɨɣ ɢɧɮɨɪɦɚɰɢɢ ɨ ɦɟɠɞɭɧɚɪɨɞɧɵɯ ɢɡɞɚɧɢɹɯ ɨɛɪɚɳɚɣɬɟɫɶ ɜ ɪɟɝɢɨɧɚɥɶɧɵɣ ɨɮɢɫ Ʉɨɪɩɨɪɚɰɢɢ Microsoft ɢɥɢ ɧɚɩɪɹɦɭɸ ɜ Microsoft Press International ɩɨ ɮɚɤɫɭ (425) 936 7329. ɉɨɫɟɬɢɬɟ ɧɚɲ ȼɟɛ ɫɚɣɬ ɩɨ ɚɞɪɟɫɭ www.microsoft.com/mspress. ɉɪɢɫɵɥɚɣɬɟ ɤɨɦɦɟɧɬɚɪɢɢ ɧɚ ɚɞɪɟɫ ɷɥɟɤɬɪɨɧɧɨɣ ɩɨɱɬɵ
[email protected]. Microsoft, Microsoft Press, Access, DirectShow, Expression, Expression Blend, InfoPath, IntelliSense, Internet Explorer, MSDN, Outlook, Silverlight, SQL Server, Visio, Visual Basic, Visual C#, Visual Studio, Win32, Windows, Windows Media, Windows NT, Windows Server ɢ Windows Vista ɹɜɥɹɸɬɫɹ ɢɥɢ ɡɚɪɟɝɢɫɬɪɢɪɨɜɚɧɧɵɦɢ ɬɨɪɝɨɜɵɦɢ ɦɚɪɤɚɦɢ ɢɥɢ ɬɨɪɝɨɜɵɦɢ ɦɚɪɤɚɦɢ ɝɪɭɩɩ ɤɨɦɩɚɧɢɣ Microsoft. Ⱦɪɭɝɢɟ ɭɩɨɦɢɧɚɟɦɵɟ ɡɞɟɫɶ ɧɚɢɦɟɧɨɜɚɧɢɹ ɩɪɨɞɭɤɬɨɜ ɢɥɢ ɧɚɡɜɚɧɢɹ ɤɨɦɩɚɧɢɣ ɦɨɝɭɬ ɛɵɬɶ ɬɨɪɝɨɜɵɦɢ ɦɚɪɤɚɦɢ ɫɨɨɬɜɟɬɫɬɜɭɸɳɢɯ ɜɥɚɞɟɥɶɰɟɜ. ȼɫɟ ɭɩɨɦɢɧɚɟɦɵɟ ɜ ɤɧɢɝɟ ɧɚɡɜɚɧɢɹ ɤɨɦɩɚɧɢɣ ɨɪɝɚɧɢɡɚɰɢɣ ɩɪɨɞɭɤɬɨɜ ɞɨɦɟɧɧɵɟ ɢɦɟɧɚ ɚɞɪɟɫɚ ɷɥɟɤɬɪɨɧɧɨɣ ɩɨɱɬɵ ɥɨɝɨɬɢɩɵ ɥɸɞɢ ɦɟɫɬɚ ɢ ɫɨɛɵɬɢɹ ɹɜɥɹɸɬɫɹ ɜɵɦɵɲɥɟɧɧɵɦɢ ɇɢɤɚɤɨɣ ɫɜɹɡɢ ɫ ɪɟɚɥɶɧɵɦɢ ɤɨɦɩɚɧɢɹɦɢ ɨɪɝɚɧɢɡɚɰɢɹɦɢ ɩɪɨɞɭɤɬɚɦɢ ɞɨɦɟɧɧɵɦɢ ɢɦɟɧɚɦɢ ɚɞɪɟɫɚɦɢ ɷɥɟɤɬɪɨɧɧɨɣ ɩɨɱɬɵ ɥɨɝɨɬɢɩɚɦɢ ɥɸɞɶɦɢ ɦɟɫɬɚɦɢ ɢɥɢ ɫɨɛɵɬɢɹɦɢ ɨɧɢ ɧɟ ɩɨɞɪɚɡɭɦɟɜɚɸɬ ɢ ɧɟ ɢɦɟɸɬ Ⱦɚɧɧɚɹ ɤɧɢɝɚ ɩɪɟɞɫɬɚɜɥɹɟɬ ɜɢɞɟɧɢɟ ɢ ɦɧɟɧɢɟ ɚɜɬɨɪɚ ɂɧɮɨɪɦɚɰɢɹ ɫɨɞɟɪɠɚɳɚɹɫɹ ɜ ɧɟɣ ɩɪɟɞɨɫɬɚɜɥɹɟɬɫɹ ɛɟɡ ɜɫɹɤɢɯ ɜɵɪɚɠɟɧɧɵɯ ɭɫɬɚɧɨɜɥɟɧɧɵɯ ɢɥɢ ɩɪɟɞɩɨɥɚɝɚɟɦɵɯ ɝɚɪɚɧɬɢɣ ɇɢ ɚɜɬɨɪɵ Microsoft Corporation ɧɢ ɪɚɫɩɪɨɫɬɪɚɧɢɬɟɥɢ ɢɥɢ ɩɪɨɞɚɜɰɵ ɧɟ ɧɟɫɭɬ ɧɢɤɚɤɨɣ ɨɬɜɟɬɫɬɜɟɧɧɨɫɬɢ ɡɚ ɥɸɛɨɣ ɭɳɟɪɛ ɤɨɬɨɪɵɣ ɦɨɠɟɬ ɛɵɬɶ ɩɪɢɱɢɧɟɧ ɩɪɹɦɨ ɢɥɢ ɤɨɫɜɟɧɧɨ ɞɚɧɧɨɣ ɤɧɢɝɨɣ Body Part No. X14 55515
ǜǴǺǴDzǹǽ ǰȊȁȋ ǵǴǼǽǸ ǷǺǷ dzǴȁȋǻǷ ǾǷȀǯȁǴǺȎ Ǯ ǾǽȀDZȎȈǯȍ ȌȁȂ ǹǼǷDzȂ ȀDZǽǴǸ ǵǴǼǴ ǟǴǰǴǹǹǴ Ƿ ǻǽǷǻ dzǴȁȎǻ ǙǺǽ dzǷǷ Ƿ ǙǿǷȀȁǽȃǴǿȂ ǞǿǽȇȂ ǾǿǽȈǴǼǷȎ Ƕǯ DZȀǴ ȁǴ ǰǴȀȆǷȀǺǴǼǼȊǴ ©ǴȈǴ ǻǷǼȂȁǽȆǹȂ Ǿǽǹǯ Ȏ ǶǯǹǽǼȆȂ ȌȁȂ ȆǯȀȁȋª Ƿ ǰǴȀǹǽǼǴȆǼȊǴ ǽǵǷdzǯǼǷȎ ǻǴǼȎ ǹ ȀȁǽǺȂ ǷǺǷ ǾǽǷDzǿǯȁȋ ǠǾǯȀǷǰǽ DZǯǻ ǿǴǰȎȁǯ DZȊ ǺȂȆȇǷǴ ǡǯǹǵǴ ȄǽȆȂ ǾǽǰǺǯDzǽdzǯǿǷȁȋ ȁǽDzǽ ǹȁǽ ȀdzǴǺǯǺ DZȀǴ Ȍȁǽ DZǽǶǻǽǵǼȊǻ ² ǐǽDzǯ ǏDZǿǯǯǻǯ ǗȀǯǯǹǯ ǮǹǽDZǯ Ƿ ǗǷȀȂ Ȁǯ Ƕǯ ȁǽ Ȇȁǽ dzǯǿǽDZǯǺ Ǽǯǻ ǵǷǶǼȋ ǺȍǰǽDZȋ ȀȆǯȀȁȋǴ Ƿ ǼǯdzǴǵdzȂ
ǠǽdzǴǿǵǯǼǷǴ ǞǽȆǴǻȂ Silverlight? .................................................................................................................................................................................................... xii ǓǺȎ ǹǽDzǽ Ȍȁǯ ǹǼǷDzǯ.................................................................................................................................................................................................... xiii ǝ ȆǴǻ Ȍȁǯ ǹǼǷDzǯ ......................................................................................................................................................................................................... xiv ǠǷȀȁǴǻǼȊǴ ȁǿǴǰǽDZǯǼǷȎ ......................................................................................................................................................................................... xiv ǑǴǰ-ȀǯǸȁ ǹǽǻǾǯǼǷǷ .................................................................................................................................................................................................. xiv ǞǽdzdzǴǿǵǹǯ ǹǼǷDzǷ ..................................................................................................................................................................................................... xiv ǑǽǾǿǽȀȊ Ƿ ǹǽǻǻǴǼȁǯǿǷǷ ....................................................................................................................................................................................... xv ǝǰ ǯDZȁǽǿǴ ...................................................................................................................................................................................................................... xv Silverlight Ƿ DZǶǯǷǻǽdzǴǸȀȁDZǷǴ Ȁ ǾǽǺȋǶǽDZǯȁǴǺǴǻ ........................................................................................................................................... 16 ǏǿȄǷȁǴǹȁȂǿǯ Silverlight ............................................................................................................................................................................................ 18 Silverlight Ƿ XAML....................................................................................................................................................................................................... 20 Silverlight Ƿ ǾǯǹǴȁ ǷǼȀȁǿȂǻǴǼȁǽDZ Expression Studio ................................................................................................................................... 22 Silverlight Ƿ Expression Design.......................................................................................................................................................................... 23 Silverlight Ƿ Expression Blend ............................................................................................................................................................................ 25 ǞǿǽǴǹȁ Silverlight 1 .......................................................................................................................................................................................... 25 ǑǴǰ-ȀȁǿǯǼǷȅǯ Ǿǽ ȂǻǽǺȆǯǼǷȍ ..................................................................................................................................................................... 26 Silverlight Ƿ Expression Encoder............................................................................................................................................................................ 28 ǖǯǹǺȍȆǴǼǷǴ .................................................................................................................................................................................................................. 31 ǜǯȆǯǺǽ ǿǯǰǽȁȊ Ȁ ([SUHVsion Blend..................................................................................................................................................................... 32 ǠǽǶdzǯǼǷǴ ǾǿǷǺǽǵǴǼǷȎ Silverlight 2 .............................................................................................................................................................. 33 ǠȁǿǯǼǷȅǯ Ǿǽ ȂǻǽǺȆǯǼǷȍ............................................................................................................................................................................ 34 ǣǯǸǺ App.xaml Ƿ ȃǯǸǺȊ Ȁ DZȊdzǴǺǴǼǼȊǻ ǹǽdzǽǻ Ǿǽ ȂǻǽǺȆǯǼǷȍ ................................................................................................. 35 ǑȊǾǽǺǼǴǼǷǴ ǾǿǷǺǽǵǴǼǷȎ ............................................................................................................................................................................ 36 ǗǼȁǴDzǿǷǿǽDZǯǼǼǯȎ ȀǿǴdzǯ ǿǯǶǿǯǰǽȁǹǷ Expression Blend ........................................................................................................................... 37 ǞǯǼǴǺȋ ǷǼȀȁǿȂǻǴǼȁǽDZ ......................................................................................................................................................................................... 38 ǞǯǼǴǺȋ DZǶǯǷǻǽdzǴǸȀȁDZǷǸ.................................................................................................................................................................................... 38 ǟǯǰǽȆǯȎ ǾǽDZǴǿȄǼǽȀȁȋ .......................................................................................................................................................................................... 39 ǞǯǼǴǺȋ ǾǿǽǴǹȁǯ...................................................................................................................................................................................................... 40 ǞǯǼǴǺȋ ȀDZǽǸȀȁDZ ...................................................................................................................................................................................................... 41 ǗȀǾǽǺȋǶǽDZǯǼǷǴ Blend dzǺȎ ȀǽǶdzǯǼǷȎ ǾǿǷǺǽǵǴǼǷǸ Silverlight ............................................................................................................... 42 ǙǽǻǾǽǼǽDZǹǯ ............................................................................................................................................................................................................. 42 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀǴȁǹǷ ..................................................................................................................................................................................... 43
ǗȀǾǽǺȋǶǽDZǯǼǷǴ Canvas ..................................................................................................................................................................................45 ǗȀǾǽǺȋǶǽDZǯǼǷǴ StackPanel ...........................................................................................................................................................................45 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ScrollViewer ........................................................................................................................................................................46 ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Border ........................................................................................................................................................................47 ǟǯǶǻǴȈǴǼǷǴ Ƿ ǼǯȀȁǿǽǸǹǯ DZǷǶȂǯǺȋǼȊȄ ȌǺǴǻǴǼȁǽDZ ................................................................................................................................47 ǟǯǶǻǴȈǴǼǷǴ Ƿ ǼǯȀȁǿǽǸǹǯ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ................................................................................................................................48 ǗȀǾǽǺȋǶǽDZǯǼǷǴ Blend dzǺȎ ȀǽǶdzǯǼǷȎ ǯǼǷǻǯȅǷǸ .....................................................................................................................................49 ǖǯǹǺȍȆǴǼǷǴ ..................................................................................................................................................................................................................51 ǢȀȁǯǼǽDZǹǯ 9LVXDO 6WXGLR 7RROV dzǺȎ 6LOYHUOLJKW .................................................................................................................................................53 ǗȀǾǽǺȋǶǽDZǯǼǷǴ Visual Studio dzǺȎ ȀǽǶdzǯǼǷȎ ǾǿǷǺǽǵǴǼǷȎ Silverlight .................................................................................................55 ǠǽǶdzǯǼǷǴ Silverlight-ǾǿǷǺǽǵǴǼǷȎ DZ Visual Studio 2008.......................................................................................................................55 ǞǿǽǴǹȁ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight ....................................................................................................................................................57 ǞǽǼǷǻǯǼǷǴ ȀDZǽǸȀȁDZ ǾǿǽǴǹȁǯ Silverlight .................................................................................................................................................58 ǣǯǸǺȊ ȀDZǽǸȀȁDZ ...................................................................................................................................................................................................59 ǠȀȊǺǹǷ ...................................................................................................................................................................................................................59 ǣǯǸǺȊ App.xaml Ƿ App.xaml.cs ...................................................................................................................................................................60 ǣǯǸǺȊ Page.xaml Ƿ Page.xaml.cs ................................................................................................................................................................61 ǑǴǰ-ǾǿǽǴǹȁ ...............................................................................................................................................................................................................62 ǜǯǾǷȀǯǼǷǴ ǷDzǿȊ Ǽǯ Silverlight 2..........................................................................................................................................................................64 ǠǽǶdzǯǼǷǴ UI DZ XAML ............................................................................................................................................................................................64 ǜǯǾǷȀǯǼǷǴ ǹǽdzǯ ǷDzǿȊ .........................................................................................................................................................................................64 ǗǼǷȅǷǯǺǷǶǯȅǷȎ ȀȁǿȂǹȁȂǿ dzǯǼǼȊȄ ............................................................................................................................................................64 ǠǽǶdzǯǼǷǴ ȃǿǯDzǻǴǼȁǽDZ DzǽǺǽDZǽǺǽǻǹǷ ......................................................................................................................................................65 ǞǴǿǴǻǴȇǷDZǯǴǻ ȃǿǯDzǻǴǼȁȊ .........................................................................................................................................................................67 ǝȁǿǷȀǽDZǹǯ ǷDzǿǽDZǽDzǽ ǾǽǺȎ ............................................................................................................................................................................67 ǝǰǿǯǰǽȁǹǯ dzǴǸȀȁDZǷǸ ǾǽǺȋǶǽDZǯȁǴǺȎ .........................................................................................................................................................68 ǞǿǽDZǴǿǹǯ ȂȀǺǽDZǷȎ DZȊǷDzǿȊȇǯ ....................................................................................................................................................................69 ǖǯǹǺȍȆǴǼǷǴ ..................................................................................................................................................................................................................70 ǙǽǻǾǽǼǽDZǽȆǼȊǴ ȀDZǽǸȀȁDZǯ XAML .......................................................................................................................................................................71 ǙǷȀȁǷ XAML ...................................................................................................................................................................................................................73 SolidColorBrush ........................................................................................................................................................................................................73 LinearGradientBrush...............................................................................................................................................................................................73 ǗǶǻǴǼǴǼǷǴ ǼǯǾǿǯDZǺǴǼǷȎ ǿǯȀǾǿǽȀȁǿǯǼǴǼǷȎ DzǿǯdzǷǴǼȁǯ.................................................................................................................74 ǓǽǰǯDZǺǴǼǷǴ ȁǽȆǴǹ DzǿǯdzǷǴǼȁǯ .....................................................................................................................................................................74 RadialGradientBrush ..............................................................................................................................................................................................76
ǖǯdzǯǼǷǴ ȃǽǹȂȀǯ ................................................................................................................................................................................................. 76 ǗǶǻǴǼǴǼǷǴ SpreadMethod ............................................................................................................................................................................ 77 ǖǯdzǯǼǷǴ ǿǯdzǷȂȀǯ RadialGradientBrush .................................................................................................................................................... 78 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ImageBrush ............................................................................................................................................................................. 79 ǟǯȀȁȎDzǷDZǯǼǷǴ ǷǶǽǰǿǯǵǴǼǷȎ ........................................................................................................................................................................ 79 ǑȊǿǯDZǼǷDZǯǼǷǴ ǷǶǽǰǿǯǵǴǼǷȎ ..................................................................................................................................................................... 80 VideoBrush ................................................................................................................................................................................................................. 81 ǑǷǶȂǯǺȋǼȊǴ ȀDZǽǸȀȁDZǯ XAML ................................................................................................................................................................................. 81 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀDZǽǸȀȁDZ XAML dzǺȎ ǶǯdzǯǼǷȎ ǿǯǶǻǴǿǽDZ Ƿ ǻǴȀȁǽǾǽǺǽǵǴǼǷȎ ............................................................................ 81 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǾǿǽǶǿǯȆǼǽȀȁǷ ....................................................................................................................................................................... 82 ǞǽDZǴdzǴǼǷǴ ǹȂǿȀǽǿǯ ............................................................................................................................................................................................. 82 ǢǾǿǯDZǺǴǼǷǴ ȀDZǽǸȀȁDZǽǻ Stroke ........................................................................................................................................................................ 82 ǖǯdzǯǼǷǴ ȇǷǿǷǼȊ ǽǰDZǽdzǹǷ ........................................................................................................................................................................... 83 ǖǯdzǯǼǷǴ ǽǰDZǽdzǹǷ ǾȂǼǹȁǷǿǽǻ ..................................................................................................................................................................... 84 ǝǾǿǴdzǴǺǴǼǷǴ ȁǷǾǯ ȀǽǴdzǷǼǴǼǷȎ ǺǷǼǷǸ .................................................................................................................................................. 85 ǣǷDzȂǿȊ DZ XAML ........................................................................................................................................................................................................... 86 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǽǰȉǴǹȁǯ Ellipse ...................................................................................................................................................................... 86 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǽǰȉǴǹȁǯ Rectangle ............................................................................................................................................................... 86 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǽǰȉǴǹȁǯ Line .......................................................................................................................................................................... 87 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǹǽǼȁȂǿǽDZ Ƿ DzǴǽǻǴȁǿǷȆǴȀǹǷȄ ȌǺǴǻǴǼȁǽDZ .................................................................................................................. 87 ǝǰȉǴǹȁ ArcSegment .......................................................................................................................................................................................... 88 ǝǰȉǴǹȁ LineSegment ........................................................................................................................................................................................ 88 ǝǰȉǴǹȁ PolyLineSegment ................................................................................................................................................................................ 89 ǝǰȉǴǹȁ BezierSegment .................................................................................................................................................................................... 89 ǝǰȉǴǹȁ PolyBezierSegment ............................................................................................................................................................................ 89 ǝǰȉǴǹȁ QuadraticBezierSegment ................................................................................................................................................................ 90 ǝǰȉǴǹȁ PolyQuadraticBezierSegment ........................................................................................................................................................ 91 ǠǽȀȁǯDZǼȊǴ ȀǴDzǻǴǼȁȊ ǹǽǼȁȂǿǯ ..................................................................................................................................................................... 92 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǽǰȉǴǹȁǯ GeometryGroup................................................................................................................................................... 92 ǮǶȊǹ ǽǾǷȀǯǼǷȎ ǹǽǼȁȂǿǽDZ.................................................................................................................................................................................. 93 ǑȊǿǴǶǯǼǷǴ Ƿ DzǴǽǻǴȁǿǷȆǴȀǹǷǴ ȌǺǴǻǴǼȁȊ DZ XAML ...................................................................................................................................... 94 ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ XAML DZ Silverlight ...................................................................................................................................................... 95 ǬǺǴǻǴǼȁ Canvas ..................................................................................................................................................................................................... 95 ǬǺǴǻǴǼȁ Image........................................................................................................................................................................................................ 96 ǬǺǴǻǴǼȁ Glyphs....................................................................................................................................................................................................... 96
ǬǺǴǻǴǼȁ TextBlock .................................................................................................................................................................................................97 ǢȆǯȀȁǹǷ Ƿ ǿǯǶǿȊDZȊ Ȁȁǿǽǹ .............................................................................................................................................................................98 ǖǯǹǺȍȆǴǼǷǴ ..................................................................................................................................................................................................................99 ǡǿǯǼȀȃǽǿǻǯȅǷǷ....................................................................................................................................................................................................... 100 ǑǿǯȈǴǼǷǴ Ȁ ǾǽǻǽȈȋȍ RotateTransform .................................................................................................................................................. 100 ǛǯȀȇȁǯǰǷǿǽDZǯǼǷǴ Ȁ ǾǽǻǽȈȋȍ ScaleTransform .................................................................................................................................. 102 ǞǴǿǴǻǴȈǴǼǷǴ ǽǰȉǴǹȁǯ Ȁ ǾǽǻǽȈȋȍ TranslateTransform ................................................................................................................. 103 ǜǯǹǺǽǼ ǽǰȉǴǹȁǯ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ SkewTransform .................................................................................................................... 104 ǗǻǷȁǯȅǷȎ ȁǿǴȄǻǴǿǼǽDzǽ ǷǶǽǰǿǯǵǴǼǷȎ Ȁ ǾǽǻǽȈȋȍ SkewTransform .......................................................................................... 105 ǝǾǿǴdzǴǺǴǼǷǴ ȀǽǰȀȁDZǴǼǼȊȄ ȁǿǯǼȀȃǽǿǻǯȅǷǸ Ȁ ǾǽǻǽȈȋȍ MatrixTransform ........................................................................... 106 ǠǽȆǴȁǯǼǷǴ ȁǿǯǼȀȃǽǿǻǯȅǷǸ .......................................................................................................................................................................... 107 ǏǼǷǻǯȅǷȎ ................................................................................................................................................................................................................... 108 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȁǿǷDzDzǴǿǽDZ Ƿ ȁǿǷDzDzǴǿǽDZ ȀǽǰȊȁǷǸ ............................................................................................................................... 108 ǗȀǾǽǺȋǶǽDZǯǼǷǴ BeginStoryboard Ƿ Storyboard ...................................................................................................................................... 109 ǝǾǿǴdzǴǺǴǼǷǴ ǾǯǿǯǻǴȁǿǽDZ ǯǼǷǻǯȅǷǷ ...................................................................................................................................................... 109 ǖǯdzǯǼǷǴ ǽǰȉǴǹȁǯ ǯǼǷǻǯȅǷǷ ..................................................................................................................................................................... 110 ǖǯdzǯǼǷǴ ǾǿǽdzǽǺǵǷȁǴǺȋǼǽȀȁǷ .................................................................................................................................................................. 110 ǖǯdzǯǼǷǴ ǻǽǻǴǼȁǯ ǼǯȆǯǺǯ .......................................................................................................................................................................... 110 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀDZǽǸȀȁDZǯ SpeedRatio ................................................................................................................................................... 110 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀDZǽǸȀȁDZǯ AutoReverse ................................................................................................................................................. 110 ǖǯdzǯǼǷǴ ȀDZǽǸȀȁDZǯ RepeatBehavior .......................................................................................................................................................... 110 ǏǼǷǻǯȅǷȎ ǶǼǯȆǴǼǷȎ Ȁ ǾǽǻǽȈȋȍ DoubleAnimation....................................................................................................................... 111 ǏǼǷǻǯȅǷȎ ȅDZǴȁǯ Ȁ ǾǽǻǽȈȋȍ ColorAnimation .................................................................................................................................. 111 ǏǼǷǻǯȅǷȎ ȁǽȆǹǷ Ȁ ǾǽǻǽȈȋȍ PointAnimation .................................................................................................................................. 112 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ ............................................................................................................................................................ 112 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǺǷǼǴǸǼȊȄ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ ................................................................................................................................. 113 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ dzǷȀǹǿǴȁǼǽǸ ǯǼǷǻǯȅǷǷ ....................................................................................................... 114 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ ȀDzǺǯǵǴǼǼǽǸ ǯǼǷǻǯȅǷǷ ...................................................................................................... 114 ǏǼǷǻǯȅǷȎ Ƿ Expression Blend ............................................................................................................................................................................ 115 ǖǯǹǺȍȆǴǼǷǴ ............................................................................................................................................................................................................... 119 ǟǯǶǻǴȈǴǼǷǴ Silverlight DZ ǰǿǯȂǶǴǿǴ ................................................................................................................................................................. 120 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȁǴDzǯ Object ǼǯǾǿȎǻȂȍ ........................................................................................................................................................ 123 ǟǴǯǹȅǷȎ Ǽǯ ȀǽǰȊȁǷȎ ǶǯDzǿȂǶǹǷ ȀȁǿǯǼǷȅȊ ..................................................................................................................................................... 124 ǝǰǿǯǰǽȁǹǯ ǾǯǿǯǻǴȁǿǽDZ ................................................................................................................................................................................... 124 ǞǽǺȋǶǽDZǯȁǴǺȋȀǹǷǸ ǹǽǼȁǴǹȀȁ .......................................................................................................................................................................... 125
ǟǴǯǹȅǷȎ Ǽǯ ȀǽǰȊȁǷȎ DZǽǶǼǷǹǯȍȈǷǴ DZ ȀǺȂȆǯǴ ǽȇǷǰǹǷ Ǽǯ ȀȁǿǯǼǷȅǴ ............................................................................................. 127 ǠȁǯǼdzǯǿȁǼȊǸ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷǸ .......................................................................................................................................................... 128 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀǽǰȀȁDZǴǼǼǽDzǽ ǽǰǿǯǰǽȁȆǷǹǯ ǽȇǷǰǽǹ ...................................................................................................................... 128 ǠDZǽǸȀȁDZǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight ............................................................................................................................................ 130 ǜǴǾǽȀǿǴdzȀȁDZǴǼǼȊǴ ȀDZǽǸȀȁDZǯ ................................................................................................................................................................... 130 ǠDZǽǸȀȁDZǯ ȀǽdzǴǿǵǷǻǽDzǽ .............................................................................................................................................................................. 130 ǠDZǽǸȀȁDZǯ ǼǯȀȁǿǽǴǹ ........................................................................................................................................................................................ 130 ǛǴȁǽdzȊ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight ............................................................................................................................................... 131 ǛǴȁǽdz createFromXaml ................................................................................................................................................................................ 131 ǛǴȁǽdz createFromXamlDownloader ....................................................................................................................................................... 132 ǛǴȁǽdz createObject........................................................................................................................................................................................ 132 ǛǴȁǽdz findName ............................................................................................................................................................................................. 132 ǝǰȉǴǹȁ Downloader ........................................................................................................................................................................................... 132 ǠDZǽǸȀȁDZǯ ǽǰȉǴǹȁǯ Downloader ................................................................................................................................................................ 132 ǛǴȁǽdzȊ ǽǰȉǴǹȁǯ Downloader ................................................................................................................................................................... 132 ǠǽǰȊȁǷȎ ǽǰȉǴǹȁǯ Downloader ................................................................................................................................................................. 133 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǽǰȉǴǹȁǯ Downloader ................................................................................................................................................... 133 ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ ȌǺǴǻǴǼȁǽDZ UI ................................................................................................................................................................. 134 ǛǴȁǽdzȊ ȌǺǴǻǴǼȁǽDZ UI ...................................................................................................................................................................................... 134 ǛǴȁǽdzȊ AddEventListener Ƿ RemoveEventListener ............................................................................................................................ 134 ǛǴȁǽdz findName ............................................................................................................................................................................................. 135 ǝǿDzǯǼǷǶǯȅǷȎ dzǽȀȁȂǾǯ ǹ ȌǺǴǻǴǼȁȂ ȂǾǿǯDZǺǴǼǷȎ Ȁ ǾǽǻǽȈȋȍ ǻǴȁǽdzǯ GetHost ................................................................... 135 ǝǿDzǯǼǷǶǯȅǷȎ dzǽȀȁȂǾǯ ǹ ǿǽdzǷȁǴǺȋȀǹǽǻȂ ȌǺǴǻǴǼȁȂ Ȁ ǾǽǻǽȈȋȍ ǻǴȁǽdzǯ getParent ......................................................... 135 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǻǴȁǽdzǽDZ GetValue Ƿ SetValue ................................................................................................................................. 135 ǗȀǾǽǺȋǶǽDZǯǼǷǴ SetFontSource ................................................................................................................................................................. 136 ǠǽǰȊȁǷȎ ȌǺǴǻǴǼȁǽDZ UI..................................................................................................................................................................................... 137 ǟǴǯǺǷǶǯȅǷȎ ǾǴǿǴǻǴȈǴǼǷȎ ȌǺǴǻǴǼȁǽDZ ǻǴȁǽdzǽǻ ©Drag-and-Dropª ........................................................................................... 138 ǖǯǹǺȍȆǴǼǷǴ ............................................................................................................................................................................................................... 140 ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Button .............................................................................................................................................................................. 141 ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ CheckBox ........................................................................................................................................................................ 142 ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ HyperlinkButton ........................................................................................................................................................... 143 ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Image ............................................................................................................................................................................... 144 ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ListBox.............................................................................................................................................................................. 145 ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ RadioButton ................................................................................................................................................................... 147 ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ TextBlock......................................................................................................................................................................... 148
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ TextBox ............................................................................................................................................................................ 150 ǝǰȈǷǴ ȀDZǽǸȀȁDZǯ ȀǽǰȊȁǷȎ Ƿ ǻǴȁǽdzȊ ............................................................................................................................................................. 152 ǝǰǿǯǰǽȁǹǯ ȃǽǹȂȀǯ ............................................................................................................................................................................................. 152 ǝǰǿǯǰǽȁǹǯ ȀǽǰȊȁǷǸ ǻȊȇǷ ............................................................................................................................................................................ 153 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀǽǰȊȁǷǸ ǻȊȇǷ dzǺȎ ǿǴǯǺǷǶǯȅǷǷ ǾǴǿǴǻǴȈǴǼǷȎ ǽǰȉǴǹȁǽDZ ǻǴȁǽdzǽǻ ©Drag-and-dropª............. 153 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǹǺǯDZǷǯȁȂǿȊ ......................................................................................................................................................................... 155 ǖǯǹǺȍȆǴǼǷǴ ............................................................................................................................................................................................................... 156 ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ DataGrid ......................................................................................................................................................................... 157 ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Calendar Ƿ DatePicker ........................................................................................................................................... 162 ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ RepeatButton Ƿ ToggleButton ........................................................................................................................... 164 ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ScrollViewer ................................................................................................................................................................... 165 ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Slider................................................................................................................................................................................. 167 ǖǯǹǺȍȆǴǼǷǴ ............................................................................................................................................................................................................... 167 ǠǽǶdzǯǼǷǴ ǾǿǽǴǹȁǯ................................................................................................................................................................................................... 168 ǓǽǰǯDZǺǴǼǷǴ ȇǯǰǺǽǼǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ....................................................................................................................................... 169 ǜǯǾǷȀǯǼǷǴ ǹǽdzǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ................................................................................................................................................... 170 ǠǽǶdzǯǼǷǴ ǰǷǰǺǷǽȁǴǹ ǹǺǯȀȀǽDZ Silverlight ...................................................................................................................................................... 172 ǖǯǹǺȍȆǴǼǷǴ ............................................................................................................................................................................................................... 176 ǞǽdzǹǺȍȆǴǼǷǴ ǾǿǷǺǽǵǴǼǷǸ Ȁ ǾǽǻǽȈȋȍ XAML ....................................................................................................................................... 177 Silverlight Ƿ PHP ................................................................................................................................................................................................... 177 Ǒǯȇǯ ǾǴǿDZǯȎ PHP-ȀȁǿǯǼǷȅǯ ..................................................................................................................................................................... 177 ǢȆǴǰǼȊǸ ǾǿǷǻǴǿ PHP Ƿ XAML ................................................................................................................................................................ 178 Silverlight Ƿ Java ................................................................................................................................................................................................... 186 ǠǽǶdzǯǼǷǴ ȀǴǿDZǺǴȁǯ dzǺȎ DzǴǼǴǿǷǿǽDZǯǼǷȎ XAML................................................................................................................................ 187 ǝȁǽǰǿǯǵǴǼǷǴ Silverlight ǷǶ JSP ............................................................................................................................................................... 190 ǗȀǾǽǺȋǶǽDZǯǼǷǴ JavaScript dzǺȎ ȀǽǶdzǯǼǷȎ ǾǿǷǺǽǵǴǼǷǸ DZǶǯǷǻǽdzǴǸȀȁDZȂȍȈǷȄ Ȁ ȀǴǿDZǴǿǽǻ ................................................. 191 ǗȀǾǽǺȋǶǽDZǯǼǷǴ AJAX ........................................................................................................................................................................................ 191 ǠǽǶdzǯǼǷǴ ȀǴǿDZǴǿǼǽDzǽ ǾǿǷǺǽǵǴǼǷȎ dzǺȎ ǾǽǺȂȆǴǼǷȎ ȁǴǹȂȈǴDzǽ DZǿǴǻǴǼǷ ............................................................................ 191 ǠǽǶdzǯǼǷǴ ǹǺǷǴǼȁȀǹǽDzǽ ǾǿǷǺǽǵǴǼǷȎ dzǺȎ ǽȁǽǰǿǯǵǴǼǷȎ DZǿǴǻǴǼǷ .......................................................................................... 192 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ASP.NET AJAX Ƿ ǑǴǰ-ȀǴǿDZǷȀǽDZ ....................................................................................................................................... 194 ǑǶǯǷǻǽdzǴǸȀȁDZǷǴ Ƿ dzǯǼǼȊǴ DZ NET .............................................................................................................................................................. 196 ǙǺǯȀȀ WebClient .............................................................................................................................................................................................. 196 ǙǺǯȀȀ WebRequest .......................................................................................................................................................................................... 197 ǗȀǾǽǺȋǶǽDZǯǼǷǴ SyndicatedFeed dzǺȎ ǽǿDzǯǼǷǶǯȅǷǷ dzǽȀȁȂǾǯ ǹ RSS Ƿ ATOM ............................................................................. 199 Silverlight Ƿ WCF .................................................................................................................................................................................................. 201
ǖǯǹǺȍȆǴǼǷǴ ............................................................................................................................................................................................................... 204 ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ MediaElement ............................................................................................................................................................... 205 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ MediaElement ...................................................................................................................... 206 ǞǿǽȀȁǽǴ DZǽȀǾǿǽǷǶDZǴdzǴǼǷǴ DZǷdzǴǽ Ȁ ǾǽǻǽȈȋȍ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ MediaElement .................................................. 206 ǟǯǶǻǴǿȊ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ MediaElement..................................................................................................................................... 207 ǟǯȀȁȎǵǴǼǷǴ ǻȂǺȋȁǷǻǴdzǷǯ .............................................................................................................................................................................. 207 ǞǿǽǶǿǯȆǼǽȀȁȋ DZǷdzǴǽǷǶǽǰǿǯǵǴǼǷȎ ........................................................................................................................................................... 209 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȁǿǯǼȀȃǽǿǻǯȅǷǸ Ȁ ȌǺǴǻǴǼȁǽǻ ȂǾǿǯDZǺǴǼǷȎ MediaElement............................................................................ 209 ǟǯȀǾǽǺǽǵǴǼǷǴ ȀǽdzǴǿǵǷǻǽDzǽ ǾǽDZǴǿȄ DZǷdzǴǽǷǶǽǰǿǯǵǴǼǷȎ ........................................................................................................... 210 ǑȊǿǴǶǯǼǷǴ ǻȂǺȋȁǷǻǴdzǷǯ DzǴǽǻǴȁǿǷȆǴȀǹǷǻǷ ȃǽǿǻǯǻǷ ................................................................................................................... 210 ǏDZȁǽǻǯȁǷȆǴȀǹǽǴ DZǽȀǾǿǽǷǶDZǴdzǴǼǷǴ........................................................................................................................................................... 211 ǢǾǿǯDZǺǴǼǷǴ DZǽȀǾǿǽǷǶDZǴdzǴǼǷǴǻ ǶDZȂǹǯ .................................................................................................................................................... 211 ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ MediaElement ................................................................................................................................................................ 212 ǐǯǶǽDZȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ DZǽȀǾǿǽǷǶDZǴdzǴǼǷǴǻ ........................................................................................................................ 212 ǢǾǿǯDZǺǴǼǷǴ ǰȂȃǴǿǷǶǯȅǷǴǸ Ƿ ǶǯDzǿȂǶǹǽǸ ................................................................................................................................................ 214 ǢǾǿǯDZǺǴǼǷǴ ȁǴǹȂȈǷǻ ȀǽȀȁǽȎǼǷǴǻ DZǷdzǴǽ ............................................................................................................................................... 215 ǢǾǿǯDZǺǴǼǷǴ ǾǽǺǽǵǴǼǷǴǻ ǹȂǿȀǽǿǯ DZǽȀǾǿǽǷǶDZǴdzǴǼǷȎ ..................................................................................................................... 216 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǻǯǿǹǴǿǽDZ DZǿǴǻǴǼǼǽǸ ȇǹǯǺȊ ǻȂǺȋȁǷǻǴdzǷǯ ....................................................................................................... 217 ǖǯǹǿǯȇǷDZǯǼǷǴ ǾǽDZǴǿȄǼǽȀȁǴǸ DZǷdzǴǽǷǶǽǰǿǯǵǴǼǷǴǻ Ȁ ǾǽǻǽȈȋȍ VideoBrush ........................................................................... 219 ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ InkPresenter ................................................................................................................................................................... 220 ǞǿǷǻǴǿ ǿȂǹǽǾǷȀǼȊȄ ǾǿǷǻǴȆǯǼǷǸ DZ Silverlight ................................................................................................................................... 221 ǙǺǯȀȀȊ ǿȂǹǽǾǷȀǼǽDzǽ DZDZǽdzǯ DZ Silverlight dzǺȎ ǿǯǶǿǯǰǽȁȆǷǹǽDZ Ǽǯ JavaScript ............................................................................ 222 ǡǷǾ StrokeCollection ...................................................................................................................................................................................... 222 ǡǷǾ Stroke .......................................................................................................................................................................................................... 222 ǡǷǾ StylusPointCollection ............................................................................................................................................................................. 223 ǡǷǾ StylusPoint ................................................................................................................................................................................................. 223 ǏǿDzȂǻǴǼȁȊ ȀǽǰȊȁǷǸ ǻȊȇǷ Ƿ ǿȂǹǽǾǷȀǼȊǸ DZDZǽdz ............................................................................................................................ 224 ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ dzǺȎ ǿȂǹǽǾǷȀǼǽDzǽ DZDZǽdzǯ DZ Silverlight.............................................................................................................. 224 ǟǴǯǺǷǶǯȅǷȎ Deep Zoom Ȁ ǾǽǻǽȈȋȍ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ MultiScaleImage ........................................................................... 228 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǿǴdzǯǹȁǽǿǯ Deep Zoom................................................................................................................................................... 230 ǞǴǿDZȊǸ ǾǿǽǴǹȁ Deep Zoom .......................................................................................................................................................................... 233 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǻȊȇǷ Ƿ ǺǽDzǷȆǴȀǹǷȄ ǹǽǽǿdzǷǼǯȁ DZ Deep Zoom ................................................................................................... 234 ǠǽǶdzǯǼǷǴ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁǷ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷȎ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǹǽǺǴȀǯ ǻȊȇǷ ........................................................ 236 ǙǽǺǺǴǹȅǷǷ DZ Deep Zoom ................................................................................................................................................................................ 237 ǖǯǹǺȍȆǴǼǷǴ ............................................................................................................................................................................................................... 239
ǞǽǼǷǻǯǼǷǴ ȀȁǷǺǴDZǽDzǽ ǽȃǽǿǻǺǴǼǷȎ.............................................................................................................................................................. 240 ǠǽǶdzǯǼǷǴ ȀȁǷǺȎ ................................................................................................................................................................................................... 241 ǗǶǻǴǼǴǼǷǴ ǽǰǺǯȀȁǷ dzǴǸȀȁDZǷȎ ȀȁǷǺȎ ......................................................................................................................................................... 242 ǧǯǰǺǽǼȊ ..................................................................................................................................................................................................................... 243 ǖǯǹǺȍȆǴǼǷǴ ............................................................................................................................................................................................................... 245 ǠǴǿDZǴǿǼȊǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ............................................................................................................................................... 246 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀȆǴȁȆǷǹǯ ȆǯȀȁǽȁȊ ǹǯdzǿǽDZ............................................................................................................................................. 246 ǖǯdzǯǼǷǴ ǻǯǹȀǷǻǯǺȋǼǽǸ ȆǯȀȁǽȁȊ ǹǯdzǿǽDZ ................................................................................................................................................ 248 ǝǰǴȀǾǴȆǴǼǷǴ dzǽȀȁȂǾǯ ǹ HTML ..................................................................................................................................................................... 248 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǾǴǿǴǿǷȀǽDZȊDZǯǴǻȊȄ ǽǰǺǯȀȁǴǸ ................................................................................................................................... 249 ǖǯdzǯǼǷǴ ȀDZǽǸȀȁDZǯ PluginBackground ......................................................................................................................................................... 249 ǢǾǿǯDZǺǴǼǷǴ ȂȀȁǯǼǽDZǹǽǸ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ ............................................................................................................................. 250 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǿǴǵǷǻǯ Stretch .................................................................................................................................................................. 251 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǿǴǵǷǻǯ Windowless ........................................................................................................................................................ 252 ǠǽǰȊȁǷȎ ȀǴǿDZǴǿǼǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight .................................................................................................................... 253 ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ MediaPlayer DZ ASP.NET ............................................................................................................................................ 254 ǜǯȀȁǿǽǸǹǯ ǾǿǷ ǾǽǻǽȈǷ MediaPlayer Tasks ........................................................................................................................................... 254 ǑǶǯǷǻǽdzǴǸȀȁDZǷǴ Ȁ ǻȂǺȋȁǷǻǴdzǷǯ ................................................................................................................................................................. 255 ǖǯǹǺȍȆǴǼǷǴ ............................................................................................................................................................................................................... 256 ǑǯȇǴ ǾǴǿDZǽǴ Silverlight-ǾǿǷǺǽǵǴǼǷǴ Ǽǯ IronPython ............................................................................................................................. 257 ǗȀǾǽǺȋǶǽDZǯǼǷǴ Ruby Ƿ JavaScript ................................................................................................................................................................... 261 ǗȀǾǽǺȋǶǽDZǯǼǷǴ Ruby ........................................................................................................................................................................................ 262 ǗȀǾǽǺȋǶǽDZǯǼǷǴ Dynamic JavaScript ........................................................................................................................................................... 262 ǐǽǺǴǴ ȀǺǽǵǼȊǸ ǾǿǷǻǴǿ ...................................................................................................................................................................................... 263 ǖǯǹǺȍȆǴǼǷǴ ............................................................................................................................................................................................................... 267
ǐǺǯDzǽdzǯǿǼǽȀȁǷ ǠǾǯȀǷǰǽ DZȀǴǻ ȀǽȁǿȂdzǼǷǹǯǻ Microsoft Press Ƿ Microsoft Learning Ƕǯ ȀDZǴdzǴǼǷǴ ȌȁǽǸ ǹǼǷDzǷ DZǽǴdzǷǼǽ ǝȁ dzǴǺȋǼǯȎ ǰǺǯDzǽdzǯǿǼǽȀȁȋ ǑǷǹȁǽǿǷǷ ǡǯǺǻǯǼ Victoria Thulman ǹǽȁǽǿǯȎ ǿȂǹǽDZǽdzǷǺǯ ȌȁǷǻ ǾǿǽǴǹȁǽǻ Ǯ ȆǿǴǶDZȊȆǯǸǼǽ ǾǿǷǶǼǯȁǴǺǴǼ ǴǸ Ƕǯ ȁǽ Ȇȁǽ ǰȊǺǯ Ȁǽ ǻǼǽǸ ǽȁǹǿǽDZǴǼǼǯ Ƿ ǼǴ dzǯDZǯǺǯ DZȊǰǷȁȋȀȎ ǷǶ DzǿǯȃǷǹǯ
ǑDZǴdzǴǼǷǴ ǞǽȆǴǻȂ Silverlight? Ǟǽ ǻǴǿǴ ǿǽȀȁǯ Ƿ ǿǯǶDZǷȁǷȎ ǑǴǰ ǿǯȀȁȂȁ Ƿ ǽǵǷdzǯǼǷȎ ǑǴǰ-ǾǽǺȋǶǽDZǯȁǴǺȎ ǞǴǿDZȊǸ ǑǴǰ-ǰǿǯȂǶǴǿ ǽǰǴȀǾǴȆǷDZǯǺ ǽȁǼǽȀǷȁǴǺȋǼǽ ǾǿǽȀȁǽǸ ȀǾǽȀǽǰ ȀǽǶdzǯǼǷȎ ȀȀȊǺǽǹ ǻǴǵdzȂ dzǽǹȂǻǴǼȁǯǻǷ ǙǽDzdzǯ ȌȁǷ ǰǿǯȂǶǴǿȊ ǰȊǺǷ ǽǰȉǴdzǷ ǼǴǼȊ Ȁ ǾǿǽȁǽǹǽǺǯǻǷ ǻǴǵǻǯȇǷǼǼǽDzǽ DZǶǯǷǻǽdzǴǸȀȁDZǷȎ ǾǽȎDZǷǺȀȎ ǗǼȁǴǿǼǴȁ Ƿ ǼǴǽǵǷdzǯǼǼǽ dzǽǹȂǻǴǼȁȊ ȄǿǯǼȎȈǷǴȀȎ Ǽǯ ȀǴǿDZǴǿǯȄ Ǿǽ DZȀǴǻȂ ǻǷǿȂ ȀȁǯǺǷ dzǽȀȁȂǾǼȊǻǷ dzǿȂDz dzǺȎ dzǿȂDzǯ Ǡǽ DZǿǴǻǴǼǴǻ ǯȂdzǷȁǽǿǷȎ ǷȀǾǽǺȋǶȂȍȈǯȎ ǗǼȁǴǿǼǴȁ ǷǶǻǴǼǷǺǯȀȋ ǠǴǸȆǯȀ Ȍȁǽ ȂǵǴ ǼǴ ǻǯǺǴǼȋǹǯȎ DzǿȂǾǾǯ ǺȍdzǴǸ ȀDZȎǶǯǼǼȊȄ Ȁ ǼǯȂǹǽǸ Ƿ ǷȀȀǺǴdzǽDZǯǼǷȎǻǷ DZ ǽǰǺǯȀȁǷ DZȊȆǷȀǺǷȁǴǺȋǼǽǸ ȁǴȄǼǷǹǷ ǯ DZȀǴ ǼǯȀǴǺǴǼǷǴ ǾǺǯǼǴȁȊ DZ ȅǴǺǽǻ Ǘ ȁǽ Ȇȁǽ ǰȊǺǽ ǾǿǷǴǻǺǴǻȊǻ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǷǻ ǷǼȁǴǿȃǴǸȀǽǻ dzǺȎ ȌǹȀǾǴǿȁǽDZ DZ ȌȁǽǸ ǽǰǺǯȀȁǷ DZȊDzǺȎdzǷȁ ȀǽDZǴǿȇǴǼǼǽ ȀǹȂdzǼǽ dzǺȎ ǹǽǻǻǴǿȆǴȀǹǷȄ ǾǿǷǺǽǵǴǼǷǸ ǠǴǸȆǯȀ ǺȍdzǷ ȄǽȁȎȁ ǷǻǴȁȋ Ǽǯ ȀȊȈǴǼǼȊǴ Ǽǽ ǾǿǷ Ȍȁǽǻ ǾǿǽȀȁȊǴ DZ ǷȀǾǽǺȋǶǽDZǯǼǷǷ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǷǴ ǷǼȁǴǿȃǴǸȀȊ Ƿ ȆǴǻ ǰǽǺȋȇǴ ȁǷǾǽDZ ǷǼȃǽǿǻǯȅǷǷ ȀȁǯǼǽDZǷȁȀȎ dzǽȀȁȂǾǼǽ DZ ǗǼȁǴǿǼǴȁǴ DZǹǺȍȆǯȎ ǿǯǶǼǽǽǰǿǯǶǼȊǴ DZǷdzȊ ǻǴdzǷǯȃǯǸǺǽDZ ȁǴǻ ȀǺǽǵǼǴǴ ǽȁDZǴȆǯȁȋ ǽǵǷdzǯǼǷȎǻ ǾǽǺȋǶǽDZǯȁǴǺǴǸ ǹǯȀǯȍȈǷǻȀȎ ǾǿǽȀȁǽȁȊ dzǽȀȁȂǾǯ ǹ ǼǴǽǰȄǽdzǷǻȊǻ Ƿǻ dzǯǼ ǼȊǻ ǜǴǽǰȄǽdzǷǻǽȀȁȋ ȀǼǯǰdzǷȁȋ ǾǽǺȋǶǽDZǯȁǴǺǴǸ ȀǺǽǵǼȊǻǷ ȀǿǴdzȀȁDZǯǻǷ dzǽȀȁȂǾǯ ǹ ǗǼȁǴǿǼǴȁ-ǿǴȀȂǿȀǯǻ ǹǽȁǽǿȊǴ ǰȊǺǷ ǰȊ ǾǿǽȀȁȊ DZ ǷȀǾǽǺȋǶǽDZǯǼǷǷ ǾǿǷDZǽdzȎȁ ǹ ǾǽȎDZǺǴǼǷȍ ǿǯȀȇǷǿǴǼǼȊȄ ȁǴȄǼǽǺǽDzǷǸ ǿǯǶǿǯǰǽȁǹǷ ǾǿǷ ǺǽǵǴǼǷǸ ǝdzǼǽǸ ǷǶ ȁǯǹǷȄ ȁǴȄǼǽǺǽDzǷǸ ȎDZǺȎǴȁȀȎ ǼǯǾǿǷǻǴǿ ȀǽǶdzǯǼǷǴ ©ǾǽdzǹǺȍȆǯǴǻȊȄª ǷǼȀȁǿȂǻǴǼȁǽDZ ǹǽȁǽǿȊǴ ǾǽǶDZǽǺȎȍȁ ǰǿǯȂǶǴǿȂ ȆǯȀȁǷȆǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ ǺǽǹǯǺȋǼȊǴ DZȊȆǷȀǺǷȁǴǺȋǼȊǴ ǿǴȀȂǿȀȊ ǾǽǺȋǶǽDZǯȁǴ ǺǴǸ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ActiveX, Java-ǯǾǾǺǴȁȊ Ƿ Flash-ǾǿǷǺǽǵǴǼǷȎ ² DZȀǴ Ȍȁǽ ǾǿǷǻǴǿȊ ȁǴȄǼǽǺǽDzǷǷ Ǿǽdz ǹǺȍȆǯǴǻȊȄ ǻǽdzȂǺǴǸ ǏȀǷǼȄǿǽǼǼȊǸ JavaScript Ƿ XML (AJAX) ² ǴȈǴ ǽdzǷǼ ǷǼȀȁǿȂǻǴǼȁ ȀǽǶdzǯǼǼȊǸ dzǺȎ ǿǯǶ ǿǯǰǽȁǹǷ ǶǯǻǴȆǯȁǴǺȋǼȊȄ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǷȄ ǷǼȁǴǿȃǴǸȀǽDZ ǼǽDZǽDzǽ ǾǽǹǽǺǴǼǷȎ DZ ǽȀǼǽDZǴ ǹǽȁǽǿȊȄ ǺǴǵǷȁ ǹǽǼȅǴǾȅǷȎ ǼǴǻǴdzǺǴǼǼȊȄ ȆǯȀȁǷȆǼȊȄ ǽǰǼǽDZǺǴǼǷǸ ǞǿǷ ǷȀǾǽǺȋǶǽDZǯǼǷǷ AJAX ǽǰǺǯȀȁȋ ȌǹǿǯǼǯ ǰǿǯȂǶǴǿǯ ǼǴ ǻǷDzǯǴȁ Ƿ ǼǴ ǰǺǽǹǷǿȂǴȁȀȎ ǾǽȁǽǻȂ Ȇȁǽ ǾǽǺǼǽǴ ǽǰǼǽDZǺǴǼǷǴ ȀȁǿǯǼǷȅȊ DZȊǾǽǺǼȎǴȁȀȎ ǿǴdzǹǽ AJAX ǾǽǶDZǽǺȎǴȁ ǿǯǶǿǯǰǽȁȆǷǹǯǻ ȀǽǶdzǯDZǯȁȋ ǰǽǺǴǴ dzǷǼǯǻǷȆǼȊǴ ǑǴǰ-ȀǯǸȁȊ Ȁ ǰǽǺǴǴ ȀǺǽǵǼȊǻ ȀǽdzǴǿǵǷ ǻȊǻ ȆǴǻ ǻǽDz ǰȊ ǽǰǴȀǾǴȆǷȁȋ ȁǽǺȋǹǽ HTML Ǽǽ ǴDzǽ DZǽǶǻǽǵǼǽȀȁǷ ȁǽǵǴ ǼǴ ǰǴǶDzǿǯǼǷȆǼȊ ǜǯǾǿǷǻǴǿ ǽǼ ǿǴǯǺǷǶȂǴȁ ǯȀǷǼȄǿǽǼǼȊǸ ǽǰǻǴǼ ǷǼȃǽǿǻǯȅǷǴǸ Ȁ ȀǴǿDZǴǿǽǻ Ǭȁǽ ǾǽǶDZǽǺȎǴȁ ǾǿǷǺǽǵǴǼǷȎǻ ȀǯǻǽȀȁǽȎȁǴǺȋǼǽ ǽǰǼǽDZǺȎȁȋȀȎ DZ ȃǽǼǽDZǽǻ ǿǴǵǷǻǴ Ƿ ȂȀȁǿǯǼȎǴȁ ǾǿǽǰǺǴǻȂ Ȁ ǻǴǿȅǯǼǷǴǻ ȌǹǿǯǼǯ Ȇȁǽ ȁǯǹ ȆǯȀȁǽ ǻǽǵǼǽ Ǽǯ ǰǺȍdzǯȁȋ DZ ȀǺǽǵǼȊȄ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǷȄ ǑǴǰ-ǷǼȁǴǿȃǴǸȀǯȄ ǜǽ AJAX ² Ȍȁǽ ǺǷȇȋ ǻǴȄǯǼǷǶǻ ȀDZȎǶǷ ǰǿǯȂǶǴǿȀǴǿDZǴǿ Ǒ ǼǴǻ ǼǴȁ ǾǽdzdzǴǿǵǹǷ DzǿǯȃǷǹǷ ǯǼǷǻǯȅǷǷ DZǷdzǴǽ Ƿ dzǿȂDzǷȄ DZǽǶǻǽǵǼǽȀȁǴǸ ǼǴǽǰȄǽdzǷǻȊȄ dzǺȎ ȀǽǶdzǯǼǷȎ Ǿǽ-ǼǯȀȁǽȎȈǴǻȂ ǻȂǺȋȁǷǻǴdzǷǸǼȊȄ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǷȄ ǷǼȁǴǿȃǴǸȀǽDZ ǓǺȎ DZȊȄǽdzǯ Ƕǯ ǿǯǻǹǷ ȌȁǷȄ ǽDzǿǯǼǷȆǴǼǷǸ Microsoft ǿǯǶǿǯǰǽȁǯǼǯ ȀȁǿǯȁǴDzǷȎ DZǶǯǷǻǽdzǴǸȀȁDZǷȎ ǾǽǺȋǶǽDZǯȁǴǺȎ (UX Ȁ ǑǴǰ Ǒ ǼǴǸ ǽǾǿǴdzǴǺȎǴȁȀȎ ȁǿǷ ȂǿǽDZǼȎ ǹǯȆǴȀȁDZǯ DZǶǯǷǻǽdzǴǸȀȁDZǷȎ ² ©ȄǽǿǽȇǴǴª ©ǶǯǻǴȆǯȁǴǺȋǼǽǴª Ƿ ©ǾǿǴdzǴǺȋǼǽǴª ² ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ ǹǽȁǽǿȊǻ ǾǿǷǼǷǻǯǴȁȀȎ ǿǴȇǴǼǷǴ ǽ ǾǿǷǻǴǼȎǴǻȊȄ ȁǴȄǼǽǺǽDzǷȎȄ ǿǯǶǿǯ ǰǽȁǹǷ Ƿ DZȊǾǽǺǼǴǼǷȎ Ǒ dzǯǼǼǽǸ ǹǼǷDzǴ Ȍȁǯ ǹǺǯȀȀǷȃǷǹǯȅǷȎ ȁǴȀǼǽ ȀDZȎǶǯǼǯ Ȁ ǾǽǼȎȁǷȎǻǷ ©ǼǯȀȊȈǴǼǼȊǸª Ƿ ©ǼǯȀȊȈǴǼǼǽȀȁȋª ǙǽDzdzǯ Ȏ DzǽDZǽǿȍ ©ǼǯȀȊȈǴǼǼȊǸª Ȏ ǾȊȁǯȍȀȋ ǽǾǷȀǯȁȋ ǹǽǼȅǴǾȅǷȍ ǹǽȁǽǿȂȍ ȀǺǽǵǼǽ DZȊ ǿǯǶǷȁȋ ȀǺǽDZǯǻǷ ǠǿǯDZǼǷȁǴ ǽȈȂȈǴǼǷǴ ǷȀǾȊȁȊDZǯǴǻǽǴ ǾǿǷ ǿǯǰǽȁǴ Ȁ ȁǿǯdzǷȅǷǽǼǼȊǻ ǑǴǰ-ǾǿǷǺǽǵǴǼǷǴǻ ǽDzǿǯǼǷȆǴǼǼȊǻ DZǽǶǻǽǵǼǽȀȁȎǻǷ ǰǿǯȂǶǴǿǯ Ƿ HTML, Ȁ ȁǴǻ ǹǽDzdzǯ DZȊ ǿǯǰǽȁǯǴȁǴ Ȁ ǼǯȀȁǽǺȋǼȊǻ ǾǿǷǺǽǵǴǼǷ Ǵǻ ǷǻǴȍȈǷǻ DZ ȀDZǽǴǻ ǿǯȀǾǽǿȎǵǴǼǷǷ ȀǺȂǵǰȊ Ƿ DZǽǶǻǽǵǼǽȀȁǷ DZȀǴǸ ǽǾǴǿǯȅǷǽǼǼǽǸ ȀǷȀȁǴǻȊ ǠǴDzǽdzǼȎȇ ǼǷǴ ǑǴǰ-ǾǿǷǺǽǵǴǼǷȎ ǼǴ ǽǰǴȀǾǴȆǷDZǯȍȁ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁǷ ǼǯȀȁǽǺȋǼȊȄ ǾǿǷǺǽǵǴǼǷǸ Ƿ ǾǽǺȋǶǽDZǯȁǴǺȋ ǽǰȊȆǼǽ ǾǽǼǷǻǯǴȁ Ȇȁǽ ǾǿǷȆǷǼǽǸ ǷȄ ǽDzǿǯǼǷȆǴǼǼǽȀȁǷ ȎDZǺȎǴȁȀȎ ȁǴȄǼǽǺǽDzǷȎ ǞǿǷǻǴǼȎȎ Silverlight (Ƿ AJAX), ǻȊ ȀȁǯDZǷǻ ȅǴǺȋ ȀǽǶdzǯȁȋ ǑǴǰ-ǾǿǷǺǽǵǴǼǷȎ ǽȆǴǼȋ ǰǺǷǶǹǷǴ ǹ ǼǯȀȁǽǺȋǼȊǻ ǾǿǷǺǽǵǴǼǷȎǻ Ƿ DZ ǹǽǼǴȆǼǽǻ ȀȆǴȁǴ ǼǴǽȁǺǷȆǷǻȊǴ ǽȁ ǼǷȄ ǠǯǻȊǸ ǾǿǽȀȁǽǸ ȂǿǽDZǴǼȋ DZǶǯǷǻǽdzǴǸȀȁDZǷȎ Ȁ ǾǽǺȋǶǽDZǯȁǴǺǴǻ ǻǽǵǼǽ ǿǴǯǺǷǶǽDZǯȁȋ DZ ǰǿǯȂǶǴǿǴ ǿǯȀȇǷǿǴǼ Ǽǽǻ AJAX. Ǭȁǽȁ ȂǿǽDZǴǼȋ ǽǾǿǴdzǴǺȎǴȁ ǰǯǶǽDZǽǴ Ǽǯ ȀǴDzǽdzǼȎȇǼǷǸ dzǴǼȋ ǽǵǷdzǯǼǷǴ UX ² ǯȀǷǼȄǿǽǼǼǽǴ dzǷǼǯ ǻǷȆǴȀǹǽǴ ǾǿǷǺǽǵǴǼǷǴ ǰǿǯȂǶǴǿǯ ǽǰǴȀǾǴȆǷDZǯǴǻǽǴ AJAX.
ǑDZǴdzǴǼǷǴ
xiii
ǑǴǿȄǼǷǸ ǷǺǷ ©ǾǿǴdzǴǺȋǼȊǸª ȂǿǽDZǴǼȋ ² Ȍȁǽ ǼǯȀȊȈǴǼǼǽǴ ǹǺǷǴǼȁȀǹǽǴ ǼǯȀȁǽǺȋǼǽǴ ǾǿǷǺǽǵǴǼǷǴ DZȊǾǽǺ ǼȎȍȈǴǴ Windows Vista Ƿ ǷȀǾǽǺȋǶȂȍȈǴǴ Windows Presentation Foundation (WPF) Ƿ .NET Framework. ǬȁǷ ȁǴȄǼǽǺǽDzǷǷ ǾǿǴdzǺǯDzǯȍȁ ȀǿǴdzȂ DZȊǾǽǺǼǴǼǷȎ ǹǽȁǽǿǯȎ ǾǽǶDZǽǺȎǴȁ ǿǯǶǿǯǰǽȁȆǷǹǯǻ ȀǽǶdzǯDZǯȁȋ ǷȀǹǺȍȆǷȁǴǺȋ Ǽǽ ǼǯȀȊȈǴǼǼȊǴ ǾǿǷǺǽǵǴǼǷȎ ǺǴDzǹǽ ǿǯǶDZǴǿȁȊDZǯǴǻȊǴ Ƿ ǽǰȀǺȂǵǷDZǯǴǻȊǴ ǜǯ Ȍȁǽǻ ȂǿǽDZǼǴ dzǽȀȁȂǾǼǯ ǾǴ ǿǴdzǯȆǯ ǹǯȆǴȀȁDZǴǼǼǽǸ DzǿǯȃǷǹǷ DZǷdzǴǽ Ƿ ǯǼǷǻǯȅǷǷ ǯ ȁǯǹǵǴ ȀǺȂǵǰȊ ǾǿǷǺǽǵǴǼǷǸ ȁǯǹǷǴ ǹǯǹ ȄǿǯǼǴǼǷǴ DZ DZǷdzǴ ȃǯǸǺǽDZ Ƿ ǷǼȁǴDzǿǯȅǷȎ Ȁ dzǿȂDzǷǻǷ ǼǯȀȁǽǺȋǼȊǻǷ ǾǿǷǺǽǵǴǼǷȎǻǷ ǙǿǽǻǴ ȁǽDzǽ WPF ǿǯǶdzǴǺȎǴȁ ȁǴȄǼǽ ǺǽDzǷǷ dzǷǶǯǸǼǯ Ƿ ǿǯǶǿǯǰǽȁǹǷ ȁǯǹǷǻ ǽǰǿǯǶǽǻ dzǷǶǯǸǼ Ƿ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǷȄ ǷǼȁǴǿȃǴǸȀǽDZ ȀǽǶdzǯȍȁȀȎ Ǽǯ ǼǽDZǽǻ ȎǶȊǹǴ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ ǼǯǶȊDZǯǴǻǽǻ XML Application Markup Language (XAML). ǓǷǶǯǸǼǴǿȊ ǾǽǺȂȆǷǺǷ ȀǽǶdzǯǼǼȊǴ ȀǾǴȅǷǯǺȋǼǽ dzǺȎ ǼǷȄ ǷǼȀȁǿȂǻǴǼȁȊ dzǷǶǯǸǼǯ ȁǯǹǷǴ ǹǯǹ ȀǴǿǷȎ Microsoft Expression, Ƿ ǻǽDzȂȁ ȁǴǾǴǿȋ ǾǿǴdzȀȁǯDZǺȎȁȋ ȀDZǽȍ ǿǯǰǽȁȂ DZ DZǷdzǴ XAML-dzǽǹȂǻǴǼȁǽDZ Ǐ ǿǯǶǿǯǰǽȁȆǷǹǷ ǾǿǴ ȁDZǽǿȎȍȁ DZ ǵǷǶǼȋ ǻǴȆȁȊ dzǷǶǯǸǼǴǿǽDZ ǯǹȁǷDZǷǿȂȎ Ȍȁǽȁ XAML ǹǽdzǽǻ Ǽǯ & 9%1(7 ǷǺǷ -DYD6FULSW Ǯ ȂǾǽǻȎǼȂǺ ȁǿǷ ȂǿǽDZǼȎ DZ ȀȁǿǯȁǴDzǷǷ UX ǾǽȁǽǻȂ Ȇȁǽ Ǿǽ ǻǴǿǴ ǿǯǶDZǷȁǷȎ AJAX Ƿ .NET/WPF ȀȁǯǺǽ ǽȆǴDZǷdz ǼȊǻ ǼǯǺǷȆǷǴ ǾǿǽǻǴǵȂȁǽȆǼǽǸ ǼǷȇǷ dzǺȎ ǼǽDZǽǸ ȁǴȄǼǽǺǽDzǷǷ ȌȃȃǴǹȁǷDZǼǽ ȀǽȆǴȁǯȍȈǴǸ DZ ȀǴǰǴ ǺȂȆȇǷǴ ȆǴǿȁȊ ǽǰǽǷȄ ǻǷǿǽDZ ² DzǺǽǰǯǺȋǼȂȍ ǻǯȀȇȁǯǰǷǿȂǴǻǽȀȁȋ ǗǼȁǴǿǼǴȁ-ǾǿǷǺǽǵǴǼǷȎ Ƿ ǼǯȀȊȈǴǼǼǽȀȁȋ ǼǯȀȁǽǺȋ ǼǽDzǽ ǾǿǷǺǽǵǴǼǷȎ ǡǯǹǽǴ DZǶǯǷǻǽdzǴǸȀȁDZǷǴ Ȁ ǾǽǺȋǶǽDZǯȁǴǺǴǻ ǰȊǺǽ ǼǯǶDZǯǼǽ ©ǶǯǻǴȆǯȁǴǺȋǼȊǻª Ƿ ǽǰǴȀǾǴ ȆǷDZǯǴȁȀȎ ǰǿǯȂǶǴǿǽǻ ǿǯȀȇǷǿǴǼǼȊǻ AJAX Ƿ ǼǽDZǽǸ ȁǴȄǼǽǺǽDzǷǴǸ Silverlight. Silverlight ² Ȍȁǽ ǾǽdzǹǺȍȆǯǴǻȊǸ ǻǽdzȂǺȋ dzǺȎ ǰǿǯȂǶǴǿǯ ȃǽǿǻǷǿȂȍȈǷǸ DZǷǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ XAML Ƿ ǾǿǴdzǽȀȁǯDZǺȎȍȈǷǸ ǾǿǽDzǿǯǻǻǼȊǸ ǷǼȁǴǿȃǴǸȀ ǡǯǹǷǻ ǽǰǿǯǶǽǻ ǽǼ ǽǰǴȀǾǴȆǷDZǯǴȁ DZǽǶǻǽǵǼǽȀȁȋ ȀǽDZǻǴ ȀȁǼǽǸ ǿǯǰǽȁȊ dzǷǶǯǸǼǴǿǽDZ Ƿ ǿǯǶǿǯǰǽȁȆǷǹǽDZ ǾǿǷ ȀǽǶdzǯǼǷǷ ǗǼȁǴǿǼǴȁ-ǾǿǷǺǽǵǴǼǷǸ ǽǰǺǯdzǯȍȈǷȄ ǼǯȀȊ ȈǴǼǼǽȀȁȋȍ ǼǯȀȁǽǺȋǼȊȄ ǾǿǷǺǽǵǴǼǷǸ ǞǴǿDZǯȎ DZȊǾȂȈǴǼǼǯȎ DZǴǿȀǷȎ Silverlight ǾǿǴdzȀȁǯDZǷǺǯ JavaScript-ǽǿǷǴǼȁǷǿǽDZǯǼǼȂȍ ǻǽdzǴǺȋ ǾǿǽDzǿǯǻǻǷǿǽ DZǯǼǷȎ ǹǽȁǽǿǯȎ ǽǰǴȀǾǴȆǷǺǯ ǻǽȈǼǽǴ ȀǿǴdzȀȁDZǽ ǼǯǾǷȀǯǼǷȎ ȀȅǴǼǯǿǷǴDZ dzǺȎ XAML-ȌǺǴǻǴǼȁǽDZ DZ ǰǿǯȂǶǴǿǴ Silverlight 2 ȀȂȈǴȀȁDZǴǼǼǽ ǿǯȀȇǷǿȎǴȁ ȌȁȂ ǻǽdzǴǺȋ ǾǽdzdzǴǿǵǹǽǸ .NET ǰǺǯDzǽdzǯǿȎ ǹǽȁǽǿǽǸ ǾǽȎDZǺȎǴȁȀȎ DZǽǶ ǻǽǵǼǽȀȁȋ ǷȀǾǽǺȋǶǽDZǯǼǷȎ ȎǶȊǹǽDZ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ .NET Ƿ ǾǴǿǴȄǽdz Ǽǯ ǼǽDZȊǸ ȂǿǽDZǴǼȋ Ƕǯ ȀȆǴȁ ǿǯǰǽȁȊ Ȁ XAML, ǽǰǴȀǾǴȆǴǼǷȎ ǷȀǾǽǺȋǶǽDZǯǼǷȎ DzǽȁǽDZȊȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǾǽdzdzǴǿǵǹǷ ǿǯǰǽȁȊ Ȁ ȀǴȁȋȍ ǻǽȈ ǼȊȄ ǰǷǰǺǷǽȁǴǹ dzǯǼǼȊȄ ǿǯȀȇǷǿȎǴǻǽȀȁǷ Ƿ ȀȂȈǴȀȁDZǴǼǼǽDzǽ ȂǺȂȆȇǴǼǷȎ ǾǿǽǷǶDZǽdzǷȁǴǺȋǼǽȀȁǷ Ǒ dzǯǼǼǽǸ ǹǼǷDzǴ ǿǯȀȀǻǯȁǿǷDZǯǴȁȀȎ Silverlight Ƿ ȁǽ ǹǯǹ ǽǼ ǽǰǴȀǾǴȆǷDZǯǴȁ ǺȂȆȇǴǴ DZǶǯǷǻǽdzǴǸȀȁDZǷȎ Ȁ ǾǽǺȋǶǽDZǯ ȁǴǺǴǻ DZ ǑǴǰ. Silverlight ǻǽǵǴȁ ǷǶǻǴǼǷȁȋ DZǯȇǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ǽ ǾǽȀȁǿǽǴǼǷǷ ǾǿǷǺǽǵǴǼǷǸ dzǺȎ ǑǴǰ ǑǻǴȀȁǽ ǑǴǰ-ȀǯǸȁǽDZ ȁǴǾǴǿȋ ǰȂdzǴȁ ȀǽǶdzǯDZǯȁȋȀȎ ǑǴǰ-DZǾǴȆǯȁǺǴǼǷǴ Ǒ ǽȀǼǽDZǴ ǶǯǻǴȆǯȁǴǺȋǼǽDzǽ DZǾǴȆǯȁǺǴǼǷȎ ǺǴǵǷȁ ǶǯǻǴȆǯȁǴǺȋ ǼȊǸ dzǷǶǯǸǼ Ƿ Silverlight ȆǴǿǴǶ XAML Ƿ ǷǼȀȁǿȂǻǴǼȁȊ ǾǯǹǴȁǯ Microsoft Expression ǾǽǶDZǽǺȎǴȁ dzǷǶǯǸǼǴǿǯǻ Ƿ ǿǯǶǿǯǰǽȁȆǷǹǯǻ ǽǰȉǴdzǷǼǷȁȋ ȀDZǽǷ ȂȀǷǺǷȎ Ǽǯ ǾȂȁǷ ǹ dzǽȀȁǷǵǴǼǷȍ ȌȁǽǸ ȅǴǺǷ ǞǿǷ ǼǯǾǷȀǯǼǷǷ ȌȁǽǸ ǹǼǷDzǷ Ȏ ȀȁǯDZǷǺ ǾǴǿǴdz ȀǽǰǽǸ ǶǯdzǯȆȂ ǽǰǴȀǾǴȆǷȁȋ ǾǽǼǷǻǯǼǷǴ ȁǴȄǼǽǺǽDzǷǸ ǷȀǾǽǺȋ ǶȂǴǻȊȄ ȀǽDZǻǴȀȁǼǽ dzǺȎ ǿǯǶǿǯǰǽȁǹǷ Ƿ ǿǯǶDZǴǿȁȊDZǯǼǷȎ ǑǴǰ-ǾǿǷǺǽǵǴǼǷǸ Silverlight ǽȁ ǼǯǾǷȀǯǼǷȎ ǰǯǶǽDZǽDzǽ ǹǽdzǯ dzǺȎ Silverlight dzǽ ǿǯȀȇǷǿǴǼǼȊȄ ǷǼȀȁǿȂǻǴǼȁǽDZ dzǺȎ ȀǽǶdzǯǼǷȎ Ƿ dzǽȀȁǯDZǹǷ Silverlight-ȀǽdzǴǿǵǷǻǽDzǽ ǞǿǽȆǷȁǯDZ ȌȁȂ ǹǼǷDzȂ Ƿ ǾǿǽǿǯǰǽȁǯDZ DZȀǴ ǾǿǷǻǴǿȊ DZȊ dzǽǺǵǼȊ ǰȊȁȋ DzǽȁǽDZȊ ǾǿǷǻǴǼȎȁȋ ǷǶȂȆǴǼǼǽǴ Ǽǯ Ǿǿǯǹ ȁǷǹǴ dzǺȎ ȂǺȂȆȇǴǼǷȎ ǑǴǰ-ǾǿǷǺǽǵǴǼǷǸ ǿǯǶDZǴǿȁȊDZǯǴǻȊȄ ȀǴǸȆǯȀ Ǐ ǾǿǴdzȀȁǯDZȋȁǴ Ȇȁǽ DZȊ ȀǻǽǵǴȁǴ ȀdzǴǺǯȁȋ ǶǯDZȁǿǯ
ǓǺȎ ǹǽDzǽ Ȍȁǯ ǹǼǷDzǯ Ǭȁǯ ǹǼǷDzǯ ǼǯǾǷȀǯǼǯ dzǺȎ ǿǯǶǿǯǰǽȁȆǷǹǽDZ ǹǽȁǽǿȊǴ DzǽȁǽDZȊ ǴǵǴdzǼǴDZǼǽ ǿǯǰǽȁǯȁȋ Ǽǯdz ȀǽǶdzǯǼǷǴǻ ǼǽDZȊȄ Ƿ ǺȂȆȇǷȄ ǑǴǰ-ǾǿǷǺǽǵǴǼǷǸ dzǺȎ ǾǽǺȋǶǽDZǯȁǴǺǴǸ ǗǼȁǴǿǼǴȁ Ƿ ǹǽȁǽǿȊǴ ȄǽȁȎȁ dzǽǰǯDZǷȁȋ ȌȁȂ ǾǴǿǴdzǽDZȂȍ ȁǴȄǼǽ ǺǽDzǷȍ Microsoft DZ ǹǽǻǾǺǴǹȁ ȀDZǽǷȄ ǶǼǯǼǷǸ ȆȁǽǰȊ ǾǽǼȎȁȋ ǹǯǹ Ȁ ǴǴ ǾǽǻǽȈȋȍ ǽǰǴȀǾǴȆǷȁȋ ǰǽǺǴǴ ǷǼȁǴǿǴȀ ǼȊǴ ȃȂǼǹȅǷǽǼǯǺȋǼȊǴ Ƿ ȌȃȃǴǹȁǷDZǼȊǴ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǷǴ ǷǼȁǴǿȃǴǸȀȊ ǙǼǷDzǯ ǼǯǾǷȀǯǼǯ dzǽȀȁȂǾǼǽ Ƿ ǻǽ ǵǴȁ ǰȊȁȋ ǾǽǺǴǶǼǽǸ ȁǯǹǵǴ ǿȂǹǽDZǽdzǷȁǴǺȎǻ ǿǯǶǿǯǰǽȁǹǷ dzǺȎ ǾǽǼǷǻǯǼǷȎ ǻǴȀȁǯ Silverlight DZ ǻǷǿǴ ǑǴǰȁǴȄǼǽǺǽDzǷǸ Microsoft ǟȂǹǽDZǽdzǷȁǴǺǷ dzǯǵǴ ǻǽDzȂȁ ǾǽȆǴǿǾǼȂȁȋ ǷǶ ǼǴǴ ǰǯǶǽDZȊǴ ȁǴȄǼǷȆǴȀǹǷǴ ȀDZǴdzǴǼǷȎ ǹǽ ȁǽǿȊǴ Ƿǻ ǾǽǼǯdzǽǰȎȁȀȎ ǹǽDzdzǯ ǷȄ ǿǯǶǿǯǰǽȁȆǷǹǷ Ȁ DZǶDZǽǺǼǽDZǯǼǼȊǻ DZǷdzǽǻ ǾǿǷdzȂȁ ǾǽDzǽDZǽǿǷȁȋ ǽ Silverlight. Ǟǽ ǹǿǯǸǼǴǸ ǻǴǿǴ ǽǼǷ ǰȂdzȂȁ ǾǽǼǷǻǯȁȋ ȆǴǻ DZȊǶDZǯǼ ȁǯǹǽǸ ȌǼȁȂǶǷǯǶǻ
xiv
ǑDZǴdzǴǼǷǴ
ǝ ȆǴǻ Ȍȁǯ ǹǼǷDzǯ Ǭȁǯ ǹǼǷDzǯ ǿǯǶdzǴǺǴǼǯ Ǽǯ dzDZǴ ȆǯȀȁǷ ǦǯȀȁȋ I, ǑDZǴdzǴǼǷǴ DZ Silverlight 2, ǾǿǴdzȀȁǯDZǺȎǴȁ ǽȀǼǽDZȊ Silverlight. Ǒ ǼǴǸ ǿǯȀȀǻǯȁǿǷDZǯǴȁȀȎ Ȇȁǽ ȁǯǹǽǴ Silverlight Ƿ ǹǯǹǷǴ ǷǼȀȁǿȂǻǴǼȁȊ ǷȀǾǽǺȋǶȂȍȁȀȎ dzǺȎ ȀǽǶdzǯǼǷȎ Ƿ ǽǰȀǺȂǵǷDZǯ ǼǷȎ Silverlight-ǾǿǷǺǽǵǴǼǷǸ DZǹǺȍȆǯȎ Microsoft Expression Blend Ƿ Microsoft Visual Studio. Ǒ ǦǯȀȁǷ I ȁǯǹǵǴ ǽǰȀȂǵdzǯǴȁȀȎ ȁǴȄǼǽǺǽDzǷȎ XAML Ƿ ȁǽ ǹǯǹ ǽǼǯ ǷȀǾǽǺȋǶȂǴȁ XML dzǺȎ ǽǾǷȀǯǼǷȎ DZȀǴDzǽ ǾǽǺȋ ǶǽDZǯȁǴǺȋȀǹǽDzǽ ǷǼȁǴǿȃǴǸȀǯ ǼǯȆǷǼǯȎ ǽȁ ǹǽǻǾǽǼǽDZǹǷ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ dzǽ ǯǼǷǻǯȅǷǷ Ƿ Ǿǿ ǜǯǹǽ ǼǴȅ DZ ȌȁǽǸ ȆǯȀȁǷ ǾǽdzǿǽǰǼǽ ǿǯȀȀǻǯȁǿǷDZǯǴȁȀȎ Ȁǯǻ ǾǽdzǹǺȍȆǯǴǻȊǸ ǻǽdzȂǺȋ Silverlight Ƿ ǴDzǽ DZǶǯǷǻǽdzǴǸȀȁ DZǷǴ Ȁ ǰǿǯȂǶǴǿǽǻ ǰǺǯDzǽdzǯǿȎ ǹǽȁǽǿǽǻȂ DZǯȇǷ ǾǿǷǺǽǵǴǼǷȎ ȀȁǯǼǽDZȎȁȀȎ ǾǽǺǼǽǾǿǯDZǼȊǻǷ ǽǰǷȁǯȁǴǺȎǻǷ ǰǿǯȂǶǴǿǯ Ǒ ǦǯȀȁǷ II, ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2, ǻȊ ǾǴǿǴȄǽdzǷǻ ǹ dzǴȁǯǺȎǻ DZȊȀǽǹǽȂǿǽDZǼǴDZȊȄ ǹǽǼȅǴǾȅǷǸ Silverlight 2. Ǭȁǽ ǽǰȀȂǵdzǴǼǷǴ ǼǷ DZ ǹǽǴǻ ȀǺȂȆǯǴ ǼǴ ȎDZǺȎǴȁȀȎ ǷȀȆǴǿǾȊDZǯȍȈǷǻ ȀǾǿǯDZǽȆǼǷǹǽǻ Ǽǽ ǼǯǾǷȀǯǼǽ ǹǯǹ ǾǿǽȀȁǽǴ Ƿ ȀȁǿǽDzǽǴ DZDZǴdzǴǼǷǴ DZ ǿǯǶǿǯǰǽȁǹȂ DZ Silverlight ǠǼǯȆǯǺǯ ǿǯȀȀǻǯȁǿǷDZǯȍȁȀȎ DZȀȁǿǽǴǼǼȊǴ ȌǺǴ ǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Ƿǻ ǾǽȀDZȎȈǴǼȊ dzDZǴ DzǺǯDZȊ ǶǯȁǴǻ dzǴǻǽǼȀȁǿǷǿȂǴȁȀȎ Ȁ ǹǯǹǽǸ ǺǴDzǹǽȀȁȋȍ ǻǽDzȂȁ ȀǽǶdzǯ DZǯȁȋȀȎ ȀǽǰȀȁDZǴǼǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ǑȊ ǷǶȂȆǷȁǴ dzǯǼǼȊǴ DZǶǯǷǻǽdzǴǸȀȁDZǷǴ Ǿǽ ȀǴȁǷ ǾǿǽDzǿǯǻǻǷǿǽ DZǯǼǷǴ ǯǼǷǻǯȅǷǷ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ASP.NET dzǺȎ Silverlight ǯ ȁǯǹǵǴ ǼǴǹǽȁǽǿȊǴ ǿǯȀȇǷǿǴǼǼȊǴ ȌǺǴ ǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ dzǺȎ ǿǯǰǽȁȊ Ȁ ǻȂǺȋȁǷǻǴdzǷǯ Ƿ ǿȂǹǽǾǷȀǼȊǻ DZDZǽdzǽǻ Ƿ ǼǽDZȊǸ ǹǽǻǾǽǼǴǼȁ DeepZoom, ǽǰǴȀǾǴȆǷDZǯȍȈǷǸ ȀǼǽDzȀȇǷǰǯȁǴǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ǷǶǽǰǿǯǵǴǼǷǸ Ǘ ǶǯDZǴǿȇǯǴȁȀȎ ǹǼǷDzǯ ǽǰǶǽǿǽǻ Ǽǽ DZǽǸ ǶǯȄDZǯȁȊDZǯȍȈǴǸ DZǽǶǻǽǵǼǽȀȁǷ Silverlight ǾǽdzdzǴǿǵǹǷ dzǷǼǯǻǷȆǴȀǹǷȄ ȎǶȊǹǽDZ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ
ǠǷȀȁǴǻǼȊǴ ȁǿǴǰǽDZǯǼǷȎ ǓǺȎ ǿǯǶǿǯǰǽȁǹǷ Silverlight-ǾǿǷǺǽǵǴǼǷǸ ǾǿǴdzȀȁǯDZǺǴǼǼȊȄ DZ dzǯǼǼǽǸ ǹǼǷDzǴ ǾǽǼǯdzǽǰǷȁȋȀȎ ȀǺǴdzȂȍȈǴǴ (ǽǾȎȁȋ ǵǴ, DZȀǴ dzǽȀȁȂǾǼǽ Ǽǯ ȀǯǸȁǴ http://silverlight.net/GetStarted/): x
Microsoft Visual Studio 2008 Ȁ ǾǯǹǴȁǽǻ ǽǰǼǽDZǺǴǼǷǸ 63
x
Microsoft Expression Design
x
0LFURVRIW ([SUHVVLRQ %OHQG Ȁ ǾǯǹǴȁǽǻ ǽǰǼǽDZǺǴǼǷǸ 63
x
Microsoft Silverlight Software Development Kit
ǟǴǹǽǻǴǼdzȂǴǻǯȎ ǹǽǼȃǷDzȂǿǯȅǷȎ ȀǷȀȁǴǻȊ dzǺȎ Microsoft Silverlight: 128 Ǜǐ ǽǾǴǿǯȁǷDZǼǽǸ ǾǯǻȎȁǷ Ƿ ǾǿǽȅǴȀ Ȁǽǿ Ȁ ȆǯȀȁǽȁǽǸ 450 Ǜǒȅ ǷǺǷ ǰǽǺǴǴ dzǺȎ Windows Ƿ 1 ǒǐ ǽǾǴǿǯȁǷDZǼǽǸ ǾǯǻȎȁǷ Ƿ ǾǿǽȅǴȀȀǽǿ Intel Ȁ ȆǯȀȁǽ ȁǽǸ 1,83 ǒǒȅ ǷǺǷ ǰǽǺǴǴ dzǺȎ Mac OSX. ǟǴǹǽǻǴǼdzȂǴǻǯȎ ǹǽǼȃǷDzȂǿǯȅǷȎ dzǺȎ Microsoft Visual Studio 2008: ǥǞ Ȁ ȆǯȀȁǽȁǽǸ 2,2 ǒǒȅ ǷǺǷ ǰǽǺǴǴ, ǽǾǴǿǯ ȁǷDZǼǽǸ ǾǯǻȎȁǷ 1024 Ǜǐ ǷǺǷ ǰǽǺǴǴ, ȌǹǿǯǼ 1280 x 1024, ǵǴȀȁǹǷǸ dzǷȀǹ Ȁ ȆǯȀȁǽȁǽǸ DZǿǯȈǴǼǷȎ 7200 ǽǰǻǷǼ ǷǺǷ DZȊȇǴ. (ǛǷǼǷǻǯǺȋǼȊǴ ȁǿǴǰǽDZǯǼǷȎ ǥǞ Ȁ ȆǯȀȁǽȁǽǸ 1,6 ǒǒȅ, 384 Ǜǐ ǽǾǴǿǯȁǷDZǼǽǸ ǾǯǻȎȁǷ, ȌǹǿǯǼ 1024 x 768, ǵǴȀȁǹǷǸ dzǷȀǹ Ȁ ȆǯȀȁǽȁǽǸ DZǿǯȈǴǼǷȎ 5400 ǽǰǻǷǼ.) ǓǺȎ Windows Vista ǿǴǹǽǻǴǼdzȂǴȁȀȎ: ǥǞ Ȁ ȆǯȀȁǽ ȁǽǸ 2,4 ǒǒȅ, 768 Ǜǐ ǽǾǴǿǯȁǷDZǼǽǸ ǾǯǻȎȁǷ.
ǑǴǰ-ȀǯǸȁ ǹǽǻǾǯǼǷǷ ǓǯǼǼǯȎ ǹǼǷDzǯ ǾǿǴdzȀȁǯDZǺǴǼǯ Ǽǯ ǑǴǰ-ȀǯǸȁǴ ǹǽǻǾǯǼǷǷ DzdzǴ ǻǽǵǼǽ ǼǯǸȁǷ DZǴȀȋ ǷȀǾǽǺȋǶȂǴǻȊǸ DZ ǼǴǸ ǹǽdz ǝǼ ǽǿDzǯǼǷǶǽDZǯǼ Ǿǽ DzǺǯDZǯǻ ǠǹǯȆǯȁȋ ǴDzǽ ǻǽǵǼǽ Ȁ ȀǯǸȁǯ ǹǽǻǾǯǼǷǷ Ǿǽ ǯdzǿǴȀȂ http://www.microsoft.com/mspress/companion/9780735625280
ǞǽdzdzǴǿǵǹǯ ǹǼǷDzǷ Microsoft Press ǽǰǴȀǾǴȆǷDZǯǴȁ ǾǽdzdzǴǿǵǹȂ ǹǼǷDz Ƿ ȀǽǾǿǽDZǽdzǷȁǴǺȋǼȊȄ ǻǯȁǴǿǷǯǺǽDZ Ǽǯ ȀǺǴdzȂȍȈǴǻ ǑǴǰȀǯǸȁǴ: http://www.microsoft.com/learning/support/books/
ǑDZǴdzǴǼǷǴ
xv
ǓǽǾǽǺǼǷȁǴǺȋǼȊǴ ǻǯȁǴǿǷǯǺȊ ǻǽǵǼǽ ǼǯǸȁǷ DZ ȀǴȁǷ ǑȀǴ ǼǽDZȊǴ ǷǺǷ ǽǰǼǽDZǺǴǼǼȊǴ ǻǯȁǴǿǷǯǺȊ, dzǽǾǽǺ ǼȎȍȈǷǴ ȌȁȂ ǹǼǷDzȂ ǰȂdzȂȁ ǿǯǶǻǴȈǯȁȋȀȎ Ǽǯ ǑǴǰ-ȀǯǸȁǴ Microsoft Press Online Developer Tools. Ǚ ȁǯǹǷǻ ǻǯȁǴǿǷǯ Ǻǯǻ ǽȁǼǽȀȎȁȀȎ ǽǰǼǽDZǺǴǼǷȎ ȀǽdzǴǿǵǷǻǽDzǽ ǹǼǷDzǷ, ȀȁǯȁȋǷ, ȀȀȊǺǹǷ Ǽǯ ȀǽǾǿǽDZǽdzǷȁǴǺȋǼȊǴ ǻǯȁǴǿǷǯǺȊ, ȀǾǷȀǽǹ ǽǾǴ Ȇǯȁǽǹ ǾǿǷǻǴǿȊ DzǺǯDZ Ƿ ǻǼǽDzǽǴ dzǿȂDzǽǴ Ǭȁǽȁ ǑǴǰ-ȀǯǸȁ ǰȂdzǴȁ dzǽȀȁȂǾǴǼ DZ Ȁǹǽǿǽǻ DZǿǴǻǴǼǷ Ǿǽ ǯdzǿǴȀȂ www.microsoft.com/learning/books/online/developer Ƿ ǰȂdzǴȁ ǾǴǿǷǽdzǷȆǴȀǹǷ ǽǰǼǽDZǺȎȁȋȀȎ.
ǑǽǾǿǽȀȊ Ƿ ǹǽǻǻǴǼȁǯǿǷǷ ǑȀǴ ǹǽǻǻǴǼȁǯǿǷǷ DZǽǾǿǽȀȊ ǷǺǷ ǾǿǴdzǺǽǵǴǼǷȎ ǹǯȀǯȍȈǷǴȀȎ dzǯǼǼǽǸ ǹǼǷDzǷ ǷǺǷ ȀǽǾǿǽDZǽdzǷȁǴǺȋǼȊȄ ǻǯȁǴ ǿǷǯǺǽDZ Ƿ DZǽǾǿǽȀȊ ǽȁDZǴȁȊ Ǽǯ ǹǽȁǽǿȊǴ DZȊ ǼǴ ȀǻǽDzǺǷ ǼǯǸȁǷ Ǽǯ ǾǴǿǴȆǷȀǺǴǼǼȊȄ DZȊȇǴ ȀǯǸȁǯȄ ǾǽǵǯǺȂǸ Ȁȁǯ ǼǯǾǿǯDZǺȎǸȁǴ DZ Microsoft Press Ǿǽ ȌǺǴǹȁǿǽǼǼǽǸ ǾǽȆȁǴ
[email protected] ǷǺǷ Ǿǽ ǾǽȆȁǴ: Microsoft Press Attn: Introducing Microsoft Silverlight 2 Editor One Microsoft Way Redmond, WA 98052-6399 ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ Ǿǽ ȂǹǯǶǯǼǼȊǻ ǯdzǿǴȀǯǻ ǼǴ ǾǿǴdzǽȀȁǯDZǺȎǴȁȀȎ ǾǽdzdzǴǿǵǹǯ ǾǿǽDzǿǯǻǻǼȊȄ ǾǿǽdzȂǹ ȁǽDZ Microsoft.
ǝǰ ǯDZȁǽǿǴ ǚǽȂǿǴǼȀ ǛǽǿǽǼǷ (Laurence Moroney) ȎDZǺȎǴȁȀȎ ǑǴdzȂȈǷǻ ȌǹȀǾǴǿȁǽǻ Ǿǽ ȁǴȄǼǽǺǽDzǷȎǻ Microsoft, ȀǾǴȅǷǯǺǷǶǷǿȂȍȈǷǻȀȎ Ǽǯ Silverlight Ƿ User Experience. ǗǻǴǴȁ ǰǽǺǴǴ ȆǴǻ dzǴ ȀȎȁǷǺǴȁǼǷǸ ǽǾȊȁ ǿǯǶǿǯǰǽȁǹǷ Ƿ ǿǴǯǺǷǶǯȅǷǷ ǾǿǽDzǿǯǻǻǼǽDzǽ ǽǰǴȀǾǴȆǴǼǷȎ Ƿ ȎDZǺȎǴȁȀȎ ǯDZȁǽǿǽǻ ǽǹǽǺǽ dzǴȀȎȁǹǯ ǹǼǷDz Ǿǽ ǿǯǶǼǽǽǰǿǯǶǼǴǸȇǷǻ ȁǴǻǯȁǷǹǯǻ ȀǿǴdzǷ ǹǽȁǽǿȊȄ Windows Presentation Foundation, ǑǴǰ-ǿǯǶǿǯǰǽȁǹǯ, ǰǴǶǽǾǯȀǼǽȀȁȋ Ƿ ȀǾǽȀǽǰǼǽȀȁȋ ǹ DZǶǯǷǻǽ dzǴǸȀȁDZǷȍ. ǙǿǽǻǴ ȁǽDzǽ Ƿǻ ǼǯǾǷȀǯǼǽ ǰǽǺǴǴ ȀȁǯȁǴǸ dzǺȎ ǿǯǶǺǷȆǼȊȄ ǾǴȆǯȁǼȊȄ Ƿ ǽǼ ǺǯǸǼ ǷǶdzǯǼǷǸ Ƿ ȀdzǴǺǯǼǽ ǻǼǽǵǴȀȁDZǽ dzǽǹǺǯdzǽDZ Ǿǽ ȌȁǷǻ ȁǴǻǯǻ Ǽǯ ǻǼǽDzǷȄ ǹǽǼȃǴǿǴǼȅǷȎȄ Ǿǽ DZȀǴǻȂ ǻǷǿȂ ǙǽDzdzǯ ǼǴ ǶǯǼȎȁ Silverlight ǷǺǷ ǼǯǾǷȀǯǼǷǴǻ ǹǼǷDz ǽǼ ǾǽdzǿǯǰǯȁȊDZǯǴȁ ȀǾǽǿȁǷDZǼȊǻ ǽǰǽǶǿǴ DZǯȁǴǺǴǻ dzǺȎ ǑȊȀȇǴǸ ȃȂȁǰǽǺȋǼǽǸ ǺǷDzǷ ǼǯȅǷǽǼǯǺȋǼȊȄ ǻȂǵȀǹǽǸ Ƿ ǵǴǼȀǹǽǸ ȀǰǽǿǼȊȄ ǠǧǏ Ƿ ǼǽDZǽDzǽ ǣǙ Seattle Sounders ǚǽȂǿǴǼȀ ǵǷDZǴȁ Ȁǽ ȀDZǽǴǸ ǵǴǼǽǸ ǟǴǰǴǹǹǽǸ Ƿ dzDZȂǻȎ dzǴȁȋǻǷ DZ ǠǯǻǻǯǻǷȇ Sammamish), ȇȁǯȁ ǑǯȇǷǼDzȁǽǼ
ʧ̣̌̏̌ 1
ǑDZǴdzǴǼǷǴ DZ Silverlight 2 Silverlight ȎDZǺȎǴȁȀȎ ȀǺǴdzȂȍȈǷǻ ȇǯDzǽǻ DZ ǼǯǾǿǯDZǺǴǼǷǷ ǹ ȂǺȂȆȇǴǼǷȍ DZǶǯǷǻǽdzǴǸȀȁDZǷȎ Ȁ ǾǽǺȋǶǽDZǯȁǴǺǴǻ ȆǴǿǴǶ ǑǴǰ ǥǴǺȋ Silverlight ² ǽǰǴȀǾǴȆǷȁȋ DZ ǑǴǰ-ǾǿǷǺǽǵǴǼǷȎȄ ȁǽȆǼǽȀȁȋ ǽȁǽǰǿǯǵǴǼǷȎ Ƿ ǹǯȆǴȀȁDZǽ ǾǽǺȋǶǽ DZǯȁǴǺȋȀǹǽDzǽ ǷǼȁǴǿȃǴǸȀǯ (user interface, UI) dzǽȀȁȂǾǼǽǴ DZ ǼǯȀȁǽǺȋǼȊȄ ǾǿǷǺǽǵǴǼǷȎȄ ǾǽǶDZǽǺȎȎ ǑǴǰǿǯǶǿǯǰǽȁȆǷǹǯǻ Ƿ dzǷǶǯǸǼǴǿǯǻ ǿǴǯǺǷǶǽDZȊDZǯȁȋ DZ ȀǽǶdzǯDZǯǴǻȊȄ ǿǴȇǴǼǷȎȄ ǽȀǽǰȊǴ ȁǿǴǰǽDZǯǼǷȎ ǶǯǹǯǶȆǷǹǽDZ Silverlight ǶǯǾǽǺǼȎǴȁ ȁǴȄǼǽǺǽDzǷȆǴȀǹǷǸ DZǯǹȂȂǻ ǻǴǵdzȂ dzǷǶǯǸǼǴǿǯǻ Ƿ ǿǯǶǿǯǰǽȁȆǷǹǯǻ, ǾǿǴdzǽȀȁǯDZǺȎȎ Ƿǻ ǽǰȈǷǸ ȃǽǿǻǯȁ dzǺȎ ǿǯǰǽȁȊ Ǭȁǽȁ ȃǽǿǻǯȁ ǽǰǿǯǰǯȁȊDZǯǴȁȀȎ ǰǿǯȂǶǴǿǽǻ Ƿ ǽȀǼǽDZȊDZǯǴȁȀȎ Ǽǯ XML Ȇȁǽ ȂǾǿǽ ȈǯǴȁ ȀǽǶdzǯǼǷǴ ȇǯǰǺǽǼǽDZ Ƿ ǯDZȁǽǻǯȁǷȆǴȀǹǽǴ ȃǽǿǻǷǿǽDZǯǼǷǴ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ǡǯǹǷǻ ȃǽǿǻǯȁǽǻ ȎDZǺȎǴȁȀȎ XAML ² Extensible Application Markup Language ǿǯȀȇǷǿȎǴǻȊǸ ȎǶȊǹ ǿǯǶǻǴȁǹǷ ǾǿǷǺǽǵǴǼǷǸ Ǔǽ ǾǽȎDZǺǴǼǷȎ XAML dzǷǶǯǸǼǴǿ ǑǴǰ-ǾǿǷǺǽǵǴǼǷǸ ȀǽǶdzǯDZǯǺ dzǷǶǯǸǼ ǷȀǾǽǺȋǶȂȎ ǹǯǹǽǸ-ȁǽ ǽǾǿǴdzǴǺǴǼǼȊǸ Ǽǯǰǽǿ ǷǼȀȁǿȂǻǴǼȁǽDZ Ƿ Ȅǽǿǽȇǽ ǶǼǯǹǽǻȂȍ ǴǻȂ ȁǴȄǼǽǺǽDzǷȍ ǖǯȁǴǻ ǿǯǶǿǯǰǽȁȆǷǹ ǰǿǯǺ ȁǽ Ȇȁǽ ȀdzǴǺǯǺ dzǷ ǶǯǸǼǴǿ Ƿ ǷǼȁǴǿǾǿǴȁǷǿǽDZǯǺ Ȍȁǽ Ȁ ǾǽǻǽȈȋȍ dzǿȂDzǽǸ ȁǴȄǼǽǺǽDzǷǷ Ǿǽ ȀDZǽǴǻȂ DZȊǰǽǿȂ ǡǿǯǼȀȃǽǿǻǷǿǽDZǯȁȋ ȁǽ Ȇȁǽ ǰȊǺǽ ȀǽǶdzǯǼǽ dzǷǶǯǸǼǴǿǽǻ ǰǴǶ ǾǿǽǰǺǴǻ Ƿ ǾǿǯDZǷǺȋǼǽ ǾǽǺȂȆǯǺǽȀȋ ǼǴ DZȀǴDzdzǯ Ƿ ǿǯǶǿǯǰǽȁȆǷǹǯǻ ǾǿǷȄǽdzǷǺǽȀȋ DZǼǽȀǷȁȋ ǻǼǽǵǴȀȁDZǽ ǷǶǻǴǼǴǼǷǸ ǹǽȁǽǿȊǴ ǾǽdzȆǯȀ ǼǯǿȂȇǯǺǷ dzǷǶǯǸǼ. Ǡ Silverlight dzǷǶǯǸǼǴǿ ǻǽǵǴȁ Ȁ ǾǽǻǽȈȋȍ ǽǾǿǴdzǴǺǴǼǼȊȄ ǷǼȀȁǿȂǻǴǼȁǽDZ ǷǶǽǰǿǯǶǷȁȋ dzǷǶǯǸǼ DZ DZǷdzǴ XAML ǾǴǿǴdzǯȁȋ Ȍȁǽȁ ;$0/ ǿǯǶǿǯǰǽȁȆǷǹȂ ǹǽȁǽǿȊǸ, DZ ȀDZǽȍ ǽȆǴǿǴdzȋ, ǻǽǵǴȁ ǼǯǾǽǺǼǷȁȋ ǴDzǽ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁȋȍ ǾǿǷ ǾǽǻǽȈǷ ǹǽdzǯ Ƿ ǿǯǶDZǴǿǼȂȁȋ Microsoft Silverlight ² Ȍȁǽ ǾǽdzǹǺȍȆǯǴǻȊǸ ǻǽdzȂǺȋ ǹǽȁǽǿȊǸ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ DZ ǿǯǶǼȊȄ ǰǿǯȂǶǴǿǯȄ Ƿ Ǽǯ ǿǯǶǼȊȄ ǾǺǯȁȃǽǿǻǯȄ ǿǯǶǿǯǰǽȁǯǼǼȊǸ dzǺȎ ǽǰǴȀǾǴȆǴǼǷȎ DZǽǶǻǽǵǼǽȀȁǷ ȀǽǶdzǯǼǷȎ ȀǺǽǵǼȊȄ ȀȅǴǼǯǿǷǴDZ DZǽȀǾǿǽǷǶDZǴdzǴǼǷȎ ǻȂǺȋȁǷǻǴdzǷǯ Ƿ ȀǽǶdzǯǼǷȎ ǼǯȀȊȈǴǼǼȊȄ ǷǼȁǴǿǯǹȁǷDZǼȊȄ ǗǼȁǴǿǼǴȁ-ǾǿǷǺǽǵǴǼǷǸ Ȁ ǷȀ ǾǽǺȋǶǽDZǯǼǷǴǻ ȀǽDZǿǴǻǴǼǼȊȄ ȁǴȄǼǽǺǽDzǷǸ ǝǼ ǾǿǴdzǺǯDzǯǴȁ ǶǯDZǴǿȇǴǼǼȂȍ ǻǽdzǴǺȋ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ ǹǽ ȁǽǿǯȎ ǾǽdzdzǴǿǵǷDZǯǴȁ AJAX, .NET Ƿ ȁǯǹǷǴ dzǷǼǯǻǷȆǴȀǹǷǴ ȎǶȊǹǷ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ ǹǯǹ 3\WKRQ Ƿ 5XE\ ǑǽǶǻǽǵǼǽȀȁȋ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ DZ 6LOYHUOLJKW ǽǰǴȀǾǴȆǷDZǯǺǯȀȋ ǾǽdzdzǴǿǵǹǽǸ ȀȂȈǴȀȁDZȂȍȈǷȄ ǑǴǰȁǴȄǼǽǺǽDzǷǸ DZǹǺȍȆǯȎ $-$; -DYD6FULSW Ƿ '+70/ Ǒ 6LOYHUOLJKW dzǽǰǯDZǺȎǴȁȀȎ ǾǽdzdzǴǿǵǹǯ dzǷǼǯǻǷȆǴȀǹǷȄ ȎǶȊǹǽDZ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ Ƿ ȎǶȊǹǽDZ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ 1(7 ǯ ȁǯǹǵǴ ǾǽȎDZǺȎȍȁȀȎ ǼǽDZȊǴ DZǽǶǻǽǵǼǽ ȀȁǷ dzǽȀȁȂǾǼȊǴ ȁǽǺȋǹǽ ǾǿǷ ǷȀǾǽǺȋǶǽDZǯǼǷǷ 1(7 )UDPHZRUN ȁǯǹǷǴ ǹǯǹ ǗǶǽǺǷǿǽDZǯǼǼǽǴ ȄǿǯǼǷǺǷȈǴ (Isolated Storage), ǟǯǰǽȁǯ Ȁ ȀǴȁȋȍ (Networking), ǽǰȇǷǿǼȊǸ Ǽǯǰǽǿ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ Ƿ ȁdz. Ǒ ǾǴǿDZǽǸ ȆǯȀȁǷ dzǯǼǼǽǸ ǹǼǷDzǷ ǾǿǴdzȀȁǯDZǺǴǼȊ ǽȀǼǽDZȊ Silverlight Ƿ ǾǿǴdzǺǯDzǯǴǻȊǴ ǷǼȀȁǿȂǻǴǼȁȊ dzǺȎ dzǷ ǶǯǸǼǯ Ƿ ǿǯǶǿǯǰǽȁǹǷ ǑȁǽǿǯȎ ȆǯȀȁȋ ǹǼǷDzǷ ǾǽȀDZȎȈǴǼǯ ǰǽǺǴǴ dzǴȁǯǺȋǼǽǻȂ ǿǯȀȀǻǽȁǿǴǼǷȍ ǻǽdzǴǺǷ ǾǿǽDzǿǯǻ ǻǷǿǽDZǯǼǷȎ
Silverlight Ƿ DZǶǯǷǻǽdzǴǸȀȁDZǷǴ Ȁ ǾǽǺȋǶǽDZǯȁǴǺǴǻ Silverlight ȀǽǶdzǯǼ ǹǯǹ ȆǯȀȁȋ ǽDzǿǽǻǼǽǸ ȌǹǽȀǷȀȁǴǻȊ ǷȀǾǽǺȋǶȂǴǻǽǸ dzǺȎ ǽǰǴȀǾǴȆǴǼǷȎ ǼǯǷǺȂȆȇǴDzǽ DZǶǯǷǻǽ dzǴǸȀȁDZǷȎ Ȁ ǹǽǼǴȆǼȊǻ ǾǽǺȋǶǽDZǯȁǴǺǴǻ ǠȂȈǴȀȁDZȂǴȁ ǿȎdz ȁǷǾǽDZȊȄ ȀȅǴǼǯǿǷǴDZ dzǽȀȁȂǾǯ ǹ ǷǼȃǽǿǻǯȅǷǷ ȆǴǿǴǶ ǗǼȁǴǿǼǴȁ x
ǞǽȀǿǴdzȀȁDZǽǻ ǻǽǰǷǺȋǼȊȄ ȂȀȁǿǽǸȀȁDZ
x
ǞǽȀǿǴdzȀȁDZǽǻ ǾǿǽdzȂǹȁǽDZ ȁǷǾǯ ©ǥǷȃǿǽDZǽǸ dzǽǻª
x
ǞǽȀǿǴdzȀȁDZǽǻ ǼǴǿǯȀȇǷǿȎǴǻȊȄ ǰǿǯȂǶǴǿǽDZ ǰǴǶ ǾǽdzǹǺȍȆǯǴǻȊȄ ǻǽdzȂǺǴǸ
x
ǞǽȀǿǴdzȀȁDZǽǻ ǿǯȀȇǷǿȎǴǻȊȄ ǰǿǯȂǶǴǿǽDZ ǷȀǾǽǺȋǶȂȍȈǷǴ ȁǯǹǷǴ ǾǽdzǹǺȍȆǯǴǻȊǴ ǻǽdzȂǺǷ ǹǯǹ Flash, Java ǷǺǷ Silverlight)
x
ǞǽȀǿǴdzȀȁDZǽǻ ǼǯȀȁǽǺȋǼȊȄ ǾǿǷǺǽǵǴǼǷǸ
x
ǞǽȀǿǴdzȀȁDZǽǻ ǽȃǷȀǼȊȄ ǾǿǽDzǿǯǻǻ
Ǡ DzǽdzǯǻǷ ǽǵǷdzǯǼǷȎ ǾǽǺȋǶǽDZǯȁǴǺǴǸ ǽȁǼǽȀǷȁǴǺȋǼǽ ȁǽDzǽ ǹǯǹ dzǽǺǵǼȊ ǿǯǰǽȁǯȁȋ ȌȁǷ ǾǿǷǺǽǵǴǼǷȎ ǷǶǻǴǼǷ ǺǷȀȋ ǜǯǾǿǷǻǴǿ ǽǵǷdzǯǼǷǴ Ȇȁǽ ǾǿǷǺǽǵǴǼǷǴ Ǽǯ ǼǯȀȁǽǺȋǼǽǻ ǹǽǻǾȋȍȁǴǿǴ dzǽǺǵǼǽ ǰȊȁȋ ǰǽǺǴǴ ȃȂǼǹȅǷǽ
ǒǺǯDZǯ ǑDZǴdzǴǼǷǴ DZ 6LOYHUOLJKW 2
17
ǼǯǺȋǼȊǻ ȆǴǻ ǾǿǷǺǽǵǴǼǷǴ ȁǽDzǽ ǵǴ ȁǷǾǯ DZ ǻǽǰǷǺȋǼǽǻ ȂȀȁǿǽǸȀȁDZǴ ǛȊ ǹǯǹ ǾǽǺȋǶǽDZǯȁǴǺǷ ǾǿǷDZȊǹǺǷ ǹ ǼǯǻǼǽDzǽ ǰǽǺȋȇǷǻ DZǽǶǻǽǵǼǽȀȁȎǻ ǼǯȀȁǽǺȋǼȊȄ ȂȀȁǿǽǸȀȁDZ Ǿǽ ȀǿǯDZǼǴǼǷȍ Ȁ ǻǽǰǷǺȋǼȊǻǷ ǙǿǽǻǴ ȁǽDzǽ ǻǼǽDzǷǴ ȀȆǷȁǯȍȁ Ȇȁǽ ©ȁǯǹ ǹǯǹ ǾǿǷǺǽǵǴǼǷǴ ǿǯǶDZǴǿǼȂȁǽ DZ ǑǴǰª, ǽǼǽ ǻǽǵǴȁ ǼǴ ǽǰǺǯdzǯȁȋ ȁǴǻǷ DZǽǶǻǽǵǼǽ ȀȁȎǻǷ, ǹǽȁǽǿȊǴ ǾǿǴdzǺǯDzǯǴȁ ǯǼǯǺǽDzǷȆǼǽǴ ǼǯȀȁǽǺȋǼǽǴ ǾǿǷǺǽǵǴǼǷǴ ǜǯǾǿǷǻǴǿ ǾǽǺȋǶǽDZǯȁǴǺȋ ǾǿǴdzȉȎDZǺȎ Ǵȁ ǻǴǼȋȇǷǴ ȁǿǴǰǽDZǯǼǷȎ ǹ ǾǽȆȁǽDZǽǻȂ ǑǴǰ-ǾǿǷǺǽǵǴǼǷȍ ǾǽȁǽǻȂ Ȇȁǽ ǼǴ DZǴǿǷȁ Ȇȁǽ ǽǼǽ ǻǽǵǴȁ ǾǿǴdzǺǯ Dzǯȁȋ ȁǴ ǵǴ DZǽǶǻǽǵǼǽȀȁǷ ǿǯǰǽȁȊ Ȁ ȌǺǴǹȁǿǽǼǼǽǸ ǾǽȆȁǽǸ Ȇȁǽ Ƿ ǽȃǷȀǼȊǴ ǾǿǽDzǿǯǻǻȊ ȁǯǹǷǴ ǹǯǹ ǽǰǴȀǾǴȆǷ DZǯǴȁ Microsoft Office Outlook. ǝdzǼǯǹǽ Ǿǽ ǻǴǿǴ ȀǰǺǷǵǴǼǷȎ ȌȁǷȄ ǾǺǯȁȃǽǿǻ ǽǵǷdzǯǼǷȎ ǾǽǺȋǶǽDZǯȁǴǺȎ ǿǯȀȁȂȁ Ƿ ȁǴǾǴǿȋ dzǺȎ ǽǾǷȀǯǼǷȎ DZǽǶ ǻǽǵǼǽȀȁǴǸ ǾǿǴDZȊȇǯȍȈǷȄ ȁǴǹȂȈǷǸ ǰǯǶǽDZȊǸ ȂǿǽDZǴǼȋ ǽǵǷdzǯǼǷǸ ȇǷǿǽǹǽ ǷȀǾǽǺȋǶȂǴȁȀȎ ȁǴǿǻǷǼ ǼǯȀȊ ȈǴǼǼȊǸ (rich). ǜǯǾǿǷǻǴǿ ǾǽǼȎȁǷǴ ©ǼǯȀȊȈǴǼǼǽǴ ǗǼȁǴǿǼǴȁ-ǾǿǷǺǽǵǴǼǷǴª ǾǽȎDZǷǺǽȀȋ DZ ǽȁDZǴȁ Ǽǯ ǾǽDZȊ ȇǴǼǷǴ ȂǿǽDZǼȎ ȀǺǽǵǼǽȀȁǷ ǾǿǷǺǽǵǴǼǷǸ Ȁ ǾǽdzdzǴǿǵǹǽǸ AJAX dzǺȎ ǽǰǴȀǾǴȆǴǼǷȎ ǰǽǺǴǴ ȇǷǿǽǹǷȄ dzǷǼǯǻǷȆǴ ȀǹǷȄ DZǽǶǻǽǵǼǽȀȁǴǸ DZ ȁǯǹǷȄ ȀȅǴǼǯǿǷȎȄ ǹǯǹ ǿǯǰǽȁǯ Ȁ ȌǺǴǹȁǿǽǼǼǽǸ ǾǽȆȁǽǸ Ƿ ǹǯǿȁǽDzǿǯȃǷȆǴȀǹǷǻǷ ȀǷȀȁǴ ǻǯǻǷ ǬDZǽǺȍȅǷȎ ǽǵǷdzǯǼǷǸ ǾǿǷDZǴǺǯ ǹ ǾǽȎDZǺǴǼǷȍ ǾǽǺȋǶǽDZǯȁǴǺǴǸ ǹǽȁǽǿȊǴ ȄǽȁȎȁ ǾǽǺȂȆǯȁȋ ȀǯǻȊǴ ȇǷ ǿǽǹǷǴ DZǽǶǻǽǵǼǽȀȁǷ ǽȁDZǴȆǯȍȈǷǴ ǼǴ ȁǽǺȋǹǽ ȁǿǴǰǽDZǯǼǷȎǻ Ȁ ȁǽȆǹǷ ǶǿǴǼǷȎ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁǷ Ƿ ȌȃȃǴǹ ȁǷDZǼǽȀȁǷ ǾǿǷǺǽǵǴǼǷȎ Ǽǽ ȁǯǹǵǴ ǽǰǴȀǾǴȆǷDZǯȍȈǷǴ ȆȂDZȀȁDZǽ ȂdzǽDZǺǴȁDZǽǿǴǼǼǽȀȁǷ ǾǿǽdzȂǹȁǯǻǷ Ƿ ȀǺȂǵǰǯǻǷ ǹǽǻǾǯǼǷǷ Ȇȁǽ ǻǽǵǴȁ ȀǺȂǵǷȁȋ ǽȀǼǽDZǼǽǸ dzǺȎ ȂȀȁǯǼǽDZǺǴǼǷȎ dzǺǷȁǴǺȋǼȊȄ ǽȁǼǽȇǴǼǷǸ ǻǴǵdzȂ ǾǽǺȋǶǽDZǯȁǴ ǺǴǻ Ƿ ǹǽǻǾǯǼǷǴǸ Ǒ ǿǴǶȂǺȋȁǯȁǴ Microsoft ǼǯǾǿǯDZǷǺǯ ȀDZǽǷ ǿǴȀȂǿȀȊ Ǽǯ ǑǶǯǷǻǽdzǴǸȀȁDZǷǴ Ȁ ǾǽǺȋǶǽDZǯȁǴǺǴǻ User Experience, UX) Ƿ ǾǽȀȁǯDZǺȎǴȁ ǷǼȀȁǿȂǻǴǼȁȊ Ƿ ȁǴȄǼǽǺǽDzǷǷ ǹǽȁǽǿȊǴ ǿǯǶǿǯǰǽȁȆǷǹǷ ǻǽDzȂȁ ǷȀǾǽǺȋǶǽDZǯȁȋ dzǺȎ ǿǴǯǺǷǶǯȅǷǷ UX ǼǯȀȊȈǴǼǼȊȄ ǾǿǷǺǽǵǴǼǷǸ ǙǿǽǻǴ ȁǽDzǽ DZȀǴ ȌȁǷ ȀǿǴdzȀȁDZǯ ȀǽDzǺǯȀǽDZǯǼȊ ȁǴ ǼǯDZȊǹǷ ǿǯǶǿǯǰǽȁǹǷ UXǽǿǷǴǼȁǷǿǽDZǯǼǼȊȄ ǾǿǷǺǽǵǴǼǷǸ ǰȂdzȂȁ ǾǿǷǻǴǼǷǻȊ DZǽ DZȀǴȄ ǽǰǺǯȀȁȎȄ ǿǯǶǿǯǰǽȁǹǷ ǼǯȀȁǽǺȋǼȊȄ Ƿ ǑǴǰǾǿǷǺǽǵǴǼǷǸ Ǘȁǯǹ ǴȀǺǷ ȁǿǴǰȂǴȁȀȎ ȀǽǶdzǯȁȋ ǑǴǰ-DZǴǿȀǷȍ ǼǯȀȊȈǴǼǼǽDzǽ ǼǯȀȁǽǺȋǼǽDzǽ ǾǿǷǺǽǵǴǼǷȎ, ǼǴȁ ǼǴǽǰ ȄǽdzǷǻǽȀȁǷ ǽȀDZǯǷDZǯȁȋ ǼǽDZȊǴ ǷǼȀȁǿȂǻǴǼȁȊ Ƿ ȁǴȄǼǽǺǽDzǷǷ ǏǼǯǺǽDzǷȆǼǽ ǴȀǺǷ ȀǽǶdzǯǴȁȀȎ ǻǽǰǷǺȋǼǽǴ ǾǿǷǺǽ ǵǴǼǷǴ Ƿ ȁǿǴǰȂǴȁȀȎ ǗǼȁǴǿǼǴȁ-DZǴǿȀǷȎ ǼǴȁ ǼǴǽǰȄǽdzǷǻǽȀȁǷ ǷǻǴȁȋ dzDZǯ Ǽǯǰǽǿǯ ǼǯDZȊǹǽDZ dzDZǯ Ǽǯǰǽǿǯ ǷǼȀȁǿȂ ǻǴǼȁǽDZ Ƿ dzDZǯ DzǿȂǾǾȊ ǿǯǶǿǯǰǽȁȆǷǹǽDZ ǜǯ ǿǷȀ 1- ǾǽǹǯǶǯǼȊ dzǽȀȁȂǾǼȊǴ Ǽǯ ȀǴDzǽdzǼȎȇǼǷǸ dzǴǼȋ ǻǽdzǴǺǷ ȃǽǿǻǷǿǽDZǯǼǷȎ ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ Ǿǿǽ DzǿǯǻǻǷǿǽDZǯǼǷȎ Ȁ ǽǿǷǴǼȁǷǿǽDZǯǼǷǴǻ Ǽǯ ǑǴǰ Ǚǯǹ ǻǽǵǼǽ DZǷdzǴȁȋ ȁǷǾǽDZȊǻǷ ȁǴȄǼǽǺǽDzǷȎǻǷ ǿǯǶǿǯǰǽȁǹǷ ǑǴǰ-ǾǿǷǺǽǵǴǼǷǸ ȎDZǺȎȍȁȀȎ CSS/DHTML DZ ǻǽdzǴǺǷ ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ JavaScript/AJAX/ASP.NET DZ ǻǽdzǴǺǷ ǿǯǶǿǯǰǽȁǹǷ ǓǺȎ ǼǯȀȁǽǺȋǼȊȄ ǾǿǷǺǽǵǴǼǷǸ ȀǽǶdzǯDZǯǴǻȊȄ Ǽǯ .NET Framework [ ;$0/ ǽǰǴȀǾǴȆǷDZǯǴȁ ǻǽ dzǴǺȋ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ǯ ǻǽdzǴǺȋ ǿǯǶǿǯǰǽȁǹǷ ǽǰǴȀǾǴȆǷDZǯǴȁȀȎ ȀǯǻǽǸ ȀǿǴdzǽǸ .NET ǜǯ ǾǴǿǴȀǴȆǴǼǷǷ ȌȁǷȄ ȁǴȄǼǽǺǽDzǷǸ ² ǰǿǯȂǶǴǿ Ȁ ǾǽdzdzǴǿǵǹǽǸ Silverlight ǽǰǴȀǾǴȆǷDZǯȍȈǷǸ ǽǰȉǴdzǷǼǴǼǷǴ ©ǺȂȆȇǴDzǽ ǷǶ ǽǰǽǷȄ ǻǷ ǿǽDZª
ǟǗǠ 1 1 ʺ̨̛̖̣̔ ̨̨̛̛̪̬̬̥̥̬̦̐̌̏̌́ ̛ ̛̪̬̖̭̯̣̖̦̔̌̏́ ̣̔́ ʦ̖̍.
ǡǷǾǽDZǽǴ ǼǯȀȊȈǴǼǼǽǴ ǷǼȁǴǿǯǹȁǷDZǼǽǴ ǾǿǷǺǽǵǴǼǷǴ ǽȀǼǽDZȊDZǯǴȁȀȎ Ǽǯ ȁǴȄǼǽǺǽDzǷȎȄ ǿǯȀǾǽǺǯDzǯȍȈǷȄȀȎ DZ ǹǯȁǴDzǽǿǷǷ ©ǼǴǿǯȀȇǷǿȎǴǻȊǸ ǰǿǯȂǶǴǿª ǡǷǾǽDZǽǴ ǼǯȀȁǽǺȋǼǽǴ ǾǿǷǺǽǵǴǼǷǴ ǼǯȄǽdzǷȁȀȎ DZ dzǿȂDzǽǸ ȆǯȀȁǷ dzǷǯ ǾǯǶǽǼǯ dzǺȎ ǴDzǽ ȀǽǶdzǯǼǷȎ ǷȀǾǽǺȋǶȂȍȁȀȎ ȀǽDZǴǿȇǴǼǼǽ dzǿȂDzǷǴ ȁǴȄǼǽǺǽDzǷǷ ǝǰȉǴdzǷǼǷȁȋ ȌȁǷ ǾǿǷǺǽǵǴǼǷȎ DZ ǾǽǺǼǽȃȂǼǹȅǷǽǼǯǺȋǼǽǴ ǺǴDzǹǽDZǴȀǼǽǴ ǾǿǷǺǽǵǴǼǷǴ DZȊǾǽǺǼȎȍȈǴǴȀȎ DZ ǰǿǯȂǶǴǿǴ ǾǽǶDZǽǺȎǴȁ ǰǿǯȂǶǴǿ Ȁ
18
ʦ̛̖̖̦̖̏̔ ̏ Silverlight 2
ǾǽdzdzǴǿǵǹǽǸ Silverlight ǽǰǴȀǾǴȆǷDZǯȍȈǷǸ ǻǽdzǴǺȋ dzǷǶǯǸǼǯ CSS/DHTML Ƿ XAML Ƿ ǻǽdzǴǺȋ ǾǿǽDzǿǯǻǻǷǿǽ DZǯǼǷȎ JavaScript/AJAX/.NET Framework. Silverlight dzǽȀȁǷDzǯǴȁ ȌȁǽDzǽ Ƕǯ ȀȆǴȁ ǾǿǴdzǽȀȁǯDZǺǴǼǷȎ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ ǿǯȀȇǷǿȎȍȈǴDzǽ ȃȂǼǹȅǷǽ ǼǯǺȋǼǽȀȁȋ ǰǿǯȂǶǴǿǯ ȁǯǹǷǻǷ ȁǷǾǽDZȊǻǷ ȁǴȄǼǽǺǽDzǷȎǻǷ ǼǯȀȊȈǴǼǼȊȄ UI ǹǯǹ ǯǼǷǻǯȅǷȎ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ DZǿǴǻǴǼǼǽǸ ȇǹǯǺȊ DZǴǹȁǽǿǼǯȎ DzǿǯȃǷǹǯ Ƿ ǯȂdzǷǽDZǷǶȂǯǺȋǼȊǴ ǻȂǺȋȁǷǻǴdzǷǯ. Ǭȁǽ DZǽǶǻǽǵǼǽ ǰǺǯDzǽdzǯǿȎ ȀǿǴdzȀȁDZǯǻ ȃǽǿǻǷǿǽDZǯǼǷȎ DZǷǶȂǯǺȋǼǽDzǽ ǾǿǴdzȀȁǯDZǺǴǼǷȎ XAML dzǺȎ ǰǿǯȂǶǴǿǯ ǾǿǴdzǽȀȁǯDZǺȎǴǻȊǻ Silverlight. ǜǯȀȊȈǴǼǼȊǸ UI ǻǽǵǴȁ ȀǽǶdzǯDZǯȁȋȀȎ ǹǯǹ XAML-ǹǽdz Ƿ ǾǽȀǹǽǺȋǹȂ XAML ² ȎǶȊǹ ǽȀǼǽDZǯǼǼȊǸ Ǽǯ XML Ƿ XML ² Ȍȁǽ ǾǿǽȀȁǽ ȁǴǹȀȁ ǾǿǷǺǽǵǴǼǷǴ ȎDZǺȎǴȁȀȎ ȀǽDZǻǴȀȁǷǻȊǻ Ȁ ǰǿǯǼdzǻǯȂȌǿǽǻ Ƿ ǾǽȁǴǼȅǷǯǺȋǼǽ Ȃdzǽǰ ǼȊǻ dzǺȎ ǾǽǷȀǹǽDZǽDzǽ ǻǴȄǯǼǷǶǻǯ ǐǿǯȂǶǴǿ ǾǽǺȂȆǯǴȁ XAML Ƿ DZǷǶȂǯǺǷǶǷǿȂǴȁ ǴDzǽ. Ǒ ȀǽȆǴȁǯǼǷǷ Ȁ ȁǯǹǽǸ ȁǴȄǼǽǺǽDzǷǴǸ ǹǯǹ AJAX Ƿ JavaScript Ȍȁǽ ǻǽǵǴȁ ǰȊȁȋ dzǷǼǯǻǷȆǴȀǹǷǻ ǾǿǽȅǴȀȀǽǻ ǣǿǯDzǻǴǼȁȊ XAML ǻǽǵǼǽ ǶǯDzǿȂǵǯȁȋ Ƿ dzǽǰǯDZǺȎȁȋ DZ UI ǷǺǷ ǻǽǵǼǽ ǿǴdzǯǹȁǷǿǽDZǯȁȋ ǿǴǽǿDzǯǼǷǶǽDZȊDZǯȁȋ ǷǺǷ ȂdzǯǺȎȁȋ XAML ǼǯȄǽdzȎȈǷǸȀȎ DZ dzǯǼǼȊǸ ǻǽǻǴǼȁ DZ dzǴǿǴDZǴ DZǷǶȂǯǺȋǼǽDzǽ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ǷȀǾǽǺȋǶȂȎ ǾǿǽȀȁǽǴ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ Ǽǯ JavaScript.
ǏǿȄǷȁǴǹȁȂǿǯ Silverlight Ǚǯǹ DzǽDZǽǿǷǺǽȀȋ DZȊȇǴ ǽȀǼǽDZǼǯȎ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁȋ Silverlight ǽǰǴȀǾǴȆǷDZǯǴȁȀȎ ǾǽdzǹǺȍȆǯǴǻȊǻ ǻǽdzȂǺǴǻ ǰǿǯȂǶǴǿǯ Ǭȁǽȁ ǻǽdzȂǺȋ ȃǽǿǻǷǿȂǴȁ DZǷǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ XAML Ƿ ǽǰǴȀǾǴȆǷDZǯǴȁ ǻǽdzǴǺȋ ǾǿǽDzǿǯǻ ǻǷǿǽDZǯǼǷȎ ǹǽȁǽǿǯȎ ǻǽǵǴȁ ǽȀǼǽDZȊDZǯȁȋȀȎ ǺǷǰǽ Ǽǯ JavaScript ǺǷǰǽ Ǽǯ NET Framework Ƿ CLR. ǞǽdzdzǴǿǵǷ DZǯȍȈǯȎ Ȍȁǽ ǯǿȄǷȁǴǹȁȂǿǯ ǾǿǴdzȀȁǯDZǺǴǼǯ Ǽǯ ǿǷȀ 1-2. ǝȀǼǽDZǼȊǻ ǻǴȄǯǼǷǶǻǽǻ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ ǾǽDZǴdzǴ ǼǷȎ ǾǿǷǺǽǵǴǼǷȎ 6LOYHUOLJWK DZ ǰǿǯȂǶǴǿǴ ȎDZǺȎǴȁȀȎ -DYD6FULSW '20 $3,. ǝǼ ǾǽǶDZǽǺȎǴȁ ǾǴǿǴȄDZǯȁȊDZǯȁȋ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǷǴ ȀǽǰȊȁǷȎ DZǽǶǼǷǹǯȍȈǷǴ DZ ǾǿǷǺǽǵǴǼǷǷ ȁǯǹǷǴ ǹǯǹ ǾǴǿǴǻǴȈǴǼǷȎ ǻȊȇǷ ǷǺǷ ȈǴǺȆǹǷ ǽǾǿǴdzǴǺǴǼǼǽDzǽ ȌǺǴǻǴǼȁǯ Ƿ DZȊǶȊDZǯȁȋ ǹǽdz ǽǾǿǴdzǴǺȎȍȈǷǸ ǿǴǯǹȅǷȍ Ǽǯ ǼǷȄ Ǡ ǾǽǻǽȈȋȍ ǻǴȁǽdzǽDZ JavaScript DOM ǻǽǵǼǽ ǻǯǼǷǾȂǺǷǿǽDZǯȁȋ ȌǺǴǻǴǼȁǯǻǷ XAML ǼǯǾǿǷǻǴǿ ȂǾǿǯDZǺȎȁȋ DZǽȀǾǿǽǷǶDZǴdzǴǼǷǴǻ ǻȂǺȋ ȁǷǻǴdzǷǯ ǷǺǷ ǯǼǷǻǯȅǷǴǸ. ǓǺȎ ȀǽǶdzǯǼǷȎ ǴȈǴ ǰǽǺǴǴ ǼǯȀȊȈǴǼǼǽDzǽ Ƿ ȃȂǼǹȅǷǽǼǯǺȋǼǽDzǽ ǷǼȁǴǿȃǴǸȀǯ dzǽȀȁȂǾǼȊ DZȀǴ DZǽǶǻǽǵǼǽȀȁǷ .NET Framework CLR. ǞǽǻǷǻǽ ȁǽDzǽ Ȇȁǽ ǻǽǵǼǽ ȀdzǴǺǯȁȋ DZ JavaScript dzǯǼǼǯȎ DZǽǶǻǽǵǼǽȀȁȋ ǾǿǴdzǺǯDzǯǴȁ ǻǼǽǵǴȀȁDZǽ ǾǿǽȀȁǿǯǼȀȁDZ ǷǻǴǼ Ƿ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǾǽȀȁǯDZǺȎǴǻȊȄ ǹǯǹ ȆǯȀȁȋ NET Framework Ȇȁǽ ǾǽǶDZǽǺȎǴȁ dzǴǺǯȁȋ DZǴȈǷ ǹǽȁǽǿȊǴ ǰȊǺǽ ǽȆǴǼȋ ȀǺǽǵǼǽ ǷǺǷ DZǽǽǰȈǴ ǼǴDZǽǶǻǽǵǼǽ ǿǴǯǺǷǶǽDZǯȁȋ DZ JavaScript ǜǯǾǿǷǻǴǿ dzǽȀȁȂǾ ǹ dzǯǼǼȊǻ Ȁ ǾǽǻǽȈȋȍ ADO.NET Ƿ LINQ ǽǰǻǴǼ ǷǼȃǽǿǻǯȅǷǴǸ Ȁ ǑǴǰ-ȀǴǿDZǷȀǯǻǷ ȀǽǶdzǯǼǷǴ Ƿ ǷȀǾǽǺȋǶǽDZǯǼǷǴ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǷȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ Ƿ ȁdz
ǒǺǯDZǯ ǑDZǴdzǴǼǷǴ DZ 6LOYHUOLJKW 2
ǟǗǠ 1 2
19
ǏǿȄǷȁǴǹȁȂǿǯ Silverlight.
ǙǿǽǻǴ ȁǽDzǽ ȀǿǴdzǯ ȃǽǿǻǷǿǽDZǯǼǷȎ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ǾǽȀȁǯDZǺȎǴȁȀȎ DZǻǴȀȁǴ Ȁ ǹǽǻǾǽǼǴǼȁǯǻǷ ǼǴǽǰȄǽdzǷǻȊǻǷ dzǺȎ ǽǰǴȀǾǴȆǴǼǷȎ DZǽǶǻǽǵǼǽȀȁǷ DZǽȀǾǿǽǷǶDZǴdzǴǼǷȎ DZ ǰǿǯȂǶǴǿǴ ȁǯǹǷȄ ȃǯǸǺǽDZ ǹǯǹ WMV, WMA Ƿ MP3, ǰǴǶ DZȀȎǹǷȄ DZǼǴȇǼǷȄ ǶǯDZǷȀǷǻǽȀȁǴǸ ǡǯǹ ǼǯǾǿǷǻǴǿ ǾǽǺȋǶǽDZǯȁǴǺȎǻ Macintosh ǼǴ ǼȂǵǴǼ ǾǿǽǷDzǿȊDZǯȁǴǺȋ Windows Media dzǺȎ DZǽȀǾǿǽǷǶDZǴdzǴǼǷȎ WMV-ȀǽdzǴǿǵǷǻǽDzǽ dzǽȀȁǯȁǽȆǼǽ ǽdzǼǽDzǽ Silverlight. ǝȀǼǽDZǽǸ DZȀǴǸ ȀǿǴdzȊ ȃǽǿǻǷǿǽDZǯǼǷȎ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ȎDZǺȎǴȁȀȎ ǹǽdz ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ ǽǼ ȂǾǿǯDZǺȎǴȁ DZȀǴǻ ǾǿǽȅǴȀȀǽǻ DZǷ ǶȂǯǺǷǶǯȅǷǷ ǑȀǴ Ȍȁǽ DZȀȁǿǽǴǼǽ DZ ǾǽdzǹǺȍȆǯǴǻȊǸ ǻǽdzȂǺȋ ǰǿǯȂǶǴǿǯ ǾǽdzdzǴǿǵǷDZǯȍȈǷǸ ǽȀǼǽDZǼȊǴ ǰǿǯȂǶǴ ǿȊ Windows Ƿ Macintosh. ǜǯ ǿǷȀ 1- ǾǿǴdzȀȁǯDZǺǴǼǯ ǯǿȄǷȁǴǹȁȂǿǯ ǾǿǽȀȁǽDzǽ ǾǿǷǺǽǵǴǼǷȎ DZȊǾǽǺǼȎȍȈǴDzǽȀȎ DZ ǰǿǯȂǶǴǿǴ Ȁ ǷȀǾǽǺȋǶǽ DZǯǼǷǴǻ Silverlight.
ǟǗǠ 1 3 ǏǿȄǷȁǴǹȁȂǿǯ ǾǿǷǺǽǵǴǼǷȎ ǷȀǾǽǺȋǶȂȍȈǴDzǽ Silverlight.
Ǒ ǽȀǼǽDZǴ DZȊǾǽǺǼȎȍȈǴDzǽȀȎ DZ ǰǿǯȂǶǴǿǴ ǾǿǷǺǽǵǴǼǷȎ ǽǰȊȆǼǽ ǺǴǵǷȁ HTML. Ǭȁǯ ǿǯǶǻǴȁǹǯ ȀǽdzǴǿǵǷȁ DZȊǶǽ DZȊ dzǺȎ ȀǽǶdzǯǼǷȎ ȌǹǶǴǻǾǺȎǿǽDZ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ Silverlight ǞǿǷ DZǶǯǷǻǽdzǴǸȀȁDZǷǷ Ȁ ǾǿǷǺǽǵǴǼǷǴǻ Silverlight ǾǽǺȋǶǽDZǯȁǴǺǷ DzǴǼǴǿǷǿȂȍȁ ȀǽǰȊȁǷȎ ǹǽȁǽǿȊǴ ǻǽDzȂȁ ǰȊȁȋ ǽǰǿǯǰǽȁǯǼȊ ȃȂǼǹȅǷȎǻǷ JavaScript ǷǺǷ NET Framework Ǒ ȀDZǽȍ ǽȆǴǿǴdzȋ ǹǽdz ǾǿǽDzǿǯǻǻȊ ǻǽǵǴȁ DZȊǶȊDZǯȁȋ ǻǴȁǽdzȊ ȌǺǴǻǴǼȁǽDZ ȀǽdzǴǿǵǷǻǽDzǽ Silverlight dzǺȎ ȂǾǿǯDZǺǴǼǷȎ ǷǻǷ dzǽǰǯDZǺǴǼǷȎ ǼǽDZǽDzǽ ǷǺǷ ȂdzǯǺǴǼǷȎ ȀȂȈǴȀȁDZȂȍȈǴDzǽ ȀǽdzǴǿǵǷǻǽDzǽ ǜǯǹǽ ǼǴȅ ǾǽdzǹǺȍȆǯǴǻȊǸ ǻǽdzȂǺȋ ǻǽǵǴȁ ȆǷȁǯȁȋ Ƿ ȃǽǿǻǷǿǽDZǯȁȋ DZǷǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ XAML. Ǡǯǻ XAML
20
ʦ̛̖̖̦̖̏̔ ̏ Silverlight 2
ǻǽǵǴȁ ǰȊȁȋ DZȀȁǿǽǴǼ DZ ȀȁǿǯǼǷȅȂ ȀȂȈǴȀȁDZǽDZǯȁȋ ǹǯǹ DZǼǴȇǼǷǸ ȀȁǯȁǷȆǴȀǹǷǸ ȃǯǸǺ ǷǺǷ ǹǯǹ dzǷǼǯǻǷȆǴȀǹǷǸ XAML DZǽǶDZǿǯȈǯǴǻȊǸ ȀǴǿDZǴǿǽǻ
Silverlight Ƿ XAML ǡǴǾǴǿȋ ǾǽǺȂȆǷDZ ǽǰȈǴǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ǽǰ ǯǿȄǷȁǴǹȁȂǿǴ Silverlight Ƿ ǽ ȁǽǻ ǹǯǹ ǰȂdzǴȁ DZȊDzǺȎdzǴȁȋ ȁǷǾǽDZǽǴ ǾǿǷǺǽǵǴǼǷǴ ǽǰǿǯȁǷǻȀȎ ǹ ǽȀǼǽDZǴ UX: XAML. XAML ² Ȍȁǽ ȎǶȊǹ ǿǯǶǻǴȁǹǷ Ǽǯ ǰǯǶǴ XML ǷȀǾǽǺȋǶȂǴǻȊǸ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ DZǷǶȂǯǺȋǼȊȄ ȌǺǴǻǴǼȁǽDZ ǾǿǷǺǽ ǵǴǼǷȎ Ǚ ǼǷǻ ǽȁǼǽȀȎȁȀȎ UI DzǿǯȃǷȆǴȀǹǷǴ ȌǺǴǻǴǼȁȊ ǯǼǷǻǯȅǷǷ ǻȂǺȋȁǷǻǴdzǷǯ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Ƿ Ǿǿ XAML ǰȊǺ ǾǿǴdzȀȁǯDZǺǴǼ Microsoft DZ Windows Presentation Foundation (WPF ǿǯǼǴǴ ǼǯǶȊDZǯǴǻǽǻ Avalon, ǹǽȁǽǿȊǸ ȎDZǺȎǴȁȀȎ ȁǴȄǼǽǺǽDzǷǴǸ ǽǿǷǴǼȁǷǿǽDZǯǼǼǽǸ Ǽǯ DZȊǾǽǺǼǴǼǷǴ Ǽǯ ǹǺǷǴǼȁȀǹǽǻ ǹǽǻǾȋȍȁǴǿǴ, Ƿ ȆǯȀȁȋȍ .NET Framework Ƿ ǾǽȀǺǴdzȂȍȈǷȄ DZǴǿȀǷǸ Ǚǯǹ ǽǰȀȂǵdzǯǺǽȀȋ ǿǯǼǴǴ ǽǼ ǿǯǶǿǯǰǽȁǯǼ Ȁ ȅǴǺȋȍ ǶǯǾǽǺǼǴǼǷȎ ȁǴȄǼǽǺǽDzǷȆǴȀǹǽǸ ǾǿǽǾǯȀȁǷ ǻǴǵdzȂ dzǷǶǯǸǼǴǿǯǻǷ Ƿ ǿǯǶǿǯǰǽȁȆǷǹǯǻǷ ǾǿǷ ȀǽǶdzǯǼǷǷ ǾǿǷǺǽǵǴǼǷǸ XAML ǷȀǾǽǺȋǶȂǴǻȊǸ DZ Silverlight ǽȁǺǷȆǯǴȁȀȎ ǽȁ XAML DZ WPF Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ XAML ² Ȍȁǽ ǾǽdzǻǼǽǵǴ ȀȁDZǽ, ǽǿǷǴǼȁǷǿǽDZǯǼǼǽǴ Ǽǯ DZǽǶǻǽǵǼǽȀȁǷ ǑǴǰ-ǾǿǷǺǽǵǴǼǷǸ. ǡǯǹ Ȇȁǽ ȁǴ, ǹȁǽ ǶǼǯǹǽǻ Ȁ XAML ǷǶ WPF, Ƕǯ ǻǴȁȎȁ ǽȁȀȂȁȀȁDZǷǴ ǼǴǹǽȁǽǿȊȄ ȁǴDzǽDZ Ƿ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁǷ ǼǯǾǿǷǻǴǿ ȌǺǴǻǴǼȁǯ . XAML ǷȀǾǽǺȋǶȂǴȁ XML dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ UI Ȁ ǾǽǻǽȈȋȍ ȌǺǴǻǴǼȁǽDZ XML ǙǽǿǼǴǻ DZȀǴȄ XAML-dzǽǹȂǻǴǼȁǽDZ Silverlight ȎDZǺȎǴȁȀȎ ȌǺǴǻǴǼȁ-ǹǽǼȁǴǸǼǴǿ ȁǯǹǽǸ ǹǯǹ Canvas ǤǽǺȀȁ ǽǾǿǴdzǴǺȎȍȈǷǸ ǽǰǺǯȀȁȋ DZ ǹǽȁǽǿǽǸ ǰȂ dzǴȁ ǽȁǿǷȀǽDZǯǼ DZǯȇ UI. ǞǿǷ ǾǽȀȁǿǽǴǼǷǷ Silverlight-ǾǿǷǺǽǵǴǼǷȎ ǹǽǿǼǴDZǽǸ ȌǺǴǻǴǼȁ Canvas ǰȂdzǴȁ ȀǽdzǴǿ ǵǯȁȋ ǽǰȉȎDZǺǴǼǷȎ ǾǿǽȀȁǿǯǼȀȁDZ ǷǻǴǼ XML ǼǴǽǰȄǽdzǷǻȊȄ Silverlight. ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ XAML-dzǽǹȂǻǴǼȁǯ DZ Silverlight 1.0:
ǛǽǵǼǽ ǶǯǻǴȁǷȁȋ Ȇȁǽ ǽǰȉȎDZǺǴǼȊ dzDZǯ ǾǿǽȀȁǿǯǼȀȁDZǯ ǷǻǴǼ ǡǷǾǽDZǽǸ dzǽǹȂǻǴǼȁ XAML ȀǽdzǴǿǵǷȁ ǰǯǶǽDZȊǸ Ǽǯǰǽǿ ȌǺǴǻǴǼȁǽDZ Ƿ ǯȁǿǷǰȂȁǽDZ Ƿ dzǽǾǽǺǼǷȁǴǺȋǼȊǸ Ǽǯǰǽǿ dzǺȎ ǽǾǷȀǯǼǷȎ ǹǽȁǽǿǽDzǽ ǽǰȊȆǼǽ ǷȀǾǽǺȋǶȂǴȁȀȎ ǾǿǴȃǷǹȀ x:. ǞǿǷǻǴǿǽǻ dzǽǾǽǺǼǷȁǴǺȋǼǽDzǽ ǯȁǿǷǰȂȁǯ ǾǿǽȀȁǿǯǼȀȁDZǯ ǷǻǴǼ ȎDZǺȎǴȁȀȎ ȇǷǿǽǹǽ ǷȀǾǽǺȋǶȂǴǻȊǸ x:Name Ȁ ǾǽǻǽȈȋȍ ǹǽȁǽǿǽDzǽ ǶǯdzǯǴȁȀȎ ǷǻȎ ȌǺǴǻǴǼȁǯ XAML Ȇȁǽ ǾǽǶDZǽǺȎǴȁ ȀȀȊǺǯȁȋȀȎ Ǽǯ ǼǴDzǽ DZ ǹǽdzǴ ǙǽǿǼǴDZǽǸ ȌǺǴǻǴǼȁ Canvas ǽǰȉȎDZǺȎǴȁ ǻǴȀȁǽǾǽǺǽǵǴǼǷǴ ǾǿǽȀȁǿǯǼȀȁDZǯ ǷǻǴǼ DZȀǴȄ ȌǺǴǻǴǼȁǽDZ ǬǺǴǻǴǼȁ Canvas ȎDZǺȎǴȁȀȎ ǹǽǼȁǴǸǼǴǿǽǻ Ǭȁǽ ǽǶǼǯȆǯǴȁ Ȇȁǽ ǽǼ ǻǽǵǴȁ ȀǽdzǴǿǵǯȁȋ dzǿȂDzǷǴ ȌǺǴǻǴǼȁȊ ǹǯǹ dzǽȆǴǿǼǷǴ ǬȁǷ ȌǺǴǻǴǼȁȊ ȁǽǵǴ ǻǽDzȂȁ ǰȊȁȋ ǹǽǼȁǴǸǼǴǿǯǻǷ dzǺȎ dzǿȂDzǷȄ ȌǺǴǻǴǼȁǽDZ ǽǾǿǴdzǴǺȎȎ UI ǹǯǹ dzǴǿǴ DZǽ XML-dzǽǹȂǻǴǼȁǯ ǜǯǾǿǷǻǴǿ ǼǷǵǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǽȀȁǽǸ XAML-dzǽǹȂǻǴǼȁ Ȁ ǿȎdzǽǻ dzǽȆǴǿǼǷȄ ȌǺǴǻǴǼ ȁǽDZ ǼǴǹǽȁǽǿȊǴ ǷǶ ǹǽȁǽǿȊȄ ȀǯǻǷ ȎDZǺȎȍȁȀȎ ǹǽǼȁǴǸǼǴǿǯǻǷ Canvas:
ǖdzǴȀȋ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ȇȁǽ Ȃ ǹǽǿǼǴDZǽDzǽ Canvas ǴȀȁȋ dzDZǯ dzǽȆǴǿǼǷȄ ȌǺǴǻǴǼȁǯ Rectangle Ƿ dzǿȂDzǽǸ Canvas. ǑȁǽǿǽǸ Canvas ȁǯǹǵǴ ȀǽdzǴǿǵǷȁ Rectangle Ƿ Canvas Ƿ DZ ǾǽȀǺǴdzǼǴǻ Canvas ǼǯȄǽdzǷȁȀȎ ǴȈǴ dzDZǯ ȌǺǴǻǴǼȁǯ Rectangle ǡǯǹǯȎ ǷǴǿǯǿȄǷȆǴȀǹǯȎ ȀȁǿȂǹȁȂǿǯ ǾǽǶDZǽǺȎǴȁ ǺǽDzǷȆǴȀǹǷ DzǿȂǾǾǷǿǽDZǯȁȋ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Ƿ ǷȀǾǽǺȋǶǽDZǯȁȋ dzǺȎ ǼǷȄ ǽǰȈȂȍ ǹǽǻǾǽǼǽDZǹȂ Ƿ ǾǽDZǴdzǴǼǷǴ XAML DZ Silverlight ǾǽdzdzǴǿǵǷDZǯǴȁ ǿȎdz ȃǷDzȂǿ ǹǽȁǽǿȊǴ ǻǽǵǼǽ ȀǽȆǴȁǯȁȋ dzǺȎ ǾǽǺȂȆǴǼǷȎ ǰǽǺǴǴ ȀǺǽǵǼȊȄ ǽǰȉǴǹȁǽDZ ǜǯǻǼǽDzǽ ǰǽǺǴǴ ǾǽdzǿǽǰǼǽ ǷȀǾǽǺȋǶǽDZǯǼǷǴ XAML ǿǯȀȀǻǯȁǿǷDZǯǴȁȀȎ DZ ǒǺǯDZǴ 4, ©ǝȀǼǽDZȊ XAMLª ȀǴǸȆǯȀ ǽȀȁǯǼǽDZǷǻȀȎ ǺǷȇȋ Ǽǯ ǽȀǼǽDZǼȊȄ ȃǷDzȂǿǯȄ x
Rectangle ǞǽǶDZǽǺȎǴȁ ǽǾǿǴdzǴǺȎȁȋ Ǽǯ ȌǹǿǯǼǴ ǾǿȎǻǽȂDzǽǺȋǼȂȍ ȃǽǿǻȂ
x
Ellipse ǞǽǶDZǽǺȎǴȁ ǽǾǿǴdzǴǺȎȁȋ ȌǺǺǷǾȀ ǷǺǷ ǹǿȂDz
x
Line
x
Polygon ǝȁǿǷȀǽDZȊDZǯǴȁ ǻǼǽDzǽȂDzǽǺȋǼǷǹ
x
Polyline
x
Path ǞǽǶDZǽǺȎǴȁ ȀǽǶdzǯDZǯȁȋ ǼǴǺǷǼǴǸǼȊǴ ǹǽǼȁȂǿȊ ǼǯǾǿǷǻǴǿ ǹǯǿǯǹȂǺ̛)
ǝȁǿǷȀǽDZȊDZǯǴȁ ǾǿȎǻȂȍ ǺǷǼǷȍ ȀǽǴdzǷǼȎȍȈȂȍ dzDZǴ ȁǽȆǹǷ
ǝȁǿǷȀǽDZȊDZǯǴȁ ǺǽǻǯǼȂȍ ǺǷǼǷȍ
ǞǽǻǷǻǽ ȌȁǽDzǽ XAML ǾǽdzdzǴǿǵǷDZǯǴȁ ǹǷȀȁǷ (brushes ǹǽȁǽǿȊǴ ǽǾǿǴdzǴǺȎȍȁ ǹǯǹ ǽǰȉǴǹȁ ǶǯǹǿǯȇǷDZǯǴȁȀȎ Ǽǯ ȌǹǿǯǼǴ ǑǼȂȁǿǴǼǼȎȎ ǽǰǺǯȀȁȋ ǽǰȉǴǹȁǯ ǶǯǹǿǯȇǷDZǯǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ ǹǷȀȁǷ fill ǯ ǹǽǼȁȂǿ ǽǰȉǴǹȁǯ ǽȁǿǷȀǽ DZȊDZǯǴȁȀȎ ǹǷȀȁȋȍ stroke. ǠȂȈǴȀȁDZȂǴȁ ǻǼǽǵǴȀȁDZǽ ȁǷǾǽDZ ǹǷȀȁǴǸ DZǹǺȍȆǯȎ ǽdzǼǽȅDZǴȁǼȊǴ ǹǷȀȁǷ DzǿǯdzǷǴǼȁ ǼȊǴ ǷǶǽǰǿǯǵǴǼǷȎ Ƿ DZǷdzǴǽ ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ ǷȀǾǽǺȋǶǽDZǯǼǷȎ ǹǷȀȁǷ SolidColorBrush ǝdzǼǽȅDZǴȁǼǯȎ ǹǷȀȁȋ dzǺȎ ǶǯǹǿǯȇǷDZǯǼǷȎ ȌǺ ǺǷǾȀǯ
Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ ǹǷȀȁȋ ǷȀǾǽǺȋǶȂǴȁ ǽdzǷǼ ǷǶ ǾǽdzdzǴǿǵǷDZǯǴǻȊȄ Silverlight ǷǻǴǼǽDZǯǼǼȊȄ ȅDZǴȁǽDZ, Black ȆǴǿǼȊǸ ǡǯǹǵǴ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ȀȁǯǼdzǯǿȁǼǯȎ ȇǴȀȁǼǯdzȅǯȁǴǿǷȆǼǯȎ RGB-ǶǯǾǷȀȋ dzǺȎ ȀǽǶdzǯǼǷȎ ȅDZǴ ȁǽDZ ǖǯǺǷDZǹǷ Ƿ ǽǰDZǽdzǹǷ ȁǯǹǵǴ ǻǽDzȂȁ ǷǻǴȁȋ DzǿǯdzǷǴǼȁǼȂȍ ǶǯǺǷDZǹȂ ǓǺȎ ȌȁǽDzǽ ǷȀǾǽǺȋǶȂǴȁȀȎ DzǿǯdzǷǴǼȁǼǯȎ ǹǷȀȁȋ ǒǿǯdzǷǴǼȁ ǽǾǿǴdzǴǺȎǴȁȀȎ ǿȎdzǽǻ ǹǽǼȁǿǽǺȋǼȊȄ ȁǽȆǴǹ DzǿǯdzǷǴǼȁǯ gradient stops) DZ ǼǽǿǻǷǿǽDZǯǼǼǽǻ Ǿǿǽ ȀȁǿǯǼȀȁDZǴ normalized space). ǡǯǹ ǼǯǾǿǷǻǴǿ ǴȀǺǷ ȁǿǴǰȂǴȁȀȎ ǽǾǿǴdzǴǺǷȁȋ ǺǷǼǴǸǼȊǸ DzǿǯdzǷǴǼȁ DZ ǹǽȁǽǿǽǻ ȅDZǴȁǯ ǰȂdzȂȁ ǷǶǻǴǼȎȁȋȀȎ ȀǺǴDZǯ ǼǯǾǿǯDZǽ ǽȁ ȆǴǿǼǽDzǽ ǹ ǰǴǺǽǻȂ ȆǴǿǴǶ ǽȁȁǴǼǹǷ ȀǴǿǽDzǽ ǼǴǽǰȄǽdzǷǻǽ Ƕǯdzǯȁȋ ȀǽǽȁDZǴȁȀȁDZȂȍȈǷǴ ǹǽǼȁǿǽǺȋǼȊǴ ȁǽȆǹǷ Ǽǯ ǼǽǿǻǷǿǽDZǯǼǼǽǸ ǺǷǼǷǷ Ǒ Ȍȁǽǻ ȀǺȂȆǯǴ ǼǯȆǯǺǽ ǼǽǿǻǷǿǽDZǯǼǼǽǸ ǺǷǼǷǷ ǾǿǷǼǷǻǯǴȁȀȎ Ƕǯ ȁǽȆǹȂ Ƿ ǹǽǼǴȅ ² Ƕǯ ȁǽȆǹȂ ǡǯǹǷǻ ǽǰǿǯǶǽǻ DzǿǯdzǷǴǼȁ ȀǺǴDZǯ ǼǯǾǿǯDZǽ DZ ǽdzǼǽ ǻǴǿǼǽǻ ǾǿǽȀȁǿǯǼȀȁDZǴ ǷǻǴǴȁ dzDZǴ ȁǽȆǹǷ DzǿǯdzǷǴǼȁǯ Ƿ ǔȀǺǷ ǼǴǽǰȄǽdzǷǻǽ ǾǽǺȂȆǷȁȋ DzǿǯdzǷǴǼȁ Ȁ ǾǴǿǴȄǽ dzǯǻǷ ǻǴǵdzȂ ǼǴȀǹǽǺȋǹǷǻǷ ȅDZǴȁǯǻǷ ² ǽȁ ȆǴǿǼǽDzǽ ǹ ǹǿǯȀǼǽǻȂ Ƿ ǶǯȁǴǻ ǹ ǰǴǺǽǻȂ ǼǯǾǿǷǻǴǿ ² ǾǿǷȇǺǽȀȋ ǰȊ Ƕǯdzǯȁȋ ȁǿǴȁȋȍ ȁǽȆǹȂ DzdzǴ-ȁǽ ǻǴǵdzȂ Ƿ ǝdzǼǯǹǽ ȀǺǴdzȂǴȁ ǾǽǻǼǷȁȋ Ȇȁǽ ǾǿǷ ȀǽǶdzǯǼǷǷ ǶǯǺǷDZǹǷ ǻȊ ǿǯ ǰǽȁǯǴǻ DZ dzDZȂǻǴǿǼǽǻ ǾǿǽȀȁǿǯǼȀȁDZǴ ǾǽȌȁǽǻȂ DZǴǿȄǼǷǸ ǺǴDZȊǸ ȂDzǽǺ ǾǿǴdzȀȁǯDZǺȎǴȁ ȁǽȆǹǯ Ƿ ǼǷǵǼǷǸ ǾǿǯDZȊǸ ȂDzǽǺ ǾǿǴdzȀȁǯDZǺȎǴȁ ȁǽȆǹǯ ǡǯǹǷǻ ǽǰǿǯǶǽǻ dzǺȎ ǶǯǺǷDZǹǷ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ Ȁ ǾǽǻǽȈȋȍ DzǿǯdzǷ ǴǼȁǼǽǸ ǹǷȀȁǷ ǷȀǾǽǺȋǶǽDZǯǺǯȀȋ ǰȊ LinearGradientBrush ȀǺǴdzȂȍȈǷǻ ǽǰǿǯǶǽǻ
22
ʦ̛̖̖̦̖̏̔ ̏ Silverlight 2
XAML ȁǯǹǵǴ ǾǽdzdzǴǿǵǷDZǯǴȁ ǽȁǽǰǿǯǵǴǼǷǴ ȁǴǹȀȁǯ ǓǺȎ ȌȁǽDzǽ ǷȀǾǽǺȋǶȂǴȁȀȎ ȌǺǴǻǴǼȁ TextBlock ǡǷǾǽDZȊǴ ȀDZǽǸȀȁDZǯ ȁǴǹȀȁǯ ȁǯǹǷǴ ǹǯǹ ȀǽdzǴǿǵǷǻǽǴ ȁǷǾ ȇǿǷȃȁǯ ǿǯǶǻǴǿ ȇǿǷȃȁǯ ǽǰȁǴǹǯǼǷǴ Ƿ dzǿ ǻǽǵǼǽ ǷǶǻǴǼȎȁȋ ȆǴǿǴǶ ǯȁǿǷǰȂȁȊ Ǒǽȁ ǾǿǽȀȁǽǸ ǾǿǷǻǴǿ: Hello there, how are you?
ǡǿǯǼȀȃǽǿǻǯȅǷȎ ǽǰȉǴǹȁǽDZ DZ XAML ǽȀȂȈǴȀȁDZǺȎǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ ǿȎdzǯ ȁǿǯǼȀȃǽǿǻǯȅǷǸ Ǚ ǼǷǻ ǽȁǼǽȀȎȁȀȎ x
RotateTransform
ǞǽDZǽǿǯȆǷDZǯǴȁ ȌǺǴǻǴǼȁ Ǽǯ ǶǯdzǯǼǼȊǸ ȂDzǽǺ
x
ScaleTransform
ǗȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǷǶǻǴǼǴǼǷȎ ǻǯȀȇȁǯǰǯ ǽǰȉǴǹȁǯ
x
SkewTransform
ǜǯǹǺǽǼȎǴȁ ǽǰȉǴǹȁ DZ ǶǯdzǯǼǼǽǻ ǼǯǾǿǯDZǺǴǼǷǷ Ǽǯ ǶǯdzǯǼǼȊǸ ȂDzǽǺ
x
TranslateTransform
x
MatrixTransform ǗȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ȀǽǶdzǯǼǷȎ ǻǯȁǴǻǯȁǷȆǴȀǹǽDzǽ ǾǿǴǽǰǿǯǶǽDZǯǼǷȎ ǹǽȁǽǿǽǴ ǻǽǵǴȁ ȀǽȆǴ ȁǯȁȋ DZȀǴ DZȊȇǴǾǴǿǴȆǷȀǺǴǼǼǽǴ
ǞǴǿǴǻǴȈǯǴȁ ǽǰȉǴǹȁ DZ ǼǯǾǿǯDZǺǴǼǷǷ ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ ǶǯdzǯǼǼǽǻȂ DZǴǹȁǽǿȂ
ǑǽǶǻǽǵǼǯ DzǿȂǾǾǷǿǽDZǹǯ ȁǿǯǼȀȃǽǿǻǯȅǷǸ ǒǿȂǾǾǷǿȂȎ ȀȂȈǴȀȁDZȂȍȈǷǴ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ǻǽǵǼǽ ȀǽǶdzǯȁȋ ȀǺǽǵǼȂȍ ȁǿǯǼȀȃǽǿǻǯȅǷȍ ǡǽ ǴȀȁȋ ǻǽǵǼǽ ǼǯǾǿǷǻǴǿ ǾǴǿǴǻǴȀȁǷȁȋ ǽǰȉǴǹȁ Ȁ ǾǽǻǽȈȋȍ ȁǿǯǼȀǺȎȅǷǷ ǷǶ ǻǴǼǷȁȋ ǴDzǽ ǿǯǶǻǴǿ Ȁ ǾǽǻǽȈȋȍ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷȎ Ƿ ǾǿǷ Ȍȁǽǻ ǾǽDZǴǿǼȂȁȋ ǴDzǽ ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ DZ ǹǽ ȁǽǿǽǻ DZȊǾǽǺǼȎǴȁȀȎ ǿǯǶDZǽǿǽȁ Ƿ ǷǶǻǴǼǴǼǷǴ ǻǯȀȇȁǯǰǯ ȄǽǺȀȁǯ
ǞǽdzdzǴǿǵǹǯ ǯǼǷǻǯȅǷǷ DZ XAML ǿǴǯǺǷǶǽDZǯǼǯ ǾǽȀǿǴdzȀȁDZǽǻ ǽǾǿǴdzǴǺǴǼǷȎ ǷǶǻǴǼǴǼǷǸ ȀDZǽǸȀȁDZ Ȁǽ DZǿǴǻǴ ǼǴǻ ǓǺȎ ȌȁǽDzǽ ǷȀǾǽǺȋǶȂǴȁȀȎ DZǿǴǻǴǼǼǯȎ ȇǹǯǺǯ ǑǿǴǻǴǼǼȊǴ ȇǹǯǺȊ ǿǯȀǾǽǺǯDzǯȍȁȀȎ DZ ǿǯȀǹǯdzǿǽDZǹǴ (storyboard ǠȂȈǴȀȁDZȂȍȁ ǿǯǶǺǷȆǼȊǴ ȁǷǾȊ ǯǼǷǻǯȅǷǷ x
DoubleAnimation ǝǰǴȀǾǴȆǷDZǯǴȁ DZǽǶǻǽǵǼǽȀȁȋ ǯǼǷǻǯȅǷǷ ȆǷȀǺǽDZȊȄ ȀDZǽǸȀȁDZ ǼǯǾǿǷǻǴǿ ȁǯǹǷȄ ǹǽȁǽǿȊǴ ǷȀǾǽǺȋǶȂȍȁȀȎ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ ǾǽǺǽǵǴǼǷȎ
x
ColorAnimation
ǝǰǴȀǾǴȆǷDZǯǴȁ DZǽǶǻǽǵǼǽȀȁȋ ǯǼǷǻǯȅǷǷ ȅDZǴȁǽDZȊȄ ȀDZǽǸȀȁDZ ȁǯǹǷȄ ǹǯǹ ǶǯǺǷDZǹǷ
x
PointAnimation ȀȁDZǴ
ǝǰǴȀǾǴȆǷDZǯǴȁ DZǽǶǻǽǵǼǽȀȁȋ ǯǼǷǻǯȅǷǷ ȁǽȆǴǹ ǽǾǿǴdzǴǺǴǼǼȊȄ DZ dzDZȂȄǻǴǿǼǽǻ ǾǿǽȀȁǿǯǼ
ǗǶǻǴǼȎȁȋ ȀDZǽǸȀȁDZǯ ǻǽǵǼǽ ǺǷǼǴǸǼǽ ȁǽDzdzǯ ȀDZǽǸȀȁDZǽ ǻǴǼȎǴȁ ǶǼǯȆǴǼǷȎ Ȁ ȁǴȆǴǼǷǴǻ DZǿǴǻǴǼǷ ǷǺǷ DZ ǿǴǵǷ ǻǴ ©ǹǺȍȆǴDZǽDzǽ ǹǯdzǿǯª ǹǽDzdzǯ ǽǾǿǴdzǴǺȎǴȁȀȎ ǿȎdz ǹǽǼȁǿǽǺȋǼȊȄ ȁǽȆǴǹ ǾǴǿǴȄǽdzȊ ǻǴǵdzȂ ǹǽȁǽǿȊǻǷ Ƿ ȀǽǶ dzǯȍȁ ǯǼǷǻǯȅǷȍ ǐǽǺǴǴ ǾǽdzǿǽǰǼǽ ȌȁǷ DZǽǾǿǽȀȊ ǰȂdzȂȁ ǿǯȀȀǻǽȁǿǴǼȊ DZ ǒǺǯDZǴ ©ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷ ǻǯȅǷȎ DZ XAMLª ǜǽ ǾǿǷǻǴǼǴǼǷǴ XAML DZȊȄǽdzǷȁ dzǯǺǴǹǽ Ƕǯ ǿǯǻǹǷ ǿǯȀȀǻǽȁǿǴǼǼȊȄ ǶdzǴȀȋ ǽȀǼǽDZǼȊȄ ǾǽǼȎȁǷǸ Ǡ ǾǽǻǽȈȋȍ XAML ǽǾǷȀȊDZǯȍȁȀȎ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Ƿ ǹǽǻǾǽǼǽDZǹǯ UI. ǐǽǺǴ ǾǽdzǿǽǰǼǽ Ȍȁǽ ǰȂdzǴȁ ǿǯȀȀǻǽȁǿǴǼǽ DZ ǒǺǯDZǴ ©ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ ǹǽǻǾǽǼǽDZǹǷª Ƿ DZ DzǺǯDZǯȄ ǦǯȀȁǷ ©Ǟǿǽ DzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight ª
Silverlight Ƿ ǾǯǹǴȁ ǷǼȀȁǿȂǻǴǼȁǽDZ Expression Studio ǙǽǻǾǯǼǷǴǸ Microsoft ǰȊǺ ȀǽǶdzǯǼ ǾǯǹǴȁ ǷǼȀȁǿȂǻǴǼȁǽDZ Expression Studio. Ǭȁǽ ȀǽDZǿǴǻǴǼǼȊǸ ǼǯdzǴǵǼȊǸ Ǽǯǰǽǿ ǷǼȀȁǿȂǻǴǼȁǽDZ dzǺȎ dzǷǶǯǸǼǴǿǽDZ ǾǽǶDZǽǺȎȍȈǷǸ Ƿǻ ȀǽǶdzǯDZǯȁȋ ǯǿȁǴȃǯǹȁȊ ǹǽȁǽǿȊǴ ǶǯȁǴǻ ǻǽDzȂȁ ǰȊȁȋ DZǹǺȍȆǴǼȊ ǿǯǶǿǯǰǽȁȆǷǹǯǻǷ ǾǿǷ ǿǯǰǽȁǴ Ȁ ǾǯǹǴȁǽǻ ǷǼȀȁǿȂǻǴǼȁǽDZ Microsoft Visual Studio. Ǒ Expression Studio DZȄǽdzǷȁ ǼǴȀǹǽǺȋǹǽ ǾǿǽdzȂǹȁǽDZ:
ǒǺǯDZǯ ǑDZǴdzǴǼǷǴ DZ 6LOYHUOLJKW 2
23
x
Expression Web Ǭȁǽ ǷǼȀȁǿȂǻǴǼȁ dzǺȎ ǑǴǰ-ǿǯǶǿǯǰǽȁǹǷ ǹǽȁǽǿȊǸ ǽǰǴȀǾǴȆǷDZǯǴȁ DZǽǶǻǽǵǼǽȀȁȋ ǷȀǾǽǺȋǶǽ DZǯȁȋ HTML, DHTML, CSS Ƿ dzǿȂDzǷǴ ȀȁǯǼdzǯǿȁǼȊǴ ǑǴǰ-ȁǴȄǼǽǺǽDzǷǷ dzǺȎ ǾǿǽǴǹȁǷǿǽDZǯǼǷȎ ǾǽȀȁǿǽǴǼǷȎ Ƿ ȂǾǿǯDZǺǴǼǷȎ ǑǴǰ-ǾǿǷǺǽǵǴǼǷȎǻǷ
x
Expression Media Ǭȁǽ ǷǼȀȁǿȂǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǻȂǺȋȁǷǻǴdzǷǯ ǿǴȀȂǿȀǯǻǷ ǹǽȁǽǿȊǸ ǾǽǶDZǽǺȎǴȁ ǹǯȁǯǺǽDzǷ ǶǷǿǽDZǯȁȋ Ƿ ǽǿDzǯǼǷǶǽDZȊDZǯȁȋ ȌȁǷ ȌǺǴǻǴǼȁȊ DZǹǺȍȆǯȎ DZǽǶǻǽǵǼǽȀȁȋ ǹǽdzǷǿǽDZǯǼǷȎ Ƿ ǾǴǿǴǹǽdzǷǿǽDZǯǼǷȎ ǷǶ ȃǽǿǻǯȁǯ DZ ȃǽǿǻǯȁ
x
Expression Encoder Ǭȁǽ ǾǿǷǺǽǵǴǼǷǴ ǿǯǶǿǯǰǽȁǯǼǽ dzǺȎ ǽǰǴȀǾǴȆǴǼǷȎ DZǽǶǻǽǵǼǽȀȁǷ ȂǾǿǯDZǺǴǼǷȎ ǹǽdzǷǿǽ DZǯǼǷǴǻ ǻȂǺȋȁǷǻǴdzǷǯ ǿǴȀȂǿȀǽDZ. ǡǯǹǵǴ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ǹǽǻǾǺǴǹȁǯȅǷǷ ǻȂǺȋȁǷǻǴdzǷȎ SilverlightǻǴdzǷǯǾǺǴǴǿǽǻ DZ DZǷdzǴ ȀǽǽȁDZǴȁȀȁDZȂȍȈǴDzǽ ǹǽdzǯ.
x
Expression Design Ǭȁǽ ǷǼȀȁǿȂǻǴǼȁ DzǿǯȃǷȆǴȀǹǽDzǽ dzǷǶǯǸǼǯ ǹǽȁǽǿȊǸ ǻǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ dzǺȎ ȀǽǶdzǯǼǷȎ ǷǺǺȍȀȁǿǯȅǷǸ DzǿǯȃǷȆǴȀǹǷȄ ȌǺǴǻǴǼȁǽDZ Ƿ ǿǴȀȂǿȀǽDZ dzǺȎ 8, ǑǴǰ- Ƿ ǼǯȀȁǽǺȋǼȊȄ ǾǿǷǺǽǵǴǼǷǸ
x
Expression Blend Ǭȁǽȁ ǷǼȀȁǿȂǻǴǼȁ ǽǰǴȀǾǴȆǷDZǯǴȁ DZǽǶǻǽǵǼǽȀȁȋ ȀǽǶdzǯDZǯȁȋ 8, Ǽǯ ǰǯǶǴ XAML dzǺȎ ǼǯȀȁǽǺȋ ǼȊȄ ǾǿǷǺǽǵǴǼǷǸ Ǽǯ :3) ǷǺǷ ǑǴǰ-ǾǿǷǺǽǵǴǼǷǸ Ǽǯ 6LOYHUOLJKW ǞǿǷ ǿǯǰǽȁǴ Ȁ Silverlight DZȊ ǰȂdzǴȁǴ ǷȀǾǽǺȋǶǽDZǯȁȋ ǼǴǹǽȁǽǿȊǴ ǷǺǷ DZȀǴ ȌȁǷ ǾǿǷǺǽǵǴǼǷȎ ǓǯǺǴǴ DZ dzǯǼǼǽǸ DzǺǯDZǴ ǻȊ ǿǯȀȀǻǽȁǿǷǻ ǹǯǹ Design, Blend Ƿ Encoder ǿǯȀȇǷǿȎȍȁ DZǯȇ ǷǼȀȁǿȂǻǴǼȁǯǿǷǸ dzǺȎ ǾǿǽǴǹȁǷǿǽDZǯ ǼǷȎ Ƿ ǾǽȀȁǿǽǴǼǷȎ Silverlight-ǾǿǷǺǽǵǴǼǷǸ
Silverlight Ƿ Expression Design Expression Design ² Ȍȁǽ ǷǼȀȁǿȂǻǴǼȁ DzǿǯȃǷȆǴȀǹǽDzǽ dzǷǶǯǸǼǯ Ȁ ǾǽǻǽȈȋȍ ǹǽȁǽǿǽDzǽ ǻǽǵǼǽ ȀǽǶdzǯDZǯȁȋ Dzǿǯ ȃǷȆǴȀǹǷǴ ǿǴȀȂǿȀȊ ǷȀǾǽǺȋǶȂǴǻȊǴ DZ ǾǿǷǺǽǵǴǼǷȎȄ Ǭȁǽ ǻǽȈǼȊǸ Ƿ ȀǺǽǵǼȊǸ ǷǼȀȁǿȂǻǴǼȁ ǾǽȌȁǽǻȂ DZ dzǯǼ ǼǽǸ ǹǼǷDzǴ ǾǿǷDZǽdzǷȁȀȎ ǾǿǽȀȁǽ ǽǰǶǽǿ ȁǽDzǽ ǹǯǹ ǽǼ ǻǽǵǴȁ ǾǿǷǻǴǼȎȁȋȀȎ dzǺȎ Silverlight XAML. Expression Design ǾǽǶDZǽǺȎǴȁ ȀǽȆǴȁǯȁȋ DZǴǹȁǽǿǼȊǴ Ƿ ǿǯȀȁǿǽDZȊǴ ǷǶǽǰǿǯǵǴǼǷȎ dzǺȎ ǽǰǴȀǾǴȆǴǼǷȎ ǯǰȀǽǺȍȁǼǽǸ DzǷǰǹǽ ȀȁǷ ǝǼ ǾǽdzdzǴǿǵǷDZǯǴȁ ǷǻǾǽǿȁ ǻǼǽǵǴȀȁDZǯ ȃǽǿǻǯȁǽDZ DzǿǯȃǷȆǴȀǹǷȄ ȃǯǸǺǽDZ Ǒ Expression Design ǻǽǵǼǽ Ƿǻ ǾǽǿȁǷǿǽDZǯȁȋ ȃǯǸǺȊ DZ ȃǽǿǻǯȁǯȄ x
Adobe Illustrator³PDF-ȀǽDZǻǴȀȁǷǻȊǴ ai)
x
Adobe Photoshop (*.psd)
x
Graphical Interchange Format (.gif)
x
ǣǽǿǻǯȁ Portable Network Graphics (.png)
x
ǟǯȀȁǿǽDZȊǴ ǷǶǽǰǿǯǵǴǼǷȎ (.bmp, .dib, .rle)
x
ǣǽǿǻǯȁȊ JPEG (.jpeg, .jpg, .jpe, .jfif, .exif)
x
Windows Media Photos (.wdp, .hdp)
x
Tagged Image File Format (.tiff, .tif)
x
ǖǼǯȆǹǷ (.ico) ǞǽdzdzǴǿǵǷDZǯǴȁȀȎ ȌǹȀǾǽǿȁ ȀǺǴdzȂȍȈǷȄ ȁǷǾǽDZ ǷǶǽǰǿǯǵǴǼǷǸ
x
XAML Silverlight Canvas
x
XAML WPF Resource Dictionary
x
XAML WPF Canvas
x
Adobe Illustrator (.ai)
x
Portable Document Format (.pdf)
x
Adobe Photoshop (.psd)
x
Tagged Image File Format (.tif, .tiff)
x
ǣǽǿǻǯȁȊ JPEG (.jpeg, .jpg)
24
ʦ̛̖̖̦̖̏̔ ̏ Silverlight 2
x
Windows Bitmap (.bmp)
x
ǣǽǿǻǯȁ Portable Network Graphics (.png)
x
Graphical Interchange Format (.gif)
x
Windows Media Photos (.wdp) Ǚǯǹ DZǷdzǷȁǴ Expression Design ǾǽdzdzǴǿǵǷDZǯǴȁ ȌǹȀǾǽǿȁ DzǿǯȃǷȆǴȀǹǷȄ ǿǴȀȂǿȀǽDZ DZ DZǷdzǴ XAML-ȃǯǸǺǽDZ ǞǽǶ ǵǴ DZ dzǯǼǼǽǸ DzǺǯDZǴ ǰȂdzǴȁ ǾǽǹǯǶǯǼǽ ǹǯǹ DZ Expression Design ǿǯǶǿǯǰǯȁȊDZǯǴȁȀȎ dzǷǶǯǸǼ DzǿǯȃǷȆǴȀǹǷȄ ȌǺǴ ǻǴǼȁǽDZ ǾǿǽȀȁǽDzǽ ǾǿǷǺǽǵǴǼǷȎ ǑȊ ǰȂdzǴȁǴ ȌǹȀǾǽǿȁǷǿǽDZǯȁȋ ȌȁǷ ȌǺǴǻǴǼȁȊ DZ DZǷdzǴ XAML-ǹǽdzǯ ǹǽȁǽǿȊǸ ȀǻǽǵǴȁǴ ǷȀǾǽǺȋǶǽDZǯȁȋ dzǺȎ ȀǽǶdzǯǼǷȎ ǾǿǷǺǽǵǴǼǷȎ DZ Expression Blend Ƿ Visual Studio. ǜǯ ǿǷȀ 1- ǾǿǴdzȀȁǯDZǺǴǼǽ dzǷǯǺǽDzǽDZǽǴ ǽǹǼǽ Export ǬǹȀǾǽǿȁ DZ Expression Design Ǒ ǼǴǻ ǻǽǵǼǽ ȂDZǷdzǴȁȋ ǼǴ ȀǹǽǺȋǹǽ DZǯǿǷǯǼȁǽDZ DZȊǰǽǿǯ ȃǽǿǻǯȁǯ ǽdzǷǼ ǷǶ ǹǽȁǽǿȊȄ ² XAML Silverlight Canvas ǽȁǽǰǿǯǵǯǴȁȀȎ DZȊǰǿǯǼ ǼȊǻ ǑȊǰǽǿ ȌȁǽǸ ǽǾȅǷǷ ǽǰǴȀǾǴȆǷȁ ȃǽǿǻǯȁǷǿǽDZǯǼǷǴ ǿǷȀȂǼǹǯ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǾǽdzǻǼǽǵǴȀȁDZǯ ȌǺǴǻǴǼȁǽDZ XAML ǹǽȁǽǿȊǴ ǷȀǾǽǺȋǶȂǴȁ Silverlight Ȇȁǽ ǾǽǶDZǽǺǷȁ ǷǻǾǽǿȁǷǿǽDZǯȁȋ ǾǽǺȂȆǴǼǼȊǸ DZ ǿǴǶȂǺȋȁǯȁǴ XAML DZ Visual Studio ǷǺǷ Expression Blend dzǺȎ ǾǽȀȁǿǽǴǼǷȎ Silverlight ǾǿǷǺǽǵǴǼǷȎ
ǟǗǠ 1 4 ǬǹȀǾǽǿȁ XAML ǷǶ Expression Design.
Ǭȁǽ ǽǰǴȀǾǴȆǷȁ ȌǹȀǾǽǿȁ ȀǽdzǴǿǵǷǻǽDzǽ DZ DZǷdzǴ XML-dzǽǹȂǻǴǼȁǯ DZǹǺȍȆǯȍȈǴDzǽ ȌǺǴǻǴǼȁ Canvas DZ ǹǽȁǽǿǽǻ ȀǽdzǴǿǵǯȁȀȎ ȌǺǴǻǴǼȁȊ DZǯȇǴDzǽ dzǷǶǯǸǼǯ ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ (ȀǽǹǿǯȈǴǼǼȊǸ):
ǒǺǯDZǯ ǑDZǴdzǴǼǷǴ DZ 6LOYHUOLJKW 2
25
ǡǴǾǴǿȋ Ȍȁǽȁ XAML ǻǽǵǼǽ DZȊǿǴǶǯȁȋ Ƿ DZȀȁǯDZǷȁȋ DZ Expression Blend ǷǺǷ Visual Studio Ƿ DZȊ ȀǻǽǵǴȁǴ ǷȀ ǾǽǺȋǶǽDZǯȁȋ DzǿǯȃǷȆǴȀǹǷǸ ȌǺǴǻǴǼȁ DZ ȀDZǽǴǻ ǾǿǷǺǽǵǴǼǷǷ
Silverlight Ƿ Expression Blend Expression Blend ǽǰǺǯdzǯǴȁ DZǽǶǻǽǵǼǽȀȁȋȍ ȀǽǶdzǯǼǷȎ ǾǿǷǺǽǵǴǼǷǸ Silverlight. ǞǿǷ ǶǯǾȂȀǹǴ Expression Blend Ƿ ȀǽǶdzǯǼǷǷ ǼǽDZǽDzǽ ǾǿǽǴǹȁǯ ǾǿǴdzǺǯDzǯǴȁȀȎ dzDZǯ ȁǷǾǯ Silverlight ǾǿǽǴǹȁǽDZ ǹǯǹ DZǷdzǼǽ Ǽǯ ǿǷȀ 1-5.
ǟǗǠ 1 5 ǞǽdzdzǴǿǵǹǯ Silverlight DZ Expression Blend.
ǬȁǷǻǷ dzDZȂǻȎ ȁǷǾǯǻǷ ǾǿǽǴǹȁǽDZ Silverlight ȎDZǺȎȍȁȀȎ: x
Silverlight 1 Site Ǭȁǯ ǽǾȅǷȎ ǽǰǴȀǾǴȆǷDZǯǴȁ ȀǽǶdzǯǼǷǴ ǾǿǽǴǹȁǯ Silverlight JavaScript. ǑȊ ǾǽǺȂȆǯǴȁǴ ǾǯǾǹȂ ȀǽdzǴǿǵǯȈȂȍ ǾǿǽȀȁǽǴ ǑǴǰ-ǾǿǷǺǽǵǴǼǷǴ Ȁ HTML-ȀȁǿǯǼǷȅǴǸ ǷǻǴȍȈǴǸ ǼǴǽǰȄǽdzǷǻȊǴ ȀȅǴǼǯǿǷǷ dzǺȎ DZȀȁǯDZǹǷ ǽǰȉǴǹȁǯ Silverlight ǯ ȁǯǹǵǴ ȀȁǯǼdzǯǿȁǼȊǸ XAML-dzǽǹȂǻǴǼȁ Ȁ ǽdzǼǷǻ ȄǽǺȀȁǽǻ ǝǼ ǼǴ ȀǽdzǴǿǵǷȁ ǼǷ ǹǯǹǷȄ dzǴȁǯǺǴǸ ǿǴǯǺǷǶǯȅǷǷ dzǺȎ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ Ǽǯ 1(7 ǾǽȌȁǽǻȂ dzǺȎ ǴDzǽ ǽǾǷȀǯǼǷȎ ǷȀǾǽǺȋǶȂǴȁȀȎ ȁǴǿǻǷǼ Site ȄǽȁȎ Ȍȁǽ DZǴǿȀǷȎ .0 ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight. ǠǹǽǿǴǴ DZȀǴDzǽ DZ ǰȂdzȂȈǷȄ DZǴǿȀǷȎȄ Expression Blend ǼǯǶDZǯǼǷǴ ȌȁǽDzǽ ȁǷǾǯ ǾǿǽǴǹȁǯ ǶǯǻǴǼȎȁ Ǽǯ Silverlight JavaScript Site. Ǒ ǒǺǯDZǴ ©ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰǿǯȂǶǴǿǯ Silverlightª ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ ǾǿǷǺǽǵǴǼǷǸ JavaScript ǰȂdzǴȁ ǿǯȀȀǻǽȁǿǴǼǽ ǰǽǺǴǴ ǾǽdzǿǽǰǼǽ
x
Silverlight 2 Application Ǭȁǯ ǽǾȅǷȎ ǽǰǴȀǾǴȆǷDZǯǴȁ ȀǽǶdzǯǼǷǴ Silverlight-ǾǿǽǴǹȁǯ Ȁǽ DZȀǴǻ ǼǴǽǰȄǽdzǷǻȊǻ dzǺȎ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ 1(7 )UDPHZRUN ǐǽǺȋȇǴ ǷǼȃǽǿǻǯȅǷǷ ǽ 6LOYHUOLJKW ǾǿǷDZǽ dzǷȁȀȎ DZ ǒǺǯDZǴ ©ǗȀǾǽǺȋǶǽDZǯǼǷǴ 9LVXDO 6WXGLR Ȁ 6LOYHUOLJKW ª Ƿ ǶǯȁǴǻ DZ ǦǯȀȁǷ dzǯǼǼǽǸ ǹǼǷDzǷ ǒǺǯDZǯȄ ² Ȍȁǽȁ ȁǷǾ ǾǿǽǴǹȁǯ ǰȂdzǴȁ ǿǯȀȀǻǽȁǿǴǼ ǼǯǻǼǽDzǽ ǰǽǺǴǴ ǾǽdzǿǽǰǼǽ
ǞǿǽǴǹȁ Silverlight 1 ǞǿǷ ȀǽǶdzǯǼǷǷ ǼǽDZǽDzǽ ǾǿǷǺǽǵǴǼǷȎ Silverlight Script Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ Blend ǾǽǺȂȆǯǴǻȊǸ ǾǿǽǴǹȁ ǰȂdzǴȁ ȀǽdzǴǿǵǯȁȋ ȀȁǯǼdzǯǿȁǼȊǸ HTML-ȃǯǸǺ Ȁǽ DZȀǴǻ ǼǴǽǰȄǽdzǷǻȊǻ JavaScript-ǹǽdzǽǻ dzǺȎ ȀǽǶdzǯǼǷȎ ȌǹǶǴǻǾǺȎǿǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight. ǙǿǽǻǴ ȁǽDzǽ Blend ȁǯǹǵǴ ȀǽǶdzǯǴȁ ǰǯǶǽDZȂȍ XAML-ȀȁǿǯǼǷȅȂ Page.xaml Ƿ ȀDZȎǶǯǼǼȊǸ Ȁ ǼǴǸ JavaScript-ȃǯǸǺ Page.xaml.js. Expression Blend ȁǿǯǹȁȂǴȁ ǴDzǽ ǹǯǹ JavaScript-ȃǯǸǺ Ȁ DZȊdzǴ ǺǴǼǼȊǻ ǹǽdzǽǻ ǯǼǯǺǽDzǷȆǼǽ ȁǽǻȂ ǹǯǹ Visual Studio ȁǿǯǹȁȂǴȁ C#-ȃǯǸǺ Ȁ DZȊdzǴǺǴǼǼȊǻ ǹǽdzǽǻ ȀDZȎǶǯǼǼȊǸ Ȁǽ ȀȁǿǯǼǷȅǴǸ ASPX ǜǯǹǽǼǴȅ Blend ǾǿǴdzǽȀȁǯDZǺȎǴȁ ǹǽǾǷȍ ȃǯǸǺǯ Silverlight.js ǹǽȁǽǿȊǸ ȎDZǺȎǴȁȀȎ ȆǯȀȁȋȍ Ǿǯ ǹǴȁǯ dzǺȎ ǿǯǶǿǯǰǽȁȆǷǹǯ Ǟǝ software development kit, SDK) Silverlight Ǭȁǽȁ ȃǯǸǺ ȂǾǿǯDZǺȎǴȁ ȀǽǶdzǯǼǷǴǻ Ȍǹ ǶǴǻǾǺȎǿǽDZ Ƿ ǶǯDzǿȂǶǹǽǸ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ Silverlight dzǺȎ DZǯȇǷȄ ǾǽǺȋǶǽDZǯȁǴǺǴǸ ǠȁǿȂǹȁȂǿǯ ǾǿǽǴǹȁǯ ǾǿǴdzȀȁǯDZǺǴǼǯ Ǽǯ ǿǷȀ 1-6.
26
ʦ̛̖̖̦̖̏̔ ̏ Silverlight 2
ǟǗǠ. 1 6 ǠȁǿȂǹȁȂǿǯ ǾǿǽǴǹȁǯ ǾǿǷǺǽǵǴǼǷȎ Silverlight JavaScript.
ǑǴǰ-ȀȁǿǯǼǷȅǯ Ǿǽ ȂǻǽǺȆǯǼǷȍ Ǒ ǚǷȀȁǷǼDzǴ - ǾǿǴdzȀȁǯDZǺǴǼ ǹǽdz ǰǯǶǽDZǽǸ ǑǴǰ-ȀȁǿǯǼǷȅȊ ȀǽǶdzǯDZǯǴǻǽǸ Blend dzǺȎ ǾǿǽǴǹȁǽDZ Silverlight. ǚǗǠǡǗǜǒ 1 ǣǯǸǺ Default.html ǷǶ ȇǯǰǺǽǼǯ Silverlight SilverlightSite1 #silverlightControlHost { height: 480px; width: 640px; } #errorLocation { font-size: small; color: Gray; } function createSilverlight() { var scene = new SilverlightSite1.Page(); Silverlight.createObjectEx({ source: "Page.xaml", parentElement: document.getElementById("silverlightControlHost"), id: "SilverlightControl", properties: { width: "100%", height: "100%", version: "1.0" }, events: { onLoad: Silverlight.createDelegate(scene, scene.handleLoad), onError: function(sender, args) { var errorDiv = document.getElementById("errorLocation"); if (errorDiv != null) { var errorText = args.errorType + "- " + args.errorMessage; if (args.ErrorType == "ParserError") { errorText += "File: " + args.xamlFile; errorText += ", line " + args.lineNumber; errorText += " character " + args.charPosition; } else if (args.ErrorType == "RuntimeError") { errorText += "line " + args.lineNumber; errorText += " character " + args.charPosition; } errorDiv.innerHTML = errorText; } } }
ǒǺǯDZǯ ǑDZǴdzǴǼǷǴ DZ 6LOYHUOLJKW 2
27
}); } if (!window.Silverlight) Silverlight = {}; Silverlight.createDelegate = function(instance, method) { return function() { return method.apply(instance, arguments); } } createSilverlight();
Ǚǯǹ DZǷdzǷȁǴ ǶdzǴȀȋ ǷǻǾǽǿȁǷǿȂȍȁȀȎ dzDZǯ JavaScript-ȃǯǸǺǯ Silverlight.js Ƿ Page.xaml.js ǑȀǹǽǿǴ ǹǯǵdzȊǸ ǷǶ ǼǷȄ ǰȂdzǴȁ ǿǯȀȀǻǽȁǿǴǼ ǰǽǺǴǴ ǾǽdzǿǽǰǼǽ ǠǽǶdzǯǼǷǴ ȌǹǶǴǻǾǺȎǿǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǾǿǽǷȀȄǽdzǷȁ DZ ȌǺǴǻǴǼȁǴ Test Solution),
DZȊ ȂDZǷdzǷȁǴ Ǽǯ ȌǹǿǯǼǴ ǾǿǷǻǴǿǼǽ ȁǽ
ǟǗǠ 2 4 ǑȊǾǽǺǼǴǼǷǴ ǾǿǷǺǽǵǴǼǷȎ Silverlight ǷǶ %OHQG
Ǭȁǽ ǾǿǽȀȁǽǴ ǾǿǷǺǽǵǴǼǷǴ DZȊǾǽǺǼȎǴȁȀȎ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǑǴǰ-ȀǴǿDZǴǿǯ Cassini ǽȁȀȍdzǯ ȀǺȂȆǯǸǼȊǸ Ǽǽ ǻǴǿ Ǿǽǿȁǯ 4553 ǹǽȁǽǿȊǸ ǻǽǵǼǽ DZǷdzǴȁȋ DZ ǯdzǿǴȀǼǽǸ ȀȁǿǽǹǴ Ǽǯ ǿǷȀ 2- ǾȂȁǴǻ ȃǽǿǻǷǿǽDZǯǼǷȎ HTMLȀȁǿǯǼǷȅȊ dzǺȎ ǿǯǶǻǴȈǴǼǷȎ Silverlight-ȀǽdzǴǿǵǷǻǽDzǽ ǞǽȀǻǽȁǿǷǻ Ǽǯ ǷȀȄǽdzǼȊǸ ǹǽdz ȌȁǽǸ ȀȁǿǯǼǷȅȊ Ȁ ǾǽǻǽȈȋȍ ǹǽǻǯǼdzȊ ǰǿǯȂǶǴǿǯ View Source ǞǿǽȀǻǽȁǿ ǷȀ ȄǽdzǼǽDzǽ ǹǽdzǯ TestApp html, body { height: 100%; overflow: auto; } body { padding: 0; margin: 0; } #silverlightControlHost { height: 100%; } function onSilverlightError(sender, args) { var appSource = ""; if (sender != null && sender != 0) { appSource = sender.getHost().Source;
ǒǺǯDZǯ ǗȀǾǽǺȋǶǽDZǯǼǷǴ ([SUHVVLRQ %OHQG Ȁ Silverlight 2
37
} var errorType = args.ErrorType; var iErrorCode = args.ErrorCode; var errMsg = "Unhandled Error in Silverlight 2 Application " + appSource + "\n" ; errMsg += "Code: "+ iErrorCode + " \n"; errMsg += "Category: " + errorType + " \n"; errMsg += "Message: " + args.ErrorMessage + " \n"; if (errorType == "ParserError") { errMsg += "File: " + args.xamlFile + " \n"; errMsg += "Line: " + args.lineNumber + " \n"; errMsg += "Position: " + args.charPosition + " \n"; } else if (errorType == "RuntimeError") { if (args.lineNumber != 0) { errMsg += "Line: " + args.lineNumber + " \n"; errMsg += "Position: " + args.charPosition + " \n"; } errMsg += "MethodName: " + args.methodName + " \n"; } throw new Error(errMsg); }
ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ǽǯ ȁǴDz . Ǒ ǼǴǻ dzǴǺǯǴȁȀȎ ǾǽǾȊȁǹǯ ȀǽǶdzǯǼǷȎ ȌǹǶǴǻǾǺȎǿǯ Silverlight. Ǒ ȀǺȂȆǯǴ ȀǰǽȎ ǽǼ ȃǽǿǻǷǿȂǴȁ ǷǶǽǰǿǯǵǴǼǷǴ Ȁ DzǷǾǴǿȁǴǹȀȁǽDZǽǸ ȀȀȊǺǹǽǸ HREF Ǽǯ ǯdzǿǴȀ Ȁ ǹǽȁǽǿǽDzǽ ǻǽǵǼǽ ǶǯDzǿȂǶǷȁȋ Silverlight. ǐǽǺǴǴ ǾǽdzǿǽǰǼǽ ǽǰ Ȍȁǽǻ Ƿ dzǿȂDzǷȄ ȀǾǽȀǽǰǯȄ ȀǽǶdzǯǼǷȎ ȌǹǶǴǻǾǺȎǿǯ ǽǰȉǴǹȁǯ Silverlight ǿǯȀȀǹǯǶȊDZǯǴȁȀȎ DZ ǒǺǯDZǴ ©ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰǿǯȂǶǴǿǯ Silverlightª
ǗǼȁǴDzǿǷǿǽDZǯǼǼǯȎ ȀǿǴdzǯ ǿǯǶǿǯǰǽȁǹǷ Expression Blend Expression Blend ǾǿǴdzǺǯDzǯǴȁ DzǷǰǹȂȍ ǷǼȁǴDzǿǷǿǽDZǯǼǼȂȍ ȀǿǴdzȂ ǿǯǶǿǯǰǽȁǹǷ IDE) ǹǽȁǽǿǯȎ ǾǽǶDZǽǺȎǴȁ ǻǯǹ ȀǷǻǯǺȋǼǽ ȂDZǴǺǷȆǷȁȋ ǹǽǺǷȆǴȀȁDZǽ ǷǼȃǽǿǻǯȅǷǷ DZȊDZǽdzǷǻǽǸ Ǽǯ ȌǹǿǯǼ ǞǿǷ Ȍȁǽǻ ǾǽǺȋǶǽDZǯȁǴǺȋ ǻǽǵǴȁ ǰǴǶ ȁǿȂdzǯ ǾǽǼǷǻǯȁȋ Ȇȁǽ ǾǿǽǷȀȄǽdzǷȁ IDE ǷǻǴǴȁ dzDZǴ DZǯǿǷǯǼȁǯ ǽǿDzǯǼǷǶǯȅǷǷ ǿǯǰǽȆǴǸ ǽǰǺǯȀȁǷ ǾǿǷǺǽǵǴǼǷȎ ǿǯǰǽȆǯȎ ǽǰǺǯȀȁȋ Design ǓǷǶǯǸǼ ǷȀǾǽǺȋǶȂǴǻǯȎ ǾǿǴǷǻȂȈǴȀȁDZǴǼǼǽ dzǺȎ ȀǽǶdzǯǼǷȎ Ƿ ǼǯȀȁǿǽǸǹǷ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǽDzǽ ǷǼȁǴǿȃǴǸȀǯ UI Ƿ ǿǯ ǰǽȆǯȎ ǽǰǺǯȀȁȋ Animation (ǏǼǷǻǯȅǷȎ) ǹǽȁǽǿǯȎ ǷȀǾǽǺȋǶȂǴȁȀȎ DzǺǯDZǼȊǻ ǽǰǿǯǶǽǻ dzǺȎ ȀǽǶdzǯǼǷȎ ǯǼǷǻǯȅǷǸ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ DZǿǴǻǴǼǼǽǸ ȇǹǯǺȊ ǞǴǿǴǹǺȍȆǯȁȋȀȎ ǻǴǵdzȂ ǿǯǰǽȆǷǻǷ ǽǰǺǯȀȁȎǻǷ ǻǽǵǼǽ Ȁ ǾǽǻǽȈȋȍ ǹǺǯDZǷȇǷ F ǷǺǷ DZȊǰǷǿǯȎ ǼǴǽǰȄǽdzǷǻȂȍ ǿǯǰǽȆȂȍ ǽǰǺǯȀȁȋ DZ ǽǾȅǷȎȄ Active Workspace ǏǹȁǷDZǼǯȎ ǿǯǰǽ ȆǯȎ ǽǰǺǯȀȁȋ ǻǴǼȍ Window. ǬǹǿǯǼ DZ Expression Blend IDE ǿǯǶdzǴǺǴǼ Ǽǯ ǾǯǼǴǺǷ ǙǯǵdzǯȎ ǾǯǼǴǺȋ ǷǻǴǴȁ ȀǽǰȀȁDZǴǼǼǽǴ ǼǯǶǼǯȆǴǼǷǴ ǹǯǹ DZȊ ȂDZǷdzǷȁǴ ǾǿȎǻǽ ȀǴǸȆǯȀ DZǽ DZǿǴǻȎ ǷȄ ǽǰǶǽǿǯ
38
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǞǯǼǴǺȋ ǷǼȀȁǿȂǻǴǼȁǽDZ ǞǯǼǴǺȋ ǷǼȀȁǿȂǻǴǼȁǽDZ ǿǯȀǾǽǺǯDzǯǴȁȀȎ Ǽǯ ȌǹǿǯǼǴ Ȁ ǺǴDZǽDzǽ ǹǿǯȎ ǝǼǯ ȀǽdzǴǿǵǷȁ ǷǼȀȁǿȂǻǴǼȁȊ ȁǯǹǷǴ ǹǯǹ Selection (ǑȊǰǽǿ) ǷǺǷ Direct Selection (ǞǿȎǻǽǸ DZȊǰǽǿ) ǹǽȁǽǿȊǴ ǻǽDzȂȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ǽǰǿǯǰǽȁǹǷ ǺȍǰǽDzǽ ǽǰȉǴǹȁǯ DZǷǶȂǯǺȋǼȊǴ ȌǺǴǻǴǼȁȊ ȁǯǹǷǴ ǹǯǹ Rectangle ǞǿȎǻǽȂDzǽǺȋǼǷǹ ǷǺǷ Ellipse ǬǺǺǷǾȀ ; ǹǽǻ ǾǽǼǽDZǽȆǼȊǴ ȌǺǴǻǴǼȁȊ ȁǯǹǷǴ ǹǯǹ StackPanel ǷǺǷ Canvas Ƿ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ȁǯǹǷǴ ǹǯǹ Button (ǙǼǽǾǹǯ ǷǺǷ TextBox (ǡǴǹȀȁǽDZǽǴ ǾǽǺǴ ǞǯǼǴǺȋ ǷǼȀȁǿȂǻǴǼȁǽDZ ǾǿǴdzȀȁǯDZǺǴǼǯ Ǽǯ ǿǷȀ 2-5.
ǟǗǠ 5 ǞǯǼǴǺȋ ǷǼȀȁǿȂǻǴǼȁǽDZ Expression Blend.
Ǒ Blend ȀȄǽǵǷǴ ǷǼȀȁǿȂǻǴǼȁȊ ǻǽDzȂȁ ǰȊȁȋ ȀǽǰǿǯǼȊ Ǿǽdz ǽdzǼǷǻ ǶǼǯȆǹǽǻ Ǽǯ ǾǯǼǴǺǷ ǷǼȀȁǿȂǻǴǼȁǽDZ ǜǯ ǿǷȀ 2- DZǷdzǼǽ ǹǯǹ ǻǽǵǼǽ ǾǿǽȀǻǯȁǿǷDZǯȁȋ Ǽǯǰǽǿ ǾǽdzǽǰǼȊȄ ǷǼȀȁǿȂǻǴǼȁǽDZ ǔȀǺǷ DZ ǼǷǵǼǴǻ ǾǿǯDZǽǻ ȂDzǺȂ ǷǼȀȁǿȂǻǴǼȁǯ ǴȀȁȋ ǰǴǺȊǸ ȁǿǴȂDzǽǺȋǼǷǹ DZȊ ǻǽǵǴȁǴ ǼǯDZǴȀȁǷ ǹȂǿȀǽǿ Ǽǯ Ȍȁǽȁ ǷǼȀȁǿȂǻǴǼȁ Ƿ Ǽǯǵǯȁȋ ǹǼǽǾǹȂ ǻȊȇǷ ȆȁǽǰȊ ȂDZǷdzǴȁȋ DZȀǴȄ ȆǺǴǼǽDZ ©ȀǴǻǴǸȀȁDZǯª DZȊǰǿǯǼǼǽDzǽ ǽǰȉǴǹȁǯ ǡǯǹ ǼǯǾǿǷǻǴǿ ǴȀǺǷ ǼǯDZǴȀȁǷ ǹȂǿ Ȁǽǿ Ǽǯ ǷǼȀȁǿȂǻǴǼȁ Rectangle Ƿ Ǽǯǵǯȁȋ ǹǼǽǾǹȂ ǻȊȇǷ ǾǽȎDZǷȁȀȎ DZȊǾǯdzǯȍȈǴǴ ǽǹǼǽ DZ ǹǽȁǽǿǽǻ ǰȂdzȂȁ ǾǿǴdzȀȁǯDZǺǴǼȊ DZȀǴ ǽȀȁǯǺȋǼȊǴ dzǽȀȁȂǾǼȊǴ ȃǷDzȂǿȊ ǹǯǹ DZǷdzǼǽ Ǽǯ ǿǷȀ 2-6.
ǟǗǠ 6 ǒǿȂǾǾǷǿǽDZǹǯ ǷǼȀȁǿȂǻǴǼȁǽDZ.
Blend ǽǰǺǯdzǯǴȁ ǶǯǻǴȆǯȁǴǺȋǼȊǻ ȀDZǽǸȀȁDZǽǻ ² ǽǼ ǽȁǽǰǿǯǵǯǴȁ Ǽǯ ǾǯǼǴǺǷ ǷǼȀȁǿȂǻǴǼȁǽDZ ǶǼǯȆǽǹ ȁǽDzǽ ǷǼȀȁ ǿȂǻǴǼȁǯ ȀǴǻǴǸȀȁDZǯ ǷǼȀȁǿȂǻǴǼȁǽDZ ǹǽȁǽǿȊǸ DZȊ ǷȀǾǽǺȋǶǽDZǯǺǷ ǡǽ ǴȀȁȋ Ǽǯ ǾǯǼǴǺǷ ǷǼȀȁǿȂǻǴǼȁǽDZ ǰȂdzǴȁ ǽȁǽǰǿǯǵǯȁȋȀȎ ǷǼȀȁǿȂǻǴǼȁ ǹǽȁǽǿȊǸ ǷȀǾǽǺȋǶǽDZǯǺȀȎ ǾǽȀǺǴdzǼǷǻ ȁǯǹ Ȇȁǽ DZǯǻ ǼǴ ǾǿǷdzǴȁȀȎ DZ ȀǺǴdzȂȍȈǷǸ ǿǯǶ ȂdzǴǿǵǷDZǯȁȋ ǹǼǽǾǹȂ ǻȊȇǷ ǽǵǷdzǯȁȋ ǽȁǹǿȊȁǷȎ ǻǴǼȍ Ƿ DZȊǰǷǿǯȁȋ Ȍȁǽȁ ǷǼȀȁǿȂǻǴǼȁ ȀǼǽDZǯ ǡǯǹ ǼǯǾǿǷǻǴǿ Ǽǯ ǿǷȀ 2- Ǽǯ ǾǯǼǴǺǷ ǷǼȀȁǿȂǻǴǼȁǽDZ ǽȁǽǰǿǯǵǯǴȁȀȎ Rectangle, Ƿ Ǿǽ ǼǯǵǯȁǷȍ ǹǼǽǾǹǷ ǻȊ ȇǷ DZȊ ȂDZǷdzǷȁǴ ǽǹǼǽ Ȁ ǽȀȁǯǺȋǼȊǻǷ dzǽȀȁȂǾǼȊǻǷ ǷǼȀȁǿȂǻǴǼȁǯǻǷ DZǷǶȂǯǺȋǼȊȄ ȌǺǴǻǴǼȁǽDZ ȌȁǽDzǽ ȁǷǾǯ ǔȀǺǷ DZȊǰǿǯȁȋ Ellipse Ƿ ǼǯǿǷȀǽDZǯȁȋ Ȁ ǴDzǽ ǾǽǻǽȈȋȍ Ȇȁǽ-ȁǽ Ǽǯ ǿǯǰǽȆǴǸ ǾǽDZǴǿȄǼǽȀȁǷ Ǽǯ ǾǯǼǴǺǷ ǷǼȀȁǿȂǻǴǼȁǽDZ ǰȂdzǴȁ ǽȁǽǰǿǯǵǯȁȋȀȎ ǶǼǯȆǽǹ Ellipse ǯ ǼǴ Rectangle.
ǞǯǼǴǺȋ DZǶǯǷǻǽdzǴǸȀȁDZǷǸ ǞǯǼǴǺȋ DZǶǯǷǻǽdzǴǸȀȁDZǷǸ ǾǿǴdzȀȁǯDZǺǴǼǯ Ǽǯ ǿǷȀ 2- Ƿ ǽǰȊȆǼǽ ǿǯȀǾǽǺǯDzǯǴȁȀȎ ǾǿǯDZǴǴ ǾǯǼǴǺǷ ǷǼȀȁǿȂǻǴǼ ȁǽDZ ǝǼǯ ȀǽǶdzǯǼǯ Ȁ ȅǴǺȋȍ ȂǾǿǽȈǴǼǷȎ DZȊǾǽǺǼǴǼǷȎ ȀǺǴdzȂȍȈǷȄ ǶǯdzǯȆ x
ǞǿǽȀǻǽȁǿ DZȀǴȄ ǽǰȉǴǹȁǽDZ ǿǯǰǽȆǴǸ ǾǽDZǴǿȄǼǽȀȁǷ ǯ ȁǯǹǵǴ ǷȄ ǷǴǿǯǿȄǷǷ ǾǿǷ ǷȀǾǽǺȋǶǽDZǯǼǷǷ ǽǰȉǴǹȁǽDZǹǽǼȁǴǸǼǴǿǽDZ
ǒǺǯDZǯ ǗȀǾǽǺȋǶǽDZǯǼǷǴ ([SUHVVLRQ %OHQG Ȁ Silverlight 2
x
ǑȊǰǽǿ ǽǰȉǴǹȁǽDZ dzǺȎ ǷȄ ǷǶǻǴǼǴǼǷȎ Ǭȁǽ ǼǴ DZȀǴDzdzǯ DZǽǶǻǽǵǼǽ Ǽǯ ǿǯǰǽȆǴǸ ǾǽDZǴǿȄǼǽȀȁǷ ǾǽȁǽǻȂ Ȇȁǽ ǽǰȉǴǹȁȊ ǻǽDzȂȁ ǿǯǶǻǴȈǯȁȋȀȎ DZǼǴ ȌǹǿǯǼǯ ǷǺǷ Ƕǯ dzǿȂDzǷǻǷ ǽǰȉǴǹȁǯǻǷ.
x
ǠǽǶdzǯǼǷǴ Ƿ ǷǶǻǴǼǴǼǷǴ DZǿǴǻǴǼǼȊȄ ȇǹǯǺ ǯǼǷǻǯȅǷǸ ǐǽǺǴǴ ǾǽdzǿǽǰǼǽ ǽǰ Ȍȁǽǻ ǰȂdzǴȁ ǿǯȀȀǹǯǶǯǼǽ DZ ǿǯǶdzǴǺǴ ©ǗȀǾǽǺȋǶǽDZǯǼǷǴ Blend dzǺȎ ȀǽǶdzǯǼǷȎ ǯǼǷǻǯȅǷǸª dzǯǺǴǴ DZ ȌȁǽǸ DzǺǯDZǴ
39
ǞǯǼǴǺȋ DZǶǯǷǻǽdzǴǸȀȁDZǷǸ ǷǻǴǴȁ dzDZǯ ǿǯǶǼȊȄ DZǷdzǯ ǾǽdzȀDZǴȁǹǷ ǑȊǰǿǯǼǼȊǸ DZ ǼǯȀȁǽȎȈǷǸ ǻǽǻǴǼȁ ȌǺǴǻǴǼȁ ǾǽdzȀDZǴȆǷDZǯǴȁȀȎ ȀǴǿȊǻ ǜǯ ǿǷȀ 2- ǻǽǵǼǽ DZǷdzǴȁȋ Ȇȁǽ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Border (ǒǿǯǼǷȅǯ DZȊdzǴǺǴǼ ȀǴǿȊǻ ǑȊdzǴǺǴǼǼȊǸ ǽǰȉǴǹȁ ǻǽǵǼǽ ǷǶǻǴǼȎȁȋ ǷȀǾǽǺȋǶȂȎ ǽǹǼǽ ȀDZǽǸȀȁDZ ǷǺǷ ǾǴǿǴȁȎDzǷDZǯȎ ǴDzǽ Ǿǽ ǿǯǰǽȆǴǸ ǾǽDZǴǿȄǼǽȀȁǷ. ǤǽȁȎ Ǽǯ ȆǴǿǼǽ-ǰǴǺǽǻ ǿǷȀȂǼǹǴ ǽǼ ǹǯǵǴȁȀȎ ȀǴǿȊǻ Ǽǯ ȌǹǿǯǼǴ ǹǽǻǾȋȍȁǴǿǯ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ LayoutRoot (ǙǽǿǴǼȋ ǹǽǻǾǽǼǽDZǹǷ ǰȊǺ ǰȊ ǽǰDZǴdzǴǼ ǵǴǺȁǽǸ ǿǯǻǹǽǸ ǜǯ ǿǯǰǽȆǴǸ ǾǽDZǴǿȄǼǽȀȁǷ ȁǯǹǵǴ ǰȂdzǴȁ DZǷdz Ǽǯ Ȍȁǯ ǵǴǺȁǯȎ ǿǯǻǹǯ ǝǼǯ ȂǹǯǶȊDZǯǴȁ Ǽǯ ȁǽ Ȇȁǽ dzǯǼǼȊǸ ǹǽǼȁǴǸǼǴǿ DZȊǰǿǯǼ DZ ǼǯȀȁǽȎȈǷǸ ǻǽǻǴǼȁ ǙǿǽǻǴ ǿǯǰǽȁȊ Ȁ ǽǰȉǴǹȁǯǻǷ ǾǯǼǴǺȋ DZǶǯǷǻǽdzǴǸȀȁDZǷǸ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ȀǽǶdzǯǼǷȎ ǯǼǷǻǯȅǷǸ Ƿ ǿǯȀǹǯdzǿǽ DZǽǹ ǓǴǺǯǴȁȀȎ Ȍȁǽ ǾȂȁǴǻ ǼǯǵǯȁǷȎ ǹǼǽǾǹǷ Ȁǽ ǶǼǯǹǽǻ ǾǺȍȀ DZDZǴǿȄȂ ǾǯǼǴǺǷ DZǶǯǷǻǽdzǴǸȀȁDZǷǸ ǑǽǶǻǽǵ ǼȊǴ ǾȂȁǷ ȀǽǶdzǯǼǷȎ ǯǼǷǻǯȅǷǸ ǰȂdzȂȁ ǿǯȀȀǻǽȁǿǴǼȊ DZ ǿǯǶdzǴǺǴ ©ǗȀǾǽǺȋǶǽDZǯǼǷǴ Blend dzǺȎ ȀǽǶdzǯǼǷȎ ǯǼǷ ǻǯȅǷǸª dzǯǺǴǴ DZ dzǯǼǼǽǸ DzǺǯDZǴ
ǟǗǠ 7 ǞǯǼǴǺȋ DZǶǯǷǻǽdzǴǸȀȁDZǷǸ
ǟǯǰǽȆǯȎ ǾǽDZǴǿȄǼǽȀȁȋ ǟǯǰǽȆǯȎ ǾǽDZǴǿȄǼǽȀȁȋ ² ǽȀǼǽDZǼǯȎ ǾǯǼǴǺȋ ȌǹǿǯǼǯ Expression Blend IDE. ǖdzǴȀȋ ǻǽǵǼǽ ǻǯǼǷǾȂǺǷǿǽDZǯȁȋ DZȀǴǻǷ ǽǰȉǴǹȁǯǻǷ DZǷǶȂǯǺȋǼǽ ǷǺǷ ǾȂȁǴǻ ǼǴǾǽȀǿǴdzȀȁDZǴǼǼǽDzǽ ǷǶǻǴǼǴǼǷȎ ǺǴǵǯȈǴDzǽ DZ ǽȀǼǽDZǴ XAML-ǹǽdzǯ Ǒ ǾǿǯDZǽǸ ȆǯȀȁǷ ǿǯǰǽȆǴǸ ǾǽDZǴǿȄǼǽȀȁǷ ǷǻǴǴȁȀȎ ȁǿǷ DZǹǺǯdzǹǷ x
ǑǹǺǯdzǹǯ 'HVLJQ ǓǷǶǯǸǼ ǽȁǹǿȊDZǯǴȁ ǿǯǰǽȆȂȍ ǾǽDZǴǿȄǼǽȀȁȋ.
x
ǑǹǺǯdzǹǯ XAML ǽȁǹǿȊDZǯǴȁ ǽǹǼǽ ǿǴdzǯǹȁǷǿǽDZǯǼǷȎ ;$0/-ǹǽdzǯ
x
ǑǹǺǯdzǹǯ Split ǠǽDZǻǴȀȁǷȁȋ ǽȁǹǿȊDZǯǴȁ ǿǯǶdzǴǺǴǼǼǽǴ ǽǹǼǽ ǽdzǼǯ ǾǽǺǽDZǷǼǯ ǹǽȁǽǿǽDzǽ ǾǿǴdzȀȁǯDZǺȎǴȁ ǿǯ ǰǽȆȂȍ ǾǽDZǴǿȄǼǽȀȁȋ Ƿ DZǽ DZȁǽǿǽǸ ǾǽǺǽDZǷǼǴ ǽȁǽǰǿǯǵǯǴȁȀȎ ;$0/.
ǟǯǰǽȆǯȎ ǾǽDZǴǿȄǼǽȀȁȋ DZ ȀǽDZǻǴȈǴǼǼǽǻ ǿǴǵǷǻǴ ǾǿǴdzȀȁǯDZǺǴǼǯ Ǽǯ ǿǷȀ -8.
40
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǟǗǠ. 2 8 ǟǯǰǽȆǯȎ ǾǽDZǴǿȄǼǽȀȁȋ DZ ȀǽDZǻǴȈǴǼǼǽǻ ǿǴǵǷǻǴ
ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ DZ ǿǴǵǷǻǴ ǾǿǽȀǻǽȁǿǯ dzǷǶǯǸǼǯ dzǽȀȁȂǾǼǯ DZǽǶǻǽǵǼǽȀȁȋ Zoom ǛǯȀȇȁǯǰ ǾǽȌȁǽ ǻȂ ǾǿǷ ǿǯǰǽȁǴ Ǽǯdz ȀǺǽǵǼȊǻǷ ǷǼȁǴǿȃǴǸȀǯǻǷ ǻǽǵǼǽ ȂDZǴǺǷȆǷDZǯȁȋ ǻǯȀȇȁǯǰ dzǺȎ ǰǽǺǴǴ dzǴȁǯǺȋǼǽDzǽ Ǿǿǽ Ȁǻǽȁǿǯ Ƿ ȂǻǴǼȋȇǯȁȋ ǻǯȀȇȁǯǰ ǷǶǽǰǿǯǵǴǼǷȎ dzǺȎ ǾǽǺȂȆǴǼǷȎ ǽǰȈǴDzǽ DZǷdzǯ ǓǺȎ ȌȁǽDzǽ ǷȀǾǽǺȋǶȂǴȁȀȎ ǷǼȀȁ ǿȂǻǴǼȁ Zoom ǿǯȀǾǽǺǯDzǯȍȈǷǸȀȎ DZ ǼǷǵǼǴǻ ǺǴDZǽǻ ȂDzǺȂ ǿǯǰǽȆǴǸ ǾǽDZǴǿȄǼǽȀȁǷ ǔDzǽ ǻǽǵǼǽ ǿǯǶDZǴǿǼȂȁȋ Ƿ DZȊǰǿǯȁȋ ȀȁǯǼdzǯǿȁǼȊǸ ǻǯȀȇȁǯǰ ǻǽǵǼǽ DZDZǴȀȁǷ ǽǾǿǴdzǴǺǴǼǼǽǴ ǶǼǯȆǴǼǷǴ DZ ǾǿǴdzǽȀȁǯDZǺǴǼǼǽǻ ǾǽǺǴ ǷǺǷ ȂȀ ȁǯǼǽDZǷȁȋ ǶǯdzǯǼǼȊǸ ǻǯȀȇȁǯǰ Ȁ ǾǽǻǽȈȋȍ ǻȊȇǷ
ǞǯǼǴǺȋ ǾǿǽǴǹȁǯ ǞǯǼǴǺȋ ǾǿǽǴǹȁǯ ǾǿǴdzȀȁǯDZǺǴǼǼǯȎ Ǽǯ ǿǷȀ 2- ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ȂǾǿǯDZǺǴǼǷȎ ȃǯǸǺǯǻǷ ǾǿǽǴǹȁǯ Ǧȁǽ DZǯǵ Ǽǽ ǶǯǻǴȁǷȁȋ ǽǰ ȌȁǽǸ ǾǯǼǴǺǷ Ȍȁǽ ǷȀǾǽǺȋǶǽDZǯǼǷǴ ǹǽǼȁǴǹȀȁǼȊȄ ǻǴǼȍ Ǒ ǶǯDZǷȀǷǻǽȀȁǷ ǽȁ ȁǽDzǽ DZ ǹǯǹǽǻ ǻǴȀȁǴ ǾǯǼǴǺǷ ǼǯȄǽdzǷȁȀȎ ǹȂǿȀǽǿ DZ ǻǽǻǴǼȁ ȈǴǺȆǹǯ ǾǿǯDZǽǸ ǹǼǽǾǹǽǸ ǻȊȇǷ ǾǽȎDZǺȎȍȁȀȎ ǿǯǶǼȊǴ Ǽǽ Ȁǽ ǽȁDZǴȁȀȁDZȂȍȈǷǴ ǹǽǼȁǴǹȀȁǼȊǴ ǻǴǼȍ ǑǽǶǻǽǵǼǽ DZǯǻ ǶǼǯǹǽǻȊ ǹǽǼȁǴǹȀȁǼȊǴ ǻǴǼȍ ǾǿǴdzǺǯDzǯȍȈǷǴ ǹǽ ǻǯǼdzȊ dzǺȎ ǽǾǿǴdzǴǺǴǼǼǽǸ ǾǯǼǴǺǷ Ǽǽ DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ ǿǯǶǼȊǴ ǻǴǼȍ DZȊDZǽdzȎȁȀȎ Ǿǽ ȈǴǺȆǹȂ ǾǿǯDZǽǸ ǹǼǽǾǹǽǸ ǻȊȇǷ Ǽǯ ǿǴȇǴǼǷǷ ǾǿǽǴǹȁǴ ǾǯǾǹǴ References ǠȀȊǺǹǷ Ƿ dzǿȂDzǷȄ ȌǺǴǻǴǼȁǽDZ ǾǯǼǴǺǷ ǾǿǽǴǹȁǯ
ǒǺǯDZǯ ǗȀǾǽǺȋǶǽDZǯǼǷǴ ([SUHVVLRQ %OHQG Ȁ Silverlight 2
41
ǟǗǠ 9 ǞǯǼǴǺȋ ǾǿǽǴǹȁǯ
Solution ǟǴȇǴǼǷǴ ² Ȍȁǽ ǹǽǺǺǴǹȅǷȎ ǷǶ ǽdzǼǽDzǽ ǷǺǷ ǰǽǺǴǴ ǾǿǽǴǹȁǽDZ ǞǿǷ ǿǴdzǯǹȁǷǿǽDZǯǼǷǷ ǿǴȇǴǼǷȎ Ƿǻ ǻǽǵǼǽ ȂǾǿǯDZǺȎȁȋ ǹǯǹ ȂDzǽdzǼǽ DZȊǾǽǺǼȎȁȋ ǴDzǽ ȀǰǽǿǹȂ ǽȁǺǯdzǹȂ ǽȆǷȀȁǹȂ Ƿ ȂǾǿǯDZǺǴǼǷǴ ǽȁdzǴǺȋǼȊǻǷ ǾǿǽǴǹ ȁǯǻǷ ǜǯ ǿǷȀ 2- ǿǴȇǴǼǷǴ TestApp ǿǯȀǾǽǺǯDzǯǴȁȀȎ DZDZǴǿȄȂ ǾǯǼǴǺǷ ǾǿǽǴǹȁǯ Ƿ ǾǯǼǴǺȋ ǾǽǹǯǶȊDZǯǴȁ Ȇȁǽ dzǯǼǼǽǴ ǿǴȇǴǼǷǴ ȀǽdzǴǿǵǷȁǽdzǷǼ ǾǿǽǴǹȁ Project ǞǿǽǴǹȁ ² Ȍȁǽ ǹǽǺǺǴǹȅǷȎ ȌǺǴǻǴǼȁǽDZ ȀǽȆǴȁǯǼǷǴ ǹǽȁǽǿȊȄ ǽǰǿǯǶȂǴȁ ǾǿǷǺǽǵǴǼǷǴ ȀǽdzǴǿǵǯȈǴǴ ǽdz ǼȂ ǷǺǷ ǰǽǺǴǴ ȀȁǿǯǼǷȅ Silverlight. ǑȀǴ ȀȀȊǺǹǷ Ǽǯ DZǼǴȇǼǷǴ ǹǽǻǾǽǼǴǼȁȊ ǼǴǽǰȄǽdzǷǻȊǴ dzǯǼǼǽǻȂ ǾǿǷǺǽ ǵǴǼǷȍ ǼǯȄǽdzȎȁȀȎ DZ ǾǯǾǹǴ References ǽǾǷȀǯǼǷȎ ǾǿǽǴǹȁǯ Ǟǽ ǾǿǯDZǽǻȂ ȈǴǺȆǹȂ ǻȊȇǷ ǾǿǽǴǹȁǯ ǾǽȎDZǺȎǴȁȀȎ ǹǽǼȁǴǹȀȁǼǽǴ ǻǴǼȍ Ȁ ǾǽǻǽȈȋȍ ǹǽȁǽǿǽDzǽ ǻǽǵǼǽ ǻǯǼǷǾȂǺǷǿǽDZǯȁȋ ȀǽdzǴǿǵǷǻȊǻ ǾǿǽǴǹȁǯ Ǒ ǹǽǼȁǴǹȀȁǼǽǻ ǻǴǼȍ ǾǿǴdzǺǯDzǯȍȁȀȎ ȁǯǹǷǴ ǽǾȅǷǷ ǹǯǹ dzǽǰǯDZǺǴǼǷǴ ǼǽDZȊȄ ȇǯǰǺǽǼǼȊȄ ȌǺǴǻǴǼȁǽDZ dzǽǰǯDZǺǴǼǷǴ ȀȂȈǴȀȁ DZȂȍȈǷȄ ȌǺǴǻǴǼȁǽDZ ǷǶ dzǿȂDzǷȄ ǾǿǽǴǹȁǽDZ ǷǺǷ ȂdzǯǺǴǼǷǴ ȌǺǴǻǴǼȁǽDZ ǷǶ ǾǿǽǴǹȁǯ ǞǯǾǹǯ References DZ ǾǿǽǴǹȁǴ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ȂǾǿǯDZǺǴǼǷȎ ȀȀȊǺǹǯǻǷ Ǽǯ ȀǰǽǿǹǷ ȀǽdzǴǿǵǯȈǷǴ ǷǼȃǽǿǻǯ ȅǷȍ ǹǽȁǽǿǯȎ ǼǴǽǰȄǽdzǷǻǯ DZ ȀǽǶdzǯDZǯǴǻǽǻ ǾǿǽǴǹȁǴ ǜǯǾǿǷǻǴǿ ǴȀǺǷ ǼǴǽǰȄǽdzǷǻ ȀǾǴȅǷǯǺȋǼȊǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǽǼ ǰȂdzǴȁ ȀǹǽǻǾǷǺǷǿǽDZǯǼ DZ ȀǰǽǿǹȂ ǡǽDzdzǯ ǴȀǺǷ DZȊ ȂǹǯǵǴȁǴ ȌȁȂ ȀǰǽǿǹȂ DZ ȀȀȊǺǹǯȄ DZȊ ȀǻǽǵǴ ȁǴ ǷȀǾǽǺȋǶǽDZǯȁȋ ǴǴ DZ ȀDZǽǴǻ ǾǿǷǺǽǵǴǼǷǷ ǞǯǾǹǯ Properties ǠDZǽǸȀȁDZǯ ȀǽdzǴǿǵǷȁ ȃǯǸǺ ǻǯǼǷȃǴȀȁǯ ǾǿǷǺǽǵǴǼǷȎ ǽǾǷȀȊDZǯȍȈǷǸ DZȀǴ ȀDZǽǸȀȁDZǯ ǾǿǽǴǹ ȁǯ DZǹǺȍȆǯȎ ȀǾǷȀǽǹ ȀȀȊǺǽǹ ȆȁǽǰȊ ǾǿǷǺǽǵǴǼǷǴ ǾǽǼǷǻǯ̨̣ ǽȁǹȂdzǯ ǽǼǷ ǶǯDzǿȂǵǯȍȁȀȎ DZǽ DZǿǴǻȎ DZȊǾǽǺǼǴ ǼǷȎ ǜǴ ȀǺǴdzȂǴȁ ǾȂȁǯȁȋ ǾǯǾǹȂ Properties Ȁ ǾǯǼǴǺȋȍ ȀDZǽǸȀȁDZ ǽǰǽǶǼǯȆǴǼǼǽǸ DZǹǺǯdzǹǽǸ Properties DZDZǴǿȄȂ ǽǹǼǯ ǹǽȁǽǿǽǴ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 2- Ƿ ǽǾǷȀȊDZǯǴǻǽǸ ǰǽǺǴǴ ǾǽdzǿǽǰǼǽ DZ ȀǺǴdzȂȍȈǴǻ ǿǯǶdzǴǺǴ
ǞǯǼǴǺȋ ȀDZǽǸȀȁDZ ǞǯǼǴǺȋ ȀDZǽǸȀȁDZ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ȂǾǿǯDZǺǴǼǷȎ DZȀǴǻǷ DZǷǶȂǯǺȋǼȊǻǷ ǯȀǾǴǹȁǯǻǷ ǽȁdzǴǺȋǼǽDzǽ ȌǺǴǻǴǼȁǯ Ǟǽ ȀǹǽǺȋǹȂ ȌǺǴǻǴǼȁȊ XAML ǷǻǴȍȁ ǻǼǽǵǴȀȁDZǽ ǼǯȀȁǿǯǷDZǯǴǻȊȄ ȀDZǽǸȀȁDZ Ȍȁǯ ǾǯǼǴǺȋ ǾǿǴdzǺǯDzǯǴȁ dzDZǯ ǽȆǴǼȋ Ǿǽ ǺǴǶǼȊȄ ȎǿǺȊǹǯ Ǟǽdz ǾǴǿDZȊǻ ȎǿǺȊǹǽǻ ǾǿǴdzȀȁǯDZǺǴǼȊ ȀDZǽǸȀȁDZǯ ǿǴdzǯǹȁǷǿȂǴǻǽDzǽ ȌǺǴǻǴǼȁǯ ȀDzǿȂǾǾǷǿǽDZǯǼǼȊǴ Ǿǽ ǹǯȁǴDzǽ ǿǷȎǻ ǝǰȊȆǼǽ ǶdzǴȀȋ ǾǿǴdzǽȀȁǯDZǺȎǴȁȀȎ dzǽȀȁȂǾ ǹ ȀǺǴdzȂȍȈǷǻ DZǷǶȂǯǺȋǼȊǻ ǯȀǾǴǹȁǯǻ ȌǺǴǻǴǼȁǽDZ x
Brushes ǙǷȀȁǷ ǞǽǶDZǽǺȎǴȁ ǶǯdzǯDZǯȁȋ dzǺȎ ȌǺǴǻǴǼȁǯ ǶǯǺǷDZǹȂ Ƿ ǽǰDZǽdzǹȂ ǯ ȁǯǹǵǴ ǷȀǾǽǺȋǶǽDZǯȁȋ ǻǯȀǹȂ ǾǿǽǶǿǯȆǼǽȀȁǷ ǜǯǻǼǽDzǽ ǰǽǺǴǴ ǾǽdzǿǽǰǼǽ ǷȀǾǽǺȋǶǽDZǯǼǷǴ ǹǷȀȁǴǸ ǿǯȀȀǻǯȁǿǷDZǯǴȁȀȎ DZ ǒǺǯDZǴ ©ǝȀǼǽ DZȊ XAMLª.
x
Appearance ǑǷdz ǞǽǶDZǽǺȎǴȁ ǶǯdzǯDZǯȁȋ dzǺȎ ǽǰȉǴǹȁǯ ǿǯȀȇǷǿǴǼǼȊǴ ȀDZǽǸȀȁDZǯ ǽȁǽǰǿǯǵǴǼǷȎ. ǝǰǿǯȁǷ ȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ dzǽȀȁȂǾǼȊǴ ȀDZǽǸȀȁDZǯ ǽȁǽǰǿǯǵǴǼǷȎ ǰȂdzȂȁ ǻǴǼȎȁȋȀȎ DZ ǶǯDZǷȀǷǻǽȀȁǷ ǽȁ ȁǽDzǽ ǹǯǹǽǸ ǽǰȉǴǹȁ ǿǴdzǯǹȁǷǿȂǴȁȀȎ DZ ǼǯȀȁǽȎȈǷǸ ǻǽǻǴǼȁ ǜǯǾǿǷǻǴǿ ǴȀǺǷ ǿǴdzǯǹȁǷǿȂǴȁȀȎ ȌǺǴǻǴǼȁ Rectangle ǿǯǶ dzǴǺ Appearance ǾǯǼǴǺǷ ȀDZǽǸȀȁDZ ǾǿǴdzǺǽǵǷȁ Ƕǯdzǯȁȋ ȁǯǹǽǸ ǾǯǿǯǻǴȁǿ ǹǯǹ ǿǯdzǷȂȀ ȀǹǿȂDzǺǴǼǷȎ ȂDzǺǽDZ Ǽǽ ǾǿǷ ǿǴdzǯǹȁǷǿǽDZǯǼǷǷ ȌǺǴǻǴǼȁǯ Button ǹǽȁǽǿȊǸ ǼǴ ǷǻǴǴȁ ǿǯdzǷȂȀǯ ȀǹǿȂDzǺǴǼǷȎ Ȍȁǯ ǽǾȅǷȎ ǰȂdzǴȁ ǼǴ dzǽȀȁȂǾǼǯ
x
Layout ǙǽǻǾǽǼǽDZǹǯ) ǞǽǶDZǽǺȎǴȁ ǿǴdzǯǹȁǷǿǽDZǯȁȋ ǿǯǶǺǷȆǼȊǴ ǽǾȅǷǷ ǹǽǻǾǽǼǽDZǹǷ dzǺȎ ǽǰȉǴǹȁǯ ȁǯ ǹǷǴ ǹǯǹ Width ǧǷǿǷǼǯ Height ǑȊȀǽȁǯ Ƿ ǽǾȅǷǷ Alignment ǑȊǿǯDZǼǷDZǯǼǷǴ ǡǯǹǵǴ ǽǾȅǷǷ ǹǽǻǾǽ ǼǽDZǹǷ ǻǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ dzǺȎ ǷǶǻǴǼǴǼǷȎ ǾǽǺǽǵǴǼǷȎ ǽǰȉǴǹȁǯ DZǼȂȁǿǷ ȀǴȁǹǷ ǴȀǺǷ ǹǽǻǾǽǼǽDZǹǯ DZȊ ǾǽǺǼȎǴȁȀȎ Ǽǯ ȀǴȁǹǴ
x
Common Properties ǝǰȈǷǴ ȀDZǽǸȀȁDZǯ ǑǹǺȍȆǯǴȁ ȀDZǽǸȀȁDZǯ ǽǰȈǷǴ dzǺȎ dzǯǼǼǽDzǽ ȁǷǾǯ ǽǰȉǴǹȁǽDZ ǜǯǾǿǷǻǴǿ ǶdzǴȀȋ ǽǰȊȆǼǽ ǿǴdzǯǹȁǷǿȂȍȁȀȎ ǽǰȈǷǴ ȀDZǽǸȀȁDZǯ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǼǴ ȎDZǺȎȍȈǷȄȀȎ ȃǷDzȂǿǯǻǷ ǓǽȀȁȂǾǼǽȀȁȋ ȌȁǷȄ ǽǾȅǷǸ ǶǯDZǷȀǷȁ ǽȁ ȁǷǾǯ ǿǴdzǯǹȁǷǿȂǴǻǽDzǽ ǽǰȉǴǹȁǯ ǜǯǾǿǷǻǴǿ ǴȀǺǷ ǿǴ dzǯǹȁǷǿȂǴȁȀȎ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǽǰȈǷǻ ȀDZǽǸȀȁDZǽǻ ǰȂdzǴȁ ǴDzǽ ǷǼdzǴǹȀ ǾǴǿǴȄǽdzǯ Ǿǽ ǹǺǯDZǷȇǴ Tab Ǽǽ DZ ȀǺȂȆǯǴ ǿǴdzǯǹȁǷǿǽDZǯǼǷȎ ȃǷDzȂǿȊ ǷǼdzǴǹȀ ǾǴǿǴȄǽdzǯ Ǿǽ ǹǺǯDZǷȇǴ Tab ǰȂdzǴȁ ǼǴdzǽȀȁȂǾǴǼ
x
Transform ǡǿǯǼȀȃǽǿǻǯȅǷȎ ǝǰǴȀǾǴȆǷDZǯǴȁ DZǽǶǻǽǵǼǽȀȁȋ ǿǴdzǯǹȁǷǿǽDZǯȁȋ ȀDZǽǸȀȁDZǽ RenderTransform ǡǿǯǼȀȃǽǿǻǯȅǷȎ DZǷǶȂǯǺȋǼǽDzǽ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ǽǰȉǴǹȁǯ Ǭȁǽ ȀDZǽǸȀȁDZǽ ǽǾǿǴdzǴǺȎǴȁ ǹǯǹ ȀǷȀȁǴǻǯ ȃǽǿǻǷǿǽDZǯǼǷȎ DZǷǶȂǯǺȋǼǽDzǽ ǽȁǽǰǿǯǵǴǼǷȎ ǻǽǵǴȁ ǷǶǻǴǼȎȁȋ ǽǰȉǴǹȁ ǐǽǺǴǴ ǾǽdzǿǽǰǼǽ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ǿǯȀȀǻǯȁǿǷDZǯȍȁȀȎ DZ ǒǺǯDZǴ ©ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷǻǯȅǷȎ DZ XAMLª
42
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
x
Miscellaneous ǟǯǶǼǽǴ DzǽǿǷȍ
ǛǴȀȁǽ ǿǯǶǻǴȈǴǼǷȎ DZȀǴȄ ȀDZǽǸȀȁDZ ǹǽȁǽǿȊǴ ǼǴ ǾǽdzȄǽdzȎȁ ǼǷ Ǿǽdz ǽdzǼȂ ǹǯȁǴ
ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ ȌȁǷ ǹǯȁǴDzǽǿǷǷ ǻǽDzȂȁ ǷǻǴȁȋ ǾǽdzǹǯȁǴDzǽǿǷǷ Ǣ ǻǼǽDzǷȄ ǷǶ ǼǷȄ ǴȀȁȋ ȀȁǿǴǺǹǯ DZǼǷǶȂ Ȁ ǾǽǻǽȈȋȍ ǹǽȁǽǿǽǸ ǻǽǵǼǽ ǿǯǶDZǽǿǯȆǷDZǯȁȋ Ƿ ȀDZǽǿǯȆǷDZǯȁȋ ǾǯǼǴǺȋ ȀDZǽǸȀȁDZ Ǭȁǽ ǾǽǶDZǽǺȎǴȁ ȀǹǿȊDZǯȁȋ ȀDZǽǸ ȀȁDZǯ ǹǽȁǽǿȊǴ ǷȀǾǽǺȋǶȂȍȁȀȎ ǿǴǵǴ. ǑȁǽǿǽǸ ȎǿǺȊǹ ǾǯǼǴǺǷ ȀDZǽǸȀȁDZ ² Ȍȁǽ Search ǞǽǷȀǹ ǹǽȁǽǿȊǸ ǾǽǶDZǽǺȎǴȁ DZȊǾǽǺǼȎȁȋ ǾǽǷȀǹ ǽǾǿǴdzǴǺǴǼǼǽ Dzǽ ȀDZǽǸȀȁDZǯ ǜǯǾǿǷǻǴǿ ǴȀǺǷ ȁǿǴǰȂǴȁȀȎ ǿǴdzǯǹȁǷǿǽDZǯȁȋ ǼǴǹǽȁǽǿȊǴ ȀDZǽǸȀȁDZǯ ȇǿǷȃȁǯ Ǽǽ DZȊ ǼǴ ǶǼǯǴȁǴ ǷǻȎ ȀǯǻǽDzǽ ȀDZǽǸȀȁDZǯ ǻǽǵǼǽ DZDZǴȀȁǷ font DZ ȀȁǿǽǹȂ ǾǽǷȀǹǯ ǙǯȁǴDzǽǿǷǷ Ƿ dzǽȀȁȂǾǼȊǴ ȀDZǽǸȀȁDZǯ ǰȂdzȂȁ ǽȁ ȃǷǺȋȁǿǽDZǯǼȊ Ƿ Ǽǯ ǾǯǼǴǺȋ ǰȂdzȂȁ DZȊDZǴdzǴǼȊ ȁǽǺȋǹǽ ȁǴ ǷǶ ǼǷȄ ǹǽȁǽǿȊǴ ǷǻǴȍȁ ǽȁǼǽȇǴǼǷǴ ǹ ȇǿǷȃȁǯǻ Ǭȁǽ ǾǿǽǷȀȄǽdzǷȁ ǼǴǾǽȀǿǴdzȀȁDZǴǼǼǽ DZ ǾǿǽȅǴȀȀǴ DZDZǽdzǯ ȀǺǽDZǯ ǾǽǷȀǹǯ ǾǽȌȁǽǻȂ ǴȀǺǷ DZȊ ǷȈǴȁǴ ȀDZǽǸȀȁDZǽ ȇǿǷȃȁǯ ² ȁǴ dzǺȎ ǼǯȇǴDzǽ ǾǿǷǻǴǿǯ ǹǯǹ ȁǽǺȋǹǽ DZDZǴdzǴǼȊ ǰȂǹDZȊ fo ² DZȊ ȂDZǷdzǷȁǴ dzǽȀȁȂǾǼȊǴ ȀDZǽǸȀȁDZǯ ȁǯ ǹǷǴ ǹǯǹ foreground Ƿ rendertransform ǯ ȁǯǹǵǴ dzǽȀȁȂǾǼȊǴ ȀDZǽǸȀȁDZǯ ȇǿǷȃȁǯ ǹǯǹ ǾǽǹǯǶǯǼǽ DZ ǼǷǵǼǴǸ ȆǯȀ ȁǷ ǿǷȀ 2-10.
ǟǗǠ 10 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǾǯǼǴǺǷ ȀDZǽǸȀȁDZ.
ǡǴǾǴǿȋ ǿǯȀȀǻǽȁǿǷǻ ȁǽ ǹǯǹ ǻǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ DZȀǴ ȌȁǷ ǾǿǴdzȀȁǯDZǺǴǼǼȊǴ DZȊȇǴ ǷǼȀȁǿȂǻǴǼȁȊ dzǺȎ Ǿǽ ȀȁǿǽǴǼǷȎ ǾǿǷǺǽǵǴǼǷǸ Silverlight.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ Blend dzǺȎ ȀǽǶdzǯǼǷȎ ǾǿǷǺǽǵǴǼǷǸ Silverlight Ǚ ǽȀǼǽDZǼȊǻ ǽǿǷǴǼȁǷǿǽDZǯǼǼȊǻ Ǽǯ dzǷǶǯǸǼ ȃȂǼǹȅǷȎǻ ǹǽȁǽǿȊǴ ǻǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ DZ Blend dzǺȎ ȀǽǶdzǯ ǼǷȎ ǾǿǷǺǽǵǴǼǷȎ ǽȁǼǽȀȎȁȀȎ x
ǝǿDzǯǼǷǶǯȅǷȎ ǹǽǻǾǽǼǽDZǹǷ
x
ǟǯǶǻǴȈǴǼǷǴ Ƿ ǼǯȀȁǿǽǸǹǯ DZǷǶȂǯǺȋǼȊȄ ȌǺǴǻǴǼȁǽDZ
x
ǟǯǶǻǴȈǴǼǷǴ Ƿ ǼǯȀȁǿǽǸǹǯ DZǷǶȂǯǺȋǼȊȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ
x
ǠǽǶdzǯǼǷǴ ǯǼǷǻǯȅǷǸ
ǑȀǴ ȌȁǷ ȃȂǼǹȅǷǷ ǿǯȀȀǻǯȁǿǷDZǯȍȁȀȎ dzǯǺǴǴ DZ dzǯǼǼǽǸ DzǺǯDZǴ
ǙǽǻǾǽǼǽDZǹǯ Ǒ Silverlight dzǺȎ ȀǽǶdzǯǼǷȎ Ƿ ǽǿDzǯǼǷǶǯȅǷǷ ǹǽǻǾǽǼǽDZǹǷ ǾǿǷǺǽǵǴǼǷȎ ǷȀǾǽǺȋǶȂȍȁȀȎ ȀǾǴȅǷǯǺȋǼȊǴ ǷǼȀȁǿȂ ǻǴǼȁȊ ǞǽǺȋǶǽDZǯȁǴǺȍ dzǽȀȁȂǾǼȊ ǼǴȀǹǽǺȋǹǽ DZǯǿǷǯǼȁǽDZ ǿǯȀȀǻǽȁǿǷǻ ǹǯǵdzȊǸ ǷǶ ǼǷȄ Ǿǽ ǽȆǴǿǴdzǷ
ǒǺǯDZǯ ǗȀǾǽǺȋǶǽDZǯǼǷǴ ([SUHVVLRQ %OHQG Ȁ Silverlight 2
43
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀǴȁǹǷ ǬǺǴǻǴǼȁ ǹǽǻǾǽǼǽDZǹǷ Grid ǠǴȁǹǯ ǾǽǶDZǽǺȎǴȁ ǿǯȀǹǺǯdzȊDZǯȁȋ ȌǺǴǻǴǼȁȊ DZ ȀȁǿȂǹȁȂǿȂ ǾǽȄǽǵȂȍ Ǽǯ ȁǯǰǺǷȅȂ ǜǴ ǾȂȁǯǸȁǴ ȌǺǴǻǴǼȁ ǹǽǻǾǽǼǽDZǹǷ Grid Ȁ ȌǺǴǻǴǼȁǽǻ ȂǾǿǯDZǺǴǼǷȎ Grid ǹǽȁǽǿȊǸ ǽǰǴȀǾǴȆǷDZǯǴȁ ȃȂǼǹȅǷǽ ǼǯǺȋǼǽȀȁȋ ǯǼǯǺǽDzǷȆǼȂȍ ȌǺǴǹȁǿǽǼǼǽǸ ȁǯǰǺǷȅǴ ǞǿǷ ǷȀǾǽǺȋǶǽDZǯǼǷǷ ǷǼȀȁǿȂǻǴǼȁǯ ǹǽǻǾǽǼǽDZǹǷ Grid ǿǯȀ ǾǽǺǽǵǴǼǷǴ ȀDZǽǷȄ ȌǺǴǻǴǼȁǽDZ ǻǽǵǼǽ ǶǯdzǯDZǯȁȋ ȂǹǯǶȊDZǯȎ ǷȄ ǹǽǽǿdzǷǼǯȁȊ ǹǯǹ DZǷǿȁȂǯǺȋǼȊǴ ȀȁǿǽǹǷ Ƿ ȀȁǽǺǰȅȊ ǹǽǻǾǽǼǽDZǽȆǼǽDzǽ ȌǺǴǻǴǼȁǯ Grid. ǜǯǾǿǷǻǴǿ, ǿǯȀȀǻǽȁǿǷǻ ȀǺǴdzȂȍȈǷǸ XAML:
ǞǿǷ ȃǽǿǻǷǿǽDZǯǼǷǷ DZǷǶȂǯǺȋǼǽDzǽ ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ȍȁǽ ǰȂdzǴȁ DZȊDzǺȎdzǴȁȋ ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 2-11.
ǟǗǠ 11 ǙǼǽǾǹǷ ǿǯȀǾǽǺǽǵǴǼǼȊǴ ȀǺȂȆǯǸǼȊǻ ǽǰǿǯǶǽǻ
ǡǴǾǴǿȋ dzǺȎ ȂǾǽǿȎdzǽȆǷDZǯǼǷȎ ȌȁǷȄ ǹǼǽǾǽǹ ǻǽǵǼǽ Ƕǯdzǯȁȋ ǷȄ ǾǽǶǷȅǷǷ ǯǹǹȂǿǯȁǼǽ ǾǴǿǴȁȎDzǷDZǯȎ ǷȄ Ǿǽ ǿǯ ǰǽȆǴǸ ǾǽDZǴǿȄǼǽȀȁǷ ǜǽ DZ Ȍȁǽǻ ȀǺȂȆǯǴ DZǯǻ ǾǿǷȇǺǽȀȋ ǰȊ DZǽȀǾǽǺȋǶǽDZǯȁȋȀȎ ǷǼȀȁǿȂǻǴǼȁǽǻ ǻǯȀȇȁǯǰǷǿǽ DZǯǼǷȎ ȆȁǽǰȊ ȂǰǴdzǷȁȋȀȎ DZ ȁǽǻ Ȇȁǽ ǽǼǷ ȁǽȆǼǽ DZȊǿǽDZǼǴǼȊ Ǒ ǹǯȆǴȀȁDZǴ ǯǺȋȁǴǿǼǯȁǷDZǼǽDzǽ DZǯǿǷǯǼȁǯ ǻǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ ǹǽǻǾǽǼǽDZǽȆǼȊǸ ȌǺǴǻǴǼȁ Grid. ǖdzǴȀȋ ǻǴȀȁǽ ǾǽǺǽǵǴǼǷǴ ǹǼǽǾǹǷ Ǽǯ ȀǴȁǹǴ ǶǯdzǯǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ ǹǽǻǾǽǼǽDZǽȆǼȊȄ ȀDZǽǸȀȁDZ ǞǿǷ ȀǽǶdzǯǼǷǷ ǼǽDZǽDzǽ Silverlight ǾǿǽǴǹȁǯ DZȊ ȂDZǷdzǷȁǴ Ȇȁǽ ȃǯǸǺ 3DJH[DPO ȂǵǴ ǷǻǴǴȁ ǹǽǻǾǽǼǽDZǽȆǼȊǸ ȌǺǴǻǴǼȁ Grid Ǿǽdz ǷǻǴǼǴǻ LayoutRoot ǑȊǰǴǿǷȁǴ Ȍȁǽȁ ȌǺǴǻǴǼȁ Ǽǯ ǾǯǼǴǺǷ ,QWHUDFWLRQ ǑǶǯǷǻǽdzǴǸȀȁDZǷǴ Ƿ ǾǽȀǻǽȁǿǷȁǴ ǹǯǹǷǴ ǹǽǻǾǽǼǽ DZǽȆǼȊǴ ȀDZǽǸȀȁDZǯ Ȁ ǼǷǻ ȀDZȎǶǯǼȊ ǟǯǶDZǽǿǯȆǷDZǯǸȁǴ ǽǰǽǶǿǴDZǯȁǴǺȋ ȀDZǽǸȀȁDZ dzǽ ȁǴȄ Ǿǽǿ Ǿǽǹǯ ǼǴ ȂDZǷdzǷȁǴ Ǽǯ ȀȁǿǽǸǹǷ dzǺȎ ColumnDefinitions ǝǾǷȀǯǼǷȎ ȀȁǽǺǰȅǽDZ Ƿ RowDefinitions ǝǾǷȀǯǼǷȎ Ȁȁǿǽǹ ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 2-12.
ǟǗǠ 12 ǟǴdzǯǹȁǽǿ ǹǽǻǾǽǼǽDZǹǷ dzǺȎ ȀǴȁǹǷ
ColumnDefinitions Ƿ RowDefinitions ² ǹǽǺǺǴǹȅǷǷ ǾǽȌȁǽǻȂ ȀǾǿǯDZǯ ǽȁ ǹǯǵdzǽDzǽ ǷǶ ǼǷȄ ǿǯȀǾǽǺǯDzǯǴȁȀȎ ǹǼǽǾ ǹǯ Ȁ ǻǼǽDzǽȁǽȆǷǴǻ « Ǭȁǽ ȂǹǯǶȊDZǯǴȁ Ǽǯ ȁǽ Ȇȁǽ ǴȀǺǷ ȈǴǺǹǼȂȁȋ Ȍȁǽȁ ǾǯǿǯǻǴȁǿ ǽȁǹǿǽǴȁȀȎ dzǿȂDzǽǴ dzǷǯǺǽ
44
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
DzǽDZǽǴ ǽǹǼǽ ǑȊǰǴǿǷȁǴ ǹǼǽǾǹȂ ǿȎdzǽǻ Ȁ ǾǯǿǯǻǴȁǿǽǻ ColumnDefinitions Ƿ Ǽǯ ȌǹǿǯǼǴ ǾǽȎDZǷȁȀȎ ǿǴdzǯǹȁǽǿ ǹǽǺǺǴǹȅǷǷ ColumnDefinition ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 2-13.
ǟǗǠ 13 ǟǴdzǯǹȁǽǿ ǹǽǺǺǴǹȅǷǷ ColumnDefinition.
ǗȀǾǽǺȋǶȂǸȁǴ Ȍȁǽ dzǷǯǺǽDzǽDZǽǴ ǽǹǼǽ dzǺȎ dzǽǰǯDZǺǴǼǷȎ ȂdzǯǺǴǼǷȎ Ƿ ȂǾǿǯDZǺǴǼǷȎ ȀȁǽǺǰȅǯǻǷ ǨǴǺǹǼǷȁǴ ǹǼǽǾ ǹȂ Add Another Item ǓǽǰǯDZǷȁȋ ǴȈǴ ǽdzǷǼ ȌǺǴǻǴǼȁ ȁǿǷǵdzȊ Ƿ dzǽǰǯDZȋȁǴ ȁǿǷ ȀȁǽǺǰȅǯ ǞǽDZȁǽǿǷȁǴ ǯǼǯǺǽ DzǷȆǼȊǴ dzǴǸȀȁDZǷȎ dzǺȎ ǾǯǿǯǻǴȁǿǯ ȀDZǽǸȀȁDZǯ RowDefinitions ȆȁǽǰȊ ǾǽǺȂȆǷȁȋ ȀǴȁǹȂ ȀǽȀȁǽȎȈȂȍ ǷǶ ȁǿǴȄ Ȁȁǿǽǹ Ƿ ȁǿǴȄ ȀȁǽǺǰȅǽDZ ǞǽȀǺǴ DZǼǴȀǴǼǷȎ ȌȁǷȄ ǷǶǻǴǼǴǼǷǸ DZ ColumnDefinitions Ƿ RowDefinitions DZȊ ȂDZǷdzǷ ȁǴ Ǽǯ ǿǯǰǽȆǴǸ ǾǽDZǴǿȄǼǽȀȁǷ ǹǽǻǾǽǼǽDZǽȆǼȂȍ ȀǴȁǹȂ ï ǿǷȀ 2-14).
ǟǗǠ 2 14 ǙǽǻǾǽǼǽDZǽȆǼǯȎ ȀǴȁǹǯ 3 î 3.
ǡǴǾǴǿȋ ǾǿǷ ǿǯǶǻǴȈǴǼǷǷ ǺȍǰǽDzǽ ȌǺǴǻǴǼȁǯ Ǽǯ ȌǹǿǯǼǴ DZȊ ǰȂdzǴȁǴ DZǷdzǴȁȋ ǿǽǶǽDZȊǴ ǼǯǾǿǯDZǺȎȍȈǷǴ ǺǷǼǷǷ ȂǹǯǶȊDZǯȍȈǷǴ Ǽǯ ȁǽ ǹǯǹ ǻǽǵǼǽ DZȊǾǽǺǼǷȁȋ ǴDzǽ ǾǿǷDZȎǶǹȂ ǹ ǽǾǿǴdzǴǺǴǼǼǽǻȂ ȌǺǴǻǴǼȁȂ ȀǴȁǹǷ Ǭȁǽ ǾǽǹǯǶǯ Ǽǽ Ǽǯ ǿǷȀ 2- ǜǯ ǿǷȀȂǼǹǴ ǿǽǶǽDZȊǴ ǺǷǼǷǷ DZȊDzǺȎdzȎȁ ǹǯǹ ǰǽǺǴ ȁǽǺȀȁȊǴ ȀǴǿȊǴ ǡǯǹǯȎ ǾǿǷDZȎǶǹǯ ǹǼǽǾǹǷ ǹ ȀǴȁǹǴ Ƿ ȀȁǽǺǰȅȂ DzǯǿǯǼȁǷǿȂǴȁ Ȇȁǽ ǹǼǽǾǹǯ DZȀǴDzdzǯ ǰȂdzǴȁ ȀǽȄǿǯǼȎȁȋ dzǯǼǼȊǴ ǾǽǺǽǵǴǼǷǴ Ƿ ǿǯǶǻǴǿ ǽȁǼǽȀǷ ȁǴǺȋǼǽ ȀǴȁǹǷ ǞǽǻǴȀȁǷȁǴ dzǿȂDzȂȍ ǹǼǽǾǹȂ DZ ȅǴǼȁǿǯǺȋǼȂȍ ȎȆǴǸǹȂ ȀǴȁǹǷ ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 2-15. ǜǯ Ȍȁǽȁ ǿǯǶ ǼǴ DZȊ ǾǽǺǼȎǸȁǴ ǾǿǷDZȎǶǹȂ ǹ ȀǴȁǹǴ ǖǯȁǴǻ ǶǯǾȂȀȁǷȁǴ ǾǿǷǺǽǵǴǼǷǴ Ƿ ǾǽȌǹȀǾǴǿǷǻǴǼȁǷǿȂǸȁǴ Ȁ ǷǶǻǴǼǴǼǷȎǻǷ ǿǯǶ ǻǴǿǽDZ ǽǹǼǯ ǑȊ ȂDZǷdzǷȁǴ Ȇȁǽ ǽȁǼǽȀǷȁǴǺȋǼǽǴ ǻǴȀȁǽǾǽǺǽǵǴǼǷǴ Ƿ ǿǯǶǻǴǿ ǾǴǿDZǽǸ ǹǼǽǾǹǷ ǰȂdzȂȁ ǽȀȁǯDZǯȁȋȀȎ ǼǴǷǶǻǴǼǼȊǻǷ ȁǽDzdzǯ ǹǯǹ DZȁǽǿǯȎ ǹǼǽǾǹǯ ǰȂdzǴȁ ǻǴǼȎȁȋ ȀDZǽǷ ȇǷǿǷǼȂ ǷǷǺǷ DZȊȀǽȁȂ ȀǽȄǿǯǼȎȎ ǾǿǽǾǽǿȅǷǷ ǽȁǼǽȀǷȁǴǺȋǼǽ ǿǯǶǻǴǿǽDZ ȌǹǿǯǼǯ
ǒǺǯDZǯ ǗȀǾǽǺȋǶǽDZǯǼǷǴ ([SUHVVLRQ %OHQG Ȁ Silverlight 2
45
ǟǗǠ 15 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǹǽǻǾǽǼǽDZǹǷ Grid.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ Canvas ǙǽǻǾǽǼǽDZǽȆǼȊǸ ȌǺǴǻǴǼȁ Canvas ȎDZǺȎǴȁȀȎ ǾǽDZǴǿȄǼǽȀȁȋȍ dzǺȎ ǿǷȀǽDZǯǼǷȎ Ȁ ȀǽDZǴǿȇǴǼǼǽ ȀDZǽǰǽdzǼȊǻ ȃǽǿǻǯȁǽǻ ǝǾǿǴdzǴǺǷȁȋ ǻǴȀȁǽǾǽǺǽǵǴǼǷǴ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ ǻǽǵǼǽ ǶǯdzǯDZǯȎ ǴDzǽ ȀDZǽǸȀȁDZǯ Canvas.Top Ƿ Canvas.Left ǷǺǷ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ Margin ǞǽǺȎ). ǜǯǾǿǷǻǴǿ ǿǯȀȀǻǽȁǿǷǻ ȀǺǴdzȂȍȈǷǸ ;$0/
Ǚǯǹ DZǷdzǷȁǴ ȀDZǽǸȀȁDZǯ Canvas.Top Ƿ Canvas.Left ǶǯdzǯǼȊ ǝǼǷ ǾǽǹǯǶȊDZǯȍȁ Ȇȁǽ ǹǼǽǾǹǯ DZȀǴDzdzǯ ǰȂdzǴȁ ȀǽȄǿǯ ǼȎȁȋ Ȍȁǽ ǻǴȀȁǽǾǽǺǽǵǴǼǷǴ ǽȁǼǽȀǷȁǴǺȋǼǽ DZǴǿȄǼǴDzǽ ǺǴDZǽDzǽ ȂDzǺǯ ǿǽdzǷȁǴǺȋȀǹǽDzǽ ȌǺǴǻǴǼȁǯ Canvas. ǡǯǹ Ȇȁǽ ǴȀǺǷ Canvas ǰȂdzǴȁ ǾǴǿǴǻǴȈǯȁȋȀȎ ǹǼǽǾǹǯ ȁǽǵǴ ǰȂdzǴȁ dzDZǷDzǯȁȋȀȎ ǐǽǺǴǴ ǾǽdzǿǽǰǼǽ ǹǽǻǾǽǼǽDZǽȆǼȊǸ ȌǺǴǻǴǼȁ Canvas ǿǯȀȀǻǯȁǿǷDZǯǴȁȀȎ DZ ǒǺǯDZǴ 4.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ StackPanel ǙǽǻǾǽǼǽDZǽȆǼȊǸ ȌǺǴǻǴǼȁ StackPanel DZȀǴDzdzǯ ǰȂdzǴȁ DZȊǿǯDZǼǷDZǯȁȋ ȀDZǽǷ dzǽȆǴǿǼǷǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ DZ DzǽǿǷǶǽǼȁǯǺȋǼǽǻ ǷǺǷ DZǴǿȁǷǹǯǺȋǼǽǻ ǼǯǾǿǯDZǺǴǼǷǷ ȂǹǺǯdzȊDZǯȎ1 ǷȄ ǷȀȄǽdzȎ ǷǶ ǶǼǯȆǴǼǷȎ ȀDZǽǸȀȁDZǯ Orientation ǝǿǷǴǼȁǯȅǷȎ ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ ǾǯǼǴǺȋ ǾǴǿǴǽǾǿǴdzǴǺȎǴȁ ǾǽǶǷȅǷǽǼǷǿǽDZǯǼǷǴ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǜǯǾǿǷǻǴǿ ǿǯȀȀǻǽȁǿǷǻ ȀǺǴdzȂȍȈǷǸ XAML: =0) { cI[board[n]].SetValue(Canvas.TopProperty, Convert.toDouble(ny * 100)); cI[board[n]].SetValue(Canvas.LeftProperty, Convert.toDouble(nx * 100)); } } }
68
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ DZȊǾǽǺǼȎǴȁȀȎ ȅǷǹǺ Ȁ ǷǶǻǴǼǴǼǷǴǻ ǷǼdzǴǹȀǯ ǽȁ dzǽ DZ DzǽǺǽDZǽǺǽǻǹǴ ȃǿǯDzǻǴǼȁǽDZ Ƿ DZȊȆǷȀǺǴǼǷǴ ǹǽǽǿdzǷǼǯȁ x,y dzǺȎ ǹǯǵdzǽDzǽ ǰǺǽǹǯ DZ ȀǴȁǹǴ ï ǖǼǯȆǴǼǷǴ x ² Ȍȁǽ ǾǿǽȀȁǽ ǿǴǶȂǺȋȁǯȁ ȅǴǺǽ ȆǷȀǺǴǼǼǽDzǽ dzǴǺǴǼǷȎ ǷǼdzǴǹȀǯ ǻǯȀȀǷDZǯ Ǽǯ Ƿ ǶǼǯȆǴǼǷǴ y ² Ȍȁǽ ǻǽdzȂǺȋ ǷǼdzǴǹȀǯ dzǴǺǴǼǼǽDzǽ Ǽǯ ǢǻǼǽ ǵǯǴǻ ȌȁǷ ǶǼǯȆǴǼǷȎ Ǽǯ Ƿ ǾǽǺȂȆǯǴǻ ǼǴǽǰȄǽdzǷǻȊǴ ǹǽǽǿdzǷǼǯȁȊ dzǺȎ ǽȁǿǷȀǽDZǹǷ ȌǺǴǻǴǼȁǯ Canvas. ǡǴǾǴǿȋ ǻȊ ǷǻǴǴǻ ǾǽǺǼǽȀȁȋȍ ǷǼǷȅǷǯǺǷǶǷǿǽDZǯǼǼȂȍ ǷDzǿȂ ǟǷȀȂǼǽǹ ǿǯȀǾǽǺǯDzǯǴȁȀȎ ȀǾǿǯDZǯ ǯ ǷDzǿǽDZǽǴ Ǿǽ ǺǴ Ȁ ǾǴǿǴǻǴȇǯǼǼȊǻǷ ȃǿǯDzǻǴǼȁǯǻǷ ǿǷȀȂǼǹǯ ² ȀǺǴDZǯ
ǝǰǿǯǰǽȁǹǯ dzǴǸȀȁDZǷǸ ǾǽǺȋǶǽDZǯȁǴǺȎ ǡǴǾǴǿȋ ǼǴǽǰȄǽdzǷǻǽ ǶǯǼȎȁȋȀȎ ǽǰǿǯǰǽȁǹǽǸ dzǴǸȀȁDZǷǸ ǾǽǺȋǶǽDZǯȁǴǺȎ Ǒ ǷDzǿǯȄ ǾǽdzǽǰǼǽDzǽ ǿǽdzǯ ǾǿǴdzǾǽǺǯDzǯ ǴȁȀȎ Ȇȁǽ ǾǽǺȋǶǽDZǯȁǴǺȋ ǰȂdzǴȁ ȈǴǺǹǯȁȋ ȃǿǯDzǻǴǼȁ ǷǶǽǰǿǯǵǴǼǷȎ Ƿ ǴȀǺǷ Ȍȁǽȁ ȃǿǯDzǻǴǼȁ ǼǯȄǽdzǷȁȀȎ ǿȎdzǽǻ Ȁ ǾȂȀȁǽǸ ǽǰǺǯȀȁȋȍ ǽǼ ǾǺǯDZǼǽ ǾǴǿǴǻǴȀȁǷȁȀȎ DZ ȌȁȂ ǽǰǺǯȀȁȋ ǽȀȁǯDZǺȎȎ ǾȂȀȁȊǻ ǶǯǼǷǻǯǴǻǽǴ dzǽ ȌȁǽDzǽ ǻǴȀȁǽ Ǘȁǯǹ ǻȊ dzǽǺǵǼȊ ǽǰǿǯǰǽȁǯȁȋ ȈǴȆǹǷ Ǿǽ ȌǺǴǻǴǼȁȂ Canvas ȀǽdzǴǿǵǯȈǴDzǽ ȃǿǯDzǻǴǼȁ ǷǶǽǰǿǯǵǴǼǷȎ ǔȀǺǷ DZǴǿǼȂȁȋȀȎ ǹ ǷǼǷȅǷǯǺǷǶǯȅǷǷ ȃǿǯDzǻǴǼȁǽDZ ǻǽǵǼǽ DZȀǾǽǻǼǷȁȋ ȁǯǹȂȍ ȀȁǿǽǹȂ cI[nx].MouseLeftButtonDown += new MouseButtonEventHandler(Page MouseLeftButtonDown);
ǖdzǴȀȋ ǽǾǷȀȊDZǯǴȁȀȎ Ȇȁǽ Ǿǽ ȈǴǺȆǹȂ Canvas ǰȂdzǴȁ ǶǯǾȂȀǹǯȁȋȀȎ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ Page MouseLeftButtonDown. Ǭȁǽȁ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ ǶǯdzǯǼ dzǺȎ ǹǯǵdzǽDzǽ ǷǶ ǰǺǽǹǽDZ Canvas. Ǚǽdz ȌȁǽDzǽ ǽǰǿǯǰǽȁȆǷǹǯ ȀǽǰȊȁǷȎ ȀǽȀȁǽǷȁ ǷǶ dzDZȂȄ ǿǯǶdzǴǺǽDZ ǞǴǿDZȊǸ ǽǾǿǴdzǴǺȎǴȁ ǹǽȁǽǿȊǸ ǷǶ Canvas ȀȃǽǿǻǷǿǽDZǯǺ ȀǽǰȊȁǷǴ Ƿ ǾǽǺǽǵǴǼǷǴ ȌȁǽDzǽ Canvas Ǽǯ ǷDzǿǽDZǽǻ ǾǽǺǴ void Page MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Canvas c = sender as Canvas; int nCanvasID = -1; int nBoardLoc = -1; int nEmptyLoc = -1; for (int i = 0; i < 16; i++) { if (c == cI[i]) { nCanvasID = i; break; } } for (int i = 0; i < 16; i++) { if (board[i] == nCanvasID) { nBoardLoc = i; } else if (board[i] == -1) { nEmptyLoc = i; } }
Ǘȁǯǹ ǼǯǾǿǷǻǴǿ DZȊ ȈǴǺǹǼȂǺǷ ȃǿǯDzǻǴǼȁ ǾǿǴdzȀȁǯDZǺȎȍȈǷǸ DZǴǿȄǼǷǸ ǺǴDZȊǸ ȂDzǽǺ ǾǽǺǼǽDzǽ ǷǶǽǰǿǯǵǴǼǷȎ ǰǺǽǹ Ǽǽ DZ ǼǯȀȁǽȎȈǷǸ ǻǽǻǴǼȁ ǽǼ ǼǯȄǽdzǷȁȀȎ DZ ǼǷǵǼǴǻ ǺǴDZǽǻ ȂDzǺȂ ǷDzǿǽDZǽDzǽ ǾǽǺȎ ǾǽǶǷȅǷȎ ǞǿǷ DZǽǶǼǷǹǼǽDZǴǼǷǷ ȀǽǰȊȁǷȎ ȈǴǺȆǹǯ DZȊǾǽǺǼȎǴȁȀȎ ǾǴǿǴǰǽǿ DZȀǴDzǽ ǻǯȀȀǷDZǯ ȌǺǴǻǴǼȁǽDZ Canvas ǾǿǴdzȀȁǯDZǺȎȍȈǷȄ ȃǿǯDzǻǴǼȁȊ DzǽǺǽDZǽǺǽǻǹǷ dzǽ ȁǴȄ Ǿǽǿ Ǿǽǹǯ ǼǴ ǰȂdzǴȁ ǼǯǸdzǴǼ ȃǿǯDzǻǴǼȁ ȀǽǽȁDZǴȁȀȁDZȂȍȈǷǸ Canvas, Ǿǽ ǹǽȁǽǿǽǻȂ ǰȊǺǽ ǾǿǽǷǶDZǴdzǴǼ ȈǴǺȆǽǹ Ǘ ǶdzǴȀȋ DZȊ ǻǽǵǴȁǴ ǾǽǺȂȆǷȁȋ ǷǼdzǴǹȀ ȌȁǽDzǽ ȌǺǴǻǴǼȁǯ DZ ǻǯȀȀǷDZǴ ȀǽȄǿǯǼǷDZ ǴDzǽ DZ ǾǴǿǴǻǴǼǼǽǸ nCanvasID DZ ǼǯȇǴǻ DzǷǾǽȁǴȁǷȆǴȀǹǽǻ ǾǿǷǻǴǿǴ ǽǼ ǿǯDZǼȎǺȀȎ ǰȊ ǞǽȀǺǴ ȌȁǽDzǽ ǾǿǽȀǹǯǼǷǿǽDZǯDZ ǷDzǿǽDZǽǴ ǾǽǺǴ ǻǽǵǼǽ ǽǾǿǴdzǴǺǷȁȋ ǻǴȀȁǽǾǽǺǽǵǴǼǷǴ ȌǺǴǻǴǼȁǯ Ǽǯ ǼǴǻ Ƿ ǾǿǷȀDZǽǷȁȋ ǶǼǯȆǴǼǷǴ ǴDzǽ ǾǽǶǷȅǷǷ ǾǴǿǴǻǴǼǼǽǸ nBoardLoc ǹǽȁǽǿǽǴ DZ ǼǯȇǴǻ DzǷǾǽȁǴȁǷȆǴȀǹǽǻ ǾǿǷǻǴǿǴ ǿǯDZǼǽ Ǘ ǼǯȄǽdzȎȀȋ DZ ȌȁǽǸ ǾǽǶǷȅǷǷ, ǼǯǸdzǷȁǴ ǻǴȀȁǽǾǽǺǽǵǴǼǷǴ ǾȂȀȁǽǸ ȎȆǴǸǹǷ Ǽǯ ǷDzǿǽDZǽǻ ǾǽǺǴ Ƿ ȀǽȄǿǯǼǷȁǴ ǴDzǽ DZ nEmptyLoc. ǑȁǽǿǯȎ ȆǯȀȁȋ ǹǽdzǯ ǾǿǽDZǴǿȎǴȁ DZǽǶǻǽǵǼǽȀȁȋ ǾǴǿǴǻǴȈǴǼǷȎ ȃǿǯDzǻǴǼȁǯ Ƿ, ǴȀǺǷ ǾǴǿǴǻǴȈǴǼǷǴ DZǽǶǻǽǵǼǽ ǾǴǿǴǻǴȈǯǴȁ ȃǿǯDzǻǴǼȁ DZ ǾȂȀȁȂȍ ȎȆǴǸǹȂ Ƿ ȀǽǽȁDZǴȁȀȁDZȂȍȈǷǻ ǽǰǿǯǶǽǻ ǽǰǼǽDZǺȎǴȁ ǷDzǿǽDZǽǴ ǾǽǺǴ
ǒǺǯDZǯ ǗȀǾǽǺȋǶǽDZǯǼǷǴ Visual Studio Ȁ Silverlight 2
69
ǷȘȊȍȘȧȍȔ ȊȖȏȔȖȎȕȖșȚȤ ȗȍȘȍȔȍȡȍȕȐȧ if ((nBoardLoc == nEmptyLoc + 1) || (nBoardLoc == nEmptyLoc - 1) || (nBoardLoc == nEmptyLoc + 4) || (nBoardLoc == nEmptyLoc - 4)) { int nx = nEmptyLoc/4; int ny = nEmptyLoc%4; cI[nCanvasID].SetValue( Convert.toDouble(Canvas.TopProperty, ny * 100)); cI[nCanvasID].SetValue( Convert.toDouble(Canvas.LeftProperty, nx * 100)); board[nEmptyLoc] = nCanvasID; board[nBoardLoc] = -1; checkWinner(); } else { // ȕȍ ȌȍȓȈȍȔ ȕȐȟȍȋȖ }
}
ǓǺȎ ȌȁǽDzǽ ȀǼǯȆǯǺǯ ǾǿǽDZǴǿǷǻ ǻǴȀȁǽǾǽǺǽǵǴǼǷǴ ǾȂȀȁǽǸ ȎȆǴǸǹǷ ǽȁǼǽȀǷȁǴǺȋǼǽ ǾǽǺǽǵǴǼǷȎ ǰǺǽǹǯ Ǿǽ ǹǽȁǽ ǿǽǻȂ ǰȊǺ ǾǿǽǷǶDZǴdzǴǼ ȈǴǺȆǽǹ ǔȀǺǷ ǽǼǷ ǿǯȀǾǽǺǯDzǯȍȁȀȎ ǼǴǾǽȀǿǴdzȀȁDZǴǼǼǽ ǿȎdzǽǻ dzǿȂDz Ȁ dzǿȂDzǽǻ Ǽǯdz Ǿǽdz ȀǺǴDZǯ ǷǺǷ ȀǾǿǯDZǯ ǾǴǿǴǻǴȈǴǼǷǴ DZǽǶǻǽǵǼǽ ǞǽȀǹǽǺȋǹȂ ǷDzǿǽDZǽǴ ǾǽǺǴ ï ȎDZǺȎǴȁȀȎ ǽdzǼǽǻǴǿǼȊǻ ǻǯȀȀǷDZǽǻ ȀdzǴǺǯȁȋ Ȍȁǽ ǼǴȀǺǽǵǼǽ ǞǽǶǷȅǷǷ ȌǺǴǻǴǼȁǽDZ ǿǯȀǾǽǺǯDzǯȍȈǷȄȀȎ ȀǺǴDZǯ Ƿ ȀǾǿǯDZǯ ǽȁ ȁǴǹȂȈǴDzǽ ȌǺǴǻǴǼȁǯ ǽȁǺǷȆǯȍȁȀȎ ǽȁ ȁǴǹȂȈǴǸ Ǽǯ - Ƿ ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ Ƿ ǾǽǶǷȅǷǷ ȌǺǴǻǴǼȁǽDZ ȀDZǴǿȄȂ Ƿ ȀǼǷǶȂ ² Ǽǯ - Ƿ ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ ǡǯǹ Ȇȁǽ ǴȀǺǷ ǿǴǶȂǺȋȁǯȁ ǾǿǽDZǴǿǹǷ ȃǿǯDzǻǴǼȁǽDZ ȂǹǯǶȊDZǯǴȁ Ǽǯ ǾȂȀȁȂȍ ȎȆǴǸǹȂ DZȊ ǶǼǯǴȁǴ Ȇȁǽ ǻǽǵǴȁǴ dzDZǷDzǯȁȋȀȎ. ǦȁǽǰȊ DZȊǾǽǺǼǷȁȋ ǾǴǿǴǻǴȈǴǼǷǴ ǼǴǽǰȄǽdzǷǻǽ ǾǽǺȂȆǷȁȋ ǹǽǽǿdzǷǼǯȁȊ x Ƿ y ǽȁǼǽȀǷȁǴǺȋǼǽ ǾǽǺǽǵǴǼǷȎ ǾȂȀȁǽDzǽ ȃǿǯDzǻǴǼȁǯ Ƿ Ƕǯdzǯȁȋ ǷȄ ǹǯǹ ǹǽǽǿdzǷǼǯȁȊ ǰǺǽǹǯ Ǿǽ ǹǽȁǽǿǽǻȂ ǰȊǺ ǾǿǽǷǶDZǴdzǴǼ ȈǴǺȆǽǹ ǖǯȁǴǻ ǾǿǷȀDZǽǷȁȋ ǾǽǶǷȅǷǷ ǾǽǺȎ Ǽǯ ǹǽȁǽǿǽǸ dzǽ ȌȁǽDzǽ ǼǯȄǽdzǷǺǯȀȋ ǾȂȀȁǯȎ ȎȆǴǸǹǯ ǶǼǯȆǴǼǷǴ Canvas Ǿǽ ǹǽȁǽǿǽǻȂ ǰȊǺ ǾǿǽǷǶDZǴdzǴǼ ȈǴǺȆǽǹ Ƿ ǾǽǶǷȅǷǷ ǾǽǺȎ Ǽǯ ǹǽȁǽǿǽǸ dzǽ ȌȁǽDzǽ ǿǯȀǾǽǺǯDzǯǺȀȎ Canvas Ǿǽ ǹǽȁǽǿǽǻȂ ǰȊǺ ǾǿǽǷǶDZǴdzǴǼ ȈǴǺȆǽǹ ǶǼǯȆǴǼǷǴ - ȂǹǯǶȊDZǯȎ Ǽǯ ȁǽ Ȇȁǽ ȁǴǾǴǿȋ Ȍȁǯ ȎȆǴǸǹǯ ǾȂȀȁǯ ǜǯǹǽǼǴȅ DZȊǶǽDZǴǻ ȃȂǼǹȅǷȍ checkWinner() ȆȁǽǰȊ ǾǿǽDZǴǿǷȁȋ ȂȀǾǴȇǼǽȀȁȋ ǿǴȇǴǼǷȎ DzǽǺǽDZǽǺǽǻǹǷ
ǞǿǽDZǴǿǹǯ ȂȀǺǽDZǷȎ DZȊǷDzǿȊȇǯ ǣȂǼǹȅǷȎ checkWinner ǞǿǽDZǴǿǹǯ ǾǽǰǴdzǷȁǴǺȎ ǾǿǽDZǴǿȎǴȁ ȂȀǾǴȇǼǽȀȁȋ ǿǴȇǴǼǷȎ DzǽǺǽDZǽǺǽǻǹǷ ǝǾȎȁȋ ǵǴ DZȀǴ ǽȆǴǼȋ ǾǿǽȀȁǽ ǒǽǺǽDZǽǺǽǻǹǯ ǿǴȇǴǼǯ ǴȀǺǷ ǹǯǵdzȊǸ n-ǼȊǸ ȌǺǴǻǴǼȁ ǷDzǿǽDZǽDzǽ ǾǽǺȎ ǿǯDZǴǼ n ȁǴ Canvas 0 ǷǻǴǴȁ ǷǼdzǴǹȀ Canvas 1- ǷǼdzǴǹȀ Ƿ ȁdz ǠǯǻȊǸ ȌȃȃǴǹȁǷDZǼȊǸ ȀǾǽȀǽǰ ȀdzǴǺǯȁȋ Ȍȁǽ ² ǾǿǴdzǾǽǺǽǵǷȁȋ Ȇȁǽ DzǽǺǽDZǽǺǽǻǹǯ ǿǴȇǴǼǯ ȂȀǾǴȇǼǽ Ƿ ǾǿǽȀǹǯ ǼǷǿǽDZǯȁȋ ǷDzǿǽDZǽǴ ǾǽǺǴ DZ ǾǽǷȀǹǯȄ ǼǴȀǽǽȁDZǴȁȀȁDZǷȎ board[n] ǶǼǯȆǴǼǷȍ n Ȇȁǽ ǰȂdzǴȁ ȀDZǷdzǴȁǴǺȋȀȁDZǽDZǯȁȋ ǽ ǼǴDZǴǿǼǽǻ ǿǴȇǴǼǷǷ Ƿ ǾǿǷDZǽdzǷȁȋ ǹ ǶǯDZǴǿȇǴǼǷȍ ȅǷǹǺǯ ǔȀǺǷ DZȀǴ ǷǼdzǴǹȀȊ ȀǽDZǾǯdzǯȍȁ Ȃ ǼǯȀ ǴȀȁȋ ǾǽǰǴdzǷ ȁǴǺȋ void checkWinner() { bool bCompleted = true; for (int n = 0; n < 15; n++) { if (n != board[n]) { bCompleted = false; break; } }
70
ǑDZǴdzǴǼǷǴ DZ Silverlight 2 if (bCompleted) { ǰȋȘȖȒ ȊȣȐȋȘȈȓșȌȍȓȈȑȚȍ Ȍȓȧ ȕȍȋȖ ȟȚȖ-ȕȐȉțȌȤ ȗȘȐȧȚȕȖȍ } }
ǡǴǾǴǿȋ DZȊ ǾǽǺȂȆǷǺǷ DZȀǴ ȌǺǴǻǴǼȁȊ ǾǿǽȀȁǽǸ ǷDzǿȊ-DzǽǺǽDZǽǺǽǻǹǷ Ȁ ǾǴǿǴǻǴȈǴǼǷǴǻ ȃǿǯDzǻǴǼȁǽDZ ǼǯǾǷȀǯǼ ǼǽǸ Ǽǯ Ǡ dzǺȎ Silverlight 2. Ǘ dzǺȎ ȌȁǽDzǽ ǾǽǼǯdzǽǰǷǺǽȀȋ DZȀǴDzǽ ǺǷȇȋ Ȁȁǿǽǹ ǹǽdzǯ Ǟǽ ȄǽdzȂ ȆȁǴǼǷȎ ȌȁǽǸ ǹǼǷDzǷ dzǯǼǼȊǸ ǾǿǷǻǴǿ ǻǽǵǼǽ ǿǯȀȇǷǿȎȁȋ dzǽǰǯDZǺȎȎ ǯǼǷǻǯȅǷȍ ǾǴǿǴǻǴȈǴǼǷȎ ǰǺǽǹǽDZ ȀǽȄǿǯǼǴǼǷǴ ǺȂȆ ȇǷȄ ǿǴǶȂǺȋȁǯȁǽDZ DZǽǶǻǽǵǼǽȀȁȋ ǶǯDzǿȂǶǹǷ ǷǶǽǰǿǯǵǴǼǷǸ DZ ǾǿǷǺǽǵǴǼǷǴ Ƿ ȁdz ǜǴȁ ǾǿǴdzǴǺǽDZ ȀǽDZǴǿȇǴǼȀȁDZȂ
ǖǯǹǺȍȆǴǼǷǴ Ǒ dzǯǼǼǽǸ DzǺǯDZǴ ǻȊ ǿǯȀȀǻǽȁǿǴǺǷ Visual Studio Ƿ ǾǿǴdzǺǯDzǯǴǻȊǴ Ǵȍ ǿǯǶǺǷȆǼȊǴ ǷǼȀȁǿȂǻǴǼȁȊ Ƿ ȇǯǰ ǺǽǼȊ dzǺȎ ǿǯǶǿǯǰǽȁǹǷ ǾǿǷǺǽǵǴǼǷǸ Silverlight Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ȎǶȊǹǽDZ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ NET ǐȊǺ dzǴȁǯǺȋǼǽ ǿǯǶǽǰǿǯǼ ǾǿǽǴǹȁ ȀǽǶdzǯǼǼȊǸ Ǽǯ ǰǯǶǴ ȀȁǯǼdzǯǿȁǼȊȄ ȇǯǰǺǽǼǽDZ Silverlight ǿǯȀȀǻǽȁǿǴǼȊ DZȀǴ ǴDzǽ ȃǯǸǺȊ Ƿ ȁǽ ǹǯǹ ǽǼ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǿǯǶǿǯǰǽȁǹǷ Ƿ ǿǯǶDZǴǿȁȊDZǯǼǷȎ ǾǿǷǺǽǵǴǼǷȎ Silverlight. ǞǽȀǺǴ ȌȁǽDzǽ ǻȊ ǾǿǷǻǴǼǷǺǷ ȁǴǽǿǷȍ Ǽǯ ǾǿǯǹȁǷǹǴ Ƿ ȀǽǶdzǯǺǷ ǾǽǺǼǽȃȂǼǹȅǷǽǼǯǺȋǼȂȍ ǷDzǿȂ-DzǽǺǽDZǽǺǽǻǹȂ Ȁ ǾǴǿǴǻǴȈǴ ǼǷǴǻ ȃǿǯDzǻǴǼȁǽDZ ǷȀǾǽǺȋǶȂȎ XAML Ƿ C#. Ǭȁǽ ǾǽǶDZǽǺǷǺǽ ǾǽȆȂDZȀȁDZǽDZǯȁȋ DZǽǶǻǽǵǼǽȀȁǷ Silverlight 2, Ǽǽ ǻȊ ǺǷȇȋ ȀǺǴDzǹǯ ǾǿǷǹǽȀǼȂǺǷȀȋ ǹ ǼǷǻ Ǒ ǦǯȀȁǷ dzǯǼǼǽǸ ǹǼǷDzǷ ©ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight ª ǰȂdzȂȁ ǰǽǺǴǴ DzǺȂǰǽǹǽ ǿǯȀȀǻǽȁǿǴǼȊ ȃȂǼǹȅǷǽǼǯǺȋǼȊǴ DZǽǶǻǽǵǼǽȀȁǷ dzǽȀȁȂǾǼȊǴ DZ .NET Framework DZǹǺȍȆǯȎ ȀǽǶ dzǯǼǷǴ ȀǽǰȀȁDZǴǼǼȊȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǿǯǰǽȁȂ Ȁ ȀǴȁȋȍ Ƿ ǽǰǻǴǼ ǷǼȃǽǿǻǯȅǷǴǸ dzǯǼǼȊǴ Ƿ XML dzǷ ǼǯǻǷȆǴȀǹǷǴ ȎǶȊǹǷ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ Ƿ ȀǴǿDZǴǿǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ASP.NET.
ǒǺǯDZǯ
ǝȀǼǽDZȊ XAML XAML ² Ȍȁǽ Ȏdzǿǽ ǾǿǷǺǽǵǴǼǷȎ Silverlight. ǝǼ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ DzǿǯȃǷȆǴȀǹǷȄ ǿǴȀȂǿȀǽDZ DZǶǯǷǻǽdzǴǸȀȁDZǷǸ ǯǼǷǻǯȅǷǸ Ƿ DZǿǴǻǴǼǼȊȄ ȇǹǯǺ XAML ǽȀǼǽDZȊDZǯǴȁȀȎ Ǽǯ XML, ǾǽȌȁǽǻȂ DZȀǴ ǽǾǷȀȊDZǯǴȁȀȎ DZ ȁǴǹȀȁǽDZǽǻ ȃǽǿǻǯȁǴ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǯȁǿǷǰȂȁǽDZ dzǺȎ ǽǰȉȎDZǺǴǼǷȎ ȀDZǽǸȀȁDZ ǻǴȁǽdzǽDZ Ƿ ȀǽǰȊȁǷǸ Ǒ dzǯǼǼǽǸ DzǺǯDZǴ ǰȂdzȂȁ ǿǯȀȀǻǽȁǿǴǼȊ ǽǰȈǷǴ ǹǽǻǾǽǼǴǼȁȊ XAML ǷȀǾǽǺȋǶȂǴǻȊǴ dzǺȎ ǽǾǷȀǯǼǷȎ DZǷǶȂǯǺȋǼȊȄ ȌǺǴǻǴǼȁǽDZ ǾǿǷǺǽǵǴǼǷȎ Ǒǽ-ǾǴǿDZȊȄ ǻȊ ǽȀȁǯǼǽDZǷǻȀȎ Ǽǯ ȃǽǿǻǷǿǽDZǯǼǷǷ ǹǽǻǾǽǼǽDZǹǷ DZ ȁǽǻ ȆǷȀǺǴ Ǽǯ ȁǽǻ ǹǯǹ ȌǺǴǻǴǼȁȊ ǻǽDzȂȁ ǿǯǶǻǴȈǯȁȋȀȎ Ǽǯ ȌǹǿǯǼǴ ǽȁǼǽȀǷȁǴǺȋǼǽ ǷȄ ǹǽǼȁǴǸǼǴǿǽDZ Ƿ dzǿȂDz dzǿȂDzǯ ǡǯǹǵǴ ǿǯȀ ȀǻǽȁǿǷǻ ǿǯǶǼȊǴ ǹǷȀȁǷ ǷȀǾǽǺȋǶȂǴǻȊǴ dzǺȎ ǶǯǺǷDZǹǷ ȃǷDzȂǿ Ƿ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǯ ȁǯǹǵǴ ǽǰDZǽdzǹǷ dzǺȎ ǽȁǿǷȀǽDZǹǷ ǹǽǼȁȂǿǽDZ ǖǯȁǴǻ DZȊ ȂǶǼǯǴȁǴ ǽ ǹǽǼȁȂǿǯȄ Ƿ DzǴǽǻǴȁǿǷȆǴȀǹǷȄ ȌǺǴǻǴǼȁǯȄ Ƿ ǽ ȁǽǻ ǹǯǹ ǽǼǷ ǷȀ ǾǽǺȋǶȂȍȁȀȎ dzǺȎ ȀǽǶdzǯǼǷȎ ȀǺǽǵǼȊȄ ȃǷDzȂǿ Ƿ DzǿȂǾǾ ȃǷDzȂǿ ǯ ȁǯǹǵǴ ǹǯǹ Ȁ ǷȄ ǾǽǻǽȈȋȍ ǿǴǯǺǷǶǽDZȊDZǯǴȁȀȎ DZȊǿǴǶǯǼǷǴ dzǿȂDzǷȄ ǽǰȉǴǹȁǽDZ ǷǺǷ ǶǯǺǷDZǹǷ ǜǯǹǽǼǴȅ ǰȂdzȂȁ ǾǿǴdzȀȁǯDZǺǴǼȊ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ǷȀǾǽǺȋ ǶȂȍȈǷǴ ȌȁǷ ǹǽǻǾǽǼǴǼȁȊ XAML DZǹǺȍȆǯȎ Canvas ǹǽȁǽǿȊǸ ȎDZǺȎǴȁȀȎ ǽȀǼǽDZǼȊǻ ȌǺǴǻǴǼȁǽǻ ǹǽǻǾǽǼǽDZǹǷ Silverlight ǙǿǽǻǴ ȁǽDzǽ ǻȊ ǾǽǶǼǯǹǽǻǷǻȀȎ ǹǯǹ ǷȀǾǽǺȋǶǽDZǯȁȋ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Glyphs (ʧ̴̛̣̼ Ƿ TextBlock dzǺȎ ǽȁǽǰǿǯǵǴǼǷȎ ȁǴǹȀȁǯ
ǙǽǻǾǽǼǽDZǽȆǼȊǴ ȀDZǽǸȀȁDZǯ XAML ǔȀǺǷ DzǽDZǽǿǷȁȋ ǹǿǯȁǹǽ ȀDZǽǸȀȁDZǯ Canvas.Left Ƿ Canvas.Top ǷȀǾǽǺȋǶȂȍȁȀȎ dzǺȎ ǹǽǻǾǽǼǽDZǹǷ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ DZ XAML. ǗȄ ǼǯǶȊDZǯȍȁ ǾǿǷȀǽǴdzǷǼǴǼǼȊǻǷ ȀDZǽǸȀȁDZǯǻǷ Ȇȁǽ DZȀǴDzǽ ǺǷȇȋ ǽǶǼǯȆǯǴȁ Ȇȁǽ ǽǼǷ DzǺǽǰǯǺȋǼǽ dzǽȀȁȂǾǼȊ DZ ǹǽdzǴ XAML ǷǺǷ ǷǶǻǴǼȎȍȁ ȀDZǽǸȀȁDZǽ ǽǾǿǴdzǴǺǴǼǼǽǴ ǿǽdzǷȁǴǺȋȀǹǷǻ ȌǺǴǻǴǼȁǽǻ ǙǿǽǻǴ ȁǽDzǽ ǾǿǷȀǽǴdzǷǼǴǼǼǽǴ ȀDZǽǸȀȁDZǽ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ǽǰǽǶǼǯȆǴǼǷȎ ǾǽǺǽǵǴǼǷȎ ǽǰȉǴǹȁǯ Ǽǯ ǾǺǽȀǹǽȀȁǷ ǽȁǼǽȀǷȁǴǺȋǼǽ ǽȀǷ Z, Ȇȁǽ ǽǾǿǴdzǴǺȎǴȁ ǽȆǴǿǴdzǼǽȀȁȋ ǽȁǿǷȀǽDZǹǷ DZ ȀǺȂȆǯǴ ǼǯǺǽǵǴǼǷȎ ǽǰȉǴǹȁǽDZ dzǿȂDz Ǽǯ dzǿȂDzǯ Ǟǽ ȂǻǽǺȆǯǼǷȍ ȌǺǴǻǴǼȁ ǽȁǿǷȀǽDZȊDZǯǴǻȊǸ ǾǽȀǺǴdzǼǷǻ ȀǯǻȊǸ ǼǷǵǼǷǸ DZ dzǽǹȂǻǴǼȁǴ XAML), ȎDZǺȎǴȁȀȎ ȀǯǻȊǻ DZǴǿȄǼǷǻ Ǽǽ Ȁ ǾǽǻǽȈȋȍ Canvas.ZIndex Ȍȁǽ ǾǽǺǽǵǴǼǷǴ ǻǽǵǼǽ ǾǴǿǴǽǾǿǴdzǴǺǷȁȋ Ǘȁǯǹ ǿǯȀȀǻǽȁǿǷǻ ȀǺǴdzȂȍȈǷǸ ȃǿǯDzǻǴǼȁ XAML ǝǼ ǾǿǴdzȀȁǯDZǺȎǴȁ ǹǽdz dzǺȎ Canvas Ȁ dzDZȂǻȎ ǾǿȎǻǽȂDzǽǺȋǼǷ ǹǯǻǷ ǓǺȎ ǽǾǿǴdzǴǺǴǼǷȎ ǾǽǺǽǵǴǼǷȎ DZǴǿȄǼǴDzǽ ǺǴDZǽDzǽ ȂDzǺǯ ȌȁǷȄ ǾǿȎǻǽȂDzǽǺȋǼǷǹǽDZ ǽȁǼǽȀǷȁǴǺȋǼǽ ȄǽǺȀȁǯ DZ ǹǽȁǽǿǽǻ ǽǼǷ ǿǯȀǾǽǺǯDzǯȍȁȀȎ ǷȀǾǽǺȋǶȂȍȁȀȎ ȀDZǽǸȀȁDZǯ Canvas.Left Ƿ Canvas.Top.
ǦǴǿǼȊǸ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ǽȁǿǷȀǽDZȊDZǯǴȁȀȎ ǾǽDZǴǿȄ ǹǿǯȀǼǽDzǽ ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 4-1.
71
72
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǟǗǠ 1 ǙǽǻǾǽǼǽDZǹǯ ǾǿȎǻǽȂDzǽǺȋǼǷǹǽDZ
ǙǿǯȀǼȊǸ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ǼǯȄǽdzǷȁȀȎ Ǽǯ ǿǯȀȀȁǽȎǼǷǷ ǾǷǹȀǴǺǽDZ ǽȁ ǺǴDZǽDzǽ ǹǿǯȎ Ƿ ǾǷǹȀǴǺǽDZ ǽȁ DZǴǿȄǼǴǸ DzǿǯǼǷȅȊ ǿǽdzǷȁǴǺȋȀǹǽDzǽ ȄǽǺȀȁǯ ǦǴǿǼȊǸ ȀdzDZǷǼȂȁ Ǽǯ ǾǷǹȀǴǺǽDZ ǽȁ ǺǴDZǽDzǽ Ƿ ǾǷǹȀǴǺǯ ǽȁ DZǴǿȄǼǴDzǽ ǹǿǯȎ ǦǴǿǼȊǸ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ǿǯȀǾǽǺǯDzǯǴȁȀȎ ǾǽDZǴǿȄ ǹǿǯȀǼǽDzǽ ȁǯǹ ǹǯǹ ǽǼ DZǷǶȂǯǺǷǶǷǿǽDZǯǺȀȎ ǾǽȀǺǴdzǼǷǻ Ǭȁǽ ǾǽǺǽǵǴǼǷǴ ȌǺǴǻǴǼȁǽDZ ǻǽǵǼǽ ǾǴǿǴǽǾǿǴdzǴǺǷȁȋ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ ZIndex. ZIndex ǾǿǷǼǷǻǯǴȁ ȆǷ ȀǺǽDZȊǴ ǶǼǯȆǴǼǷȎ ǝǰȉǴǹȁȊ Ȁ ǰǽǺȋȇǷǻǷ ǶǼǯȆǴǼǷȎǻǷ ZIndex ǰȂdzȂȁ ǽȁǽǰǿǯǵǯȁȋȀȎ ǾǽDZǴǿȄ ǽǰȉǴǹȁǽDZ Ȁ ǻǴǼȋȇǷǻǷ ZIndex ǹǯǹ DZǷdzǼǽ DZ ȀǺǴdzȂȍȈǴǻ ǹǽdzǴ
Ǚǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 4- ȁǴǾǴǿȋ ǹǿǯȀǼȊǸ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ǿǯȀǾǽǺǯDzǯǴȁȀȎ ǾǽDZǴǿȄ ȆǴǿǼǽDzǽ ȆǴDzǽ Ƿ ȀǺǴdzǽ DZǯǺǽ ǽǵǷdzǯȁȋ ǾǽȀǹǽǺȋǹȂ ǶǼǯȆǴǼǷǴ ȀDZǽǸȀȁDZǯ ZIndex ǹǿǯȀǼǽDzǽ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ǰǽǺȋȇǴ ȆǴǻ ǶǼǯȆǴǼǷǴ ȌȁǽDzǽ ȀDZǽǸȀȁDZǯ dzǺȎ ȆǴǿǼǽDzǽ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ
ǟǗǠ 2 ǗǶǻǴǼǴǼǷǴ ǾǽǿȎdzǹǯ ǿǯȀǾǽǺǽǵǴǼǷȎ ȌǺǴǻǴǼȁǽDZ ǽȁǼǽȀǷȁǴǺȋǼǽ ǽȀǷ Z.
ǒǺǯDZǯ ǝȀǼǽDZȊ ;$0/
73
ǙǷȀȁǷ XAML ǙǷȀȁǷ DZ XAML ǷȀǾǽǺȋǶȂȍȁȀȎ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ ȁǽDzǽ ǹǯǹ ǽȁǿǷȀǽDZȊDZǯȍȁȀȎ Ƿ ǶǯǹǿǯȇǷDZǯȍȁȀȎ ȃǷDzȂǿȊ Ǒ ǾǿǴdzȊdzȂȈǴǻ ǾǿǷǻǴǿǴ ǾǿǴdzȀȁǯDZǺǴǼǽ dzDZǯ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ǶǯǺǷDZǹǯ ǹǽȁǽǿȊȄ DZȊǾǽǺǼǴǼǯ Ȁ ǷȀǾǽǺȋǶǽDZǯ ǼǷǴǻ ǷǶDZǴȀȁǼȊȄ ȅDZǴȁǽDZ Red ǹǿǯȀǼȊǸ Ƿ Black ȆǴǿǼȊǸ ȀǽǽȁDZǴȀȁDZǴǼǼǽ Ǭȁǽ ǾǿǽȀȁȊǴ ǾǿǷǻǴǿȊ ǾǿǷǻǴ ǼǴǼǷȎ ǹǷȀȁǴǸ Ǒ ȀǺǴdzȂȍȈǷȄ ǿǯǶdzǴǺǯȄ ǰȂdzȂȁ ǽǾǷȀǯǼȊ ǰǽǺǴǴ ȀǺǽǵǼȊǴ ȁǷǾȊ ǹǷȀȁǴǸ ǾǽdzdzǴǿǵǷDZǯǴǻȊǴ XAML.
SolidColorBrush SolidColorBrush ǶǯǾǽǺǼȎǴȁ ǽǰǺǯȀȁȋ ȀǾǺǽȇǼȊǻ ȅDZǴȁǽǻ. ǓǺȎ ǶǯdzǯǼǷȎ ȅDZǴȁǯ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ǷǻǴǼǽ DZǯǼǼǽǴ ǶǼǯȆǴǼǷǴ ǼǯǾǿǷǻǴǿ Red ǷǺǷ Black ǷǺǷ ȇǴȀȁǼǯdzȅǯȁǴǿǷȆǼȊǴ ǶǼǯȆǴǼǷȎ ǽǰǽǶǼǯȆǯȍȈǷǴ ǷǼȁǴǼ ȀǷDZǼǽȀȁǷ ǯǺȋȃǯ ǹǿǯȀǼǽDzǽ ǶǴǺǴǼǽDzǽ Ƿ ȀǷǼǴDzǽ ǹǯǼǯǺǽDZ ǜǯǾǿǷǻǴǿ ǰǴǺȊǸ ȅDZǴȁ DZ ȇǴȀȁǼǯdzȅǯȁǴǿǷȆǼǽǻ ǾǿǴdzȀȁǯDZǺǴǼǷǷ ǽǾǷȀȊDZǯǴȁȀȎ ǹǯǹ #FFFFFFFF Ƿ ǹǿǯȀǼȊǸ ² #FFFF0000.
LinearGradientBrush LinearGradientBrush (ǚǷǼǴǸǼǯȎ DzǿǯdzǷǴǼȁǼǯȎ ǹǷȀȁȋ) ǶǯǾǽǺǼȎǴȁ ǽǰǺǯȀȁȋ ǺǷǼǴǸǼǽǸ DzǿǯdzǷǴǼȁǼǽǸ ǶǯǺǷDZǹǽǸ ǽǾǿǴdzǴǺǴǼǼǽǸ DZ dzDZȂǻǴǿǼǽǻ ǾǿǽȀȁǿǯǼȀȁDZǴ ǒǿǯdzǷǴǼȁ Ǿǽ ȂǻǽǺȆǯǼǷȍ ǽǾǷȀȊDZǯǴȁȀȎ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǼǽǿǻǷǿǽDZǯǼǼǽDzǽ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ DZǴǿȄǼǷǸ ǺǴDZȊǸ ȂDzǽǺ ǹǽȁǽǿǽDzǽ ǷǻǴǴȁ ǹǽǽǿdzǷǼǯȁȊ Ƿ ǼǷǵǼǷǸ ǾǿǯDZȊǸ ȂDzǽǺ ² ǹǽǽǿdzǷǼǯȁȊ Ǒ Ȍȁǽǻ ȀǺȂȆǯǴ DzǿǯdzǷǴǼȁ ǿǯȀǾǿǽȀȁǿǯǼȎǴȁȀȎ DZ ǼǯǾǿǯDZǺǴ ǼǷǷ ǽȁ DZǴǿȄǼǴDzǽ ǺǴDZǽDzǽ ȂDzǺǯ ǹ ǼǷǵǼǴǻȂ ǾǿǯDZǽǻȂ ȂDzǺȂ ǔȀǺǷ dzǺȎ ǹǯǵdzǽǸ ǷǶ ȌȁǷȄ ȁǽȆǴǹ Ƕǯdzǯȁȋ ȅDZǴȁ Silverlight ǽȁǽǰǿǯǶǷȁ ǾǺǯDZǼȊǸ ǾǴǿǴȄǽdz ǻǴǵdzȂ ǼǷǻǷ Ǒ ǹǯȆǴȀȁDZǴ ǾǿǷǻǴǿǯ ǿǯȀȀǻǽȁǿǷǻ ȀǺǴdzȂȍȈǴǴ ǽǾǷȀǯǼǷǴ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ
Ǭȁǽȁ ȃǿǯDzǻǴǼȁ XAML-ǹǽdzǯ ǽǾǿǴdzǴǺȎǴȁ LinearGradientBrush, ǿǯȀǾǿǽȀȁǿǯǼȎȍȈȂȍȀȎ ǷǶ DZǴǿȄǼǴDzǽ ǺǴDZǽDzǽ ȂDzǺǯ DZ ǼǷǵǼǷǸ ǾǿǯDZȊǸ ȂDzǽǺ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ǞǴǿDZǯȎ ȁǽȆǹǯ DzǿǯdzǷǴǼȁǯ DZ ǼǯȆǯǺǴ DzǿǯdzǷǴǼȁǯ ȆǴǿǼǯȎ ((#FF Ƿ DZȁǽǿǯȎ ȁǽȆǹǯ DzǿǯdzǷǴǼȁǯ DZ ǹǽǼȅǴ DzǿǯdzǷǴǼȁǯ ǰǴǺǯȎ FFFFFFFF). ǞǿǽǿǷȀǽDZǹȂ ȌȁǽDzǽ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 4-3.
ǟǗǠ 3 ǗȀǾǽǺȋǶǽDZǯǼǷǴ LinearGradientBrush.
74
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǗǶǻǴǼǴǼǷǴ ǼǯǾǿǯDZǺǴǼǷȎ ǿǯȀǾǿǽȀȁǿǯǼǴǼǷȎ DzǿǯdzǷǴǼȁǯ ǖǯdzǯDZǯȎ ȀDZǽǸȀȁDZǯ StartPoint (ǜǯȆǯǺȋǼǯȎ ȁǽȆǹǯ Ƿ EndPoint (ǙǽǼǴȆǼǯȎ ȁǽȆǹǯ) LinearGradientBrush ǻǽǵǼǽ ǷǶǻǴǼȎȁȋ ǼǯǾǿǯDZǺǴǼǷǴ ǿǯȀǾǿǽȀȁǿǯǼǴǼǷȎ DzǿǯdzǷǴǼȁǯ ǦȁǽǰȊ ǼǯǾǿǯDZǷȁȋ DzǿǯdzǷǴǼȁǼȂȍ ǶǯǺǷDZǹȂ ǷǶ ǼǷǵǼǴDzǽ ǺǴDZǽDzǽ DZ DZǴǿȄǼǷǸ ǾǿǯDZȊǸ ȂDzǽǺ ȌȁǷǻ ȀDZǽǸȀȁDZǯǻ ǼǴǽǰȄǽdzǷǻǽ Ƕǯdzǯȁȋ ǶǼǯȆǴǼǷȎ Ƿ ȀǽǽȁDZǴȁȀȁDZǴǼ Ǽǽ
ǜǯ ǿǷȀ -4 ǾǽǹǯǶǯǼǽ ǹǯǹ Ȍȁǽȁ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ǰȂdzǴȁ DZȊDzǺȎdzǴȁȋ Ǽǯ ȌǹǿǯǼǴ.
ǟǗǠ 4 ǗǶǻǴǼǴǼǷǴ ǼǯǾǿǯDZǺǴǼǷȎ DzǿǯdzǷǴǼȁǼǽǸ ǶǯǺǷDZǹǷ
ǓǽǰǯDZǺǴǼǷǴ ȁǽȆǴǹ DzǿǯdzǷǴǼȁǯ Ǒ ǾǿǴdzȊdzȂȈǴǻ ǾǿǷǻǴǿǴ ǾǽǹǯǶǯǼǽ ǻǷǼǷǻǯǺȋǼǽ DZǽǶǻǽǵǼǽǴ ǹǽǺǷȆǴȀȁDZǽ ȁǽȆǴǹ DzǿǯdzǷǴǼȁǯ ǹǽȁǽǿǽǴ ǿǯDZǼǽ dzDZȂǻ ǓǺȎ ȂǾǿǯDZǺǴǼǷȎ DzǿǯdzǷǴǼȁǽǻ ǻǽǵǼǽ ǶǯdzǯDZǯȁȋ dzǽǾǽǺǼǷȁǴǺȋǼȊǴ ȁǽȆǹǷ DzǿǯdzǷǴǼȁǯ Ƿ ȅDZǴȁǯ dzǺȎ ǼǷȄ ǜǯǾǿǷǻǴǿ ǴȀǺǷ ȁǿǴǰȂǴȁȀȎ ǾǽǺȂȆǷȁȋ DzǿǯdzǷǴǼȁǼȂȍ ǶǯǺǷDZǹȂ Ȁ ǷǶǻǴǼǴǼǷǴǻ ȅDZǴȁǯ ǽȁ ȆǴǿǼǽDzǽ ǹ ǰǴǺǽǻȂ Ƿ ǼǯǶǯdz ǹ ȆǴǿǼǽǻȂ ǻǽǵǼǽ ǽǾǿǴdzǴǺǷȁȋ ȁǿǷ ȁǽȆǹǷ ȀǺǴdzȂȍȈǷǻ ǽǰǿǯǶǽǻ
ǞǴǿDZǯȎ ȁǽȆǹǯ DZ ǾǽǶǷȅǷǷ ȆǴǿǼǯȎ DZȁǽǿǯȎ Ǽǯ ǾǽǺǾȂȁǷ DZdzǽǺȋ ǺǷǼǷǷ DzǿǯdzǷǴǼȁǯ DZ ǾǽǶǷȅǷǷ ǰǴǺǯȎ Ƿ ȁǿǴȁȋȎ ȁǽȆǹǯ DZ ǹǽǼȅǴ DzǿǯdzǷǴǼȁǯ DZ ǾǽǶǷȅǷǷ ȀǼǽDZǯ ȆǴǿǼǯȎ ǔȀǺǷ ȀȃǽǿǻǷǿǽDZǯȁȋ DZǷǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZ ǺǴǼǷǴ ȌȁǽDzǽ ǻǽǵǼǽ ǰȂdzǴȁ ȂDZǷdzǴȁȋ ǾǿǷǻǴǿǼǽ ȁǯǹǽǸ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ǹǯǹ ǾǿǴdzȀȁǯDZǺǴǼ Ǽǯ ǿǷȀ 4-5.
ǒǺǯDZǯ ǝȀǼǽDZȊ ;$0/
75
ǟǗǠ. 4 5 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȁǽȆǴǹ DzǿǯdzǷǴǼȁǯ
ǞǽǶǷȅǷǽǼǷǿǽDZǯǼǷǴ ȁǽȆǴǹ DzǿǯdzǷǴǼȁǯ DZȊǾǽǺǼȎǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ ǾǯǿǯǻǴȁǿǯ Offset ǠǻǴȈǴǼǷǴ ǾǽȌȁǽǻȂ ȆȁǽǰȊ ǾǴǿǴdzDZǷǼȂȁȋ ǰǴǺȂȍ ȀǴǹȅǷȍ dzǯǼǼǽDzǽ DzǿǯdzǷǴǼȁǯ ǰǺǷǵǴ ǹ DZǴǿȄǼǴǻȂ ǺǴDZǽǻȂ ȂDzǺȂ ǼǴǽǰȄǽdzǷǻǽ Ǿǿǽ Ȁȁǽ ǷǶǻǴǼǷȁȋ ǶǼǯȆǴǼǷǴ ǴDzǽ ȀDZǽǸȀȁDZǯ Offset ȁǯǹ ȆȁǽǰȊ ǽǼǽ ǰȊǺǽ ǰǺǷǵǴ ǹ ǼȂǺȍ ǹǯǹ ǾǽǹǯǶǯǼǽ DZ dzǯǼǼǽǻ ȃǿǯDzǻǴǼȁǴ XAML:
ǡǽ ǹǯǹ Ȍȁǽ ǻǴǼȎǴȁ DZǷdz ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 4-6. ǬǹȀǾǴǿǷǻǴǼȁǷǿȂȎ Ȁ ǾǽǶǷȅǷǽǼǷǿǽDZǯǼǷǴǻ Ƿ ǼǯǾǿǯDZǺǴǼǷȎǻǷ DzǿǯdzǷǴǼȁǯ ǻǽǵǼǽ dzǽǰǷȁȋȀȎ ǼǴǹǽȁǽǿȊȄ ǷǼ ȁǴǿǴȀǼȊȄ ȌȃȃǴǹȁǽDZ ǬȁǷ ȀDZǽǸȀȁDZǯ ǻǽDzȂȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ǶǯǾǽǺǼǴǼǷȎ ȃǷDzȂǿ ǷǺǷ ǽǾǿǴdzǴǺǴǼǷȎ ǹǽǼȁȂ ǿǽDZ ǹǯǹ ǰȂdzǴȁ ǾǽǹǯǶǯǼǽ dzǯǺǴǴ DZ dzǯǼǼǽǸ DzǺǯDZǴ
ǟǗǠ 6 ǞǽǶǷȅǷǽǼǷǿǽDZǯǼǷǴ ȁǽȆǹǷ DzǿǯdzǷǴǼȁǯ.
76
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
RadialGradientBrush RadialGradientBrush ǟǯdzǷǯǺȋǼǯȎ DzǿǯdzǷǴǼȁǼǯȎ ǹǷȀȁȋ ǯǼǯǺǽDzǷȆǼǯ LinearGradientBrush Ȁ ȁǽȆǹǷ ǶǿǴǼǷȎ ǽǾ ǿǴdzǴǺǴǼǷȎ Ǽǽ ǽǼǯ ǶǯdzǯǴȁ ǹǿȂDzǽDZǽǸ DzǿǯdzǷǴǼȁ DzdzǴ ȁǽȆǹǯ ǽǰǽǶǼǯȆǯǴȁ ȅǴǼȁǿ ǹǿȂDzǯ Ƿ ǽǰǽǶǼǯȆǯǴȁ DZǼǴȇǼǷǸ ǹǿǯǸ ǞǿǽȈǴ ǾǽǹǯǶǯȁȋ Ȍȁǽ Ǽǯ ǾǿǷǻǴǿǴ ǿǯȀȀǻǽȁǿǴDZ ȁǯǹǽǸ XAML:
Ǭȁǽȁ ǹǽdz ǽǰǴȀǾǴȆǷDZǯǴȁ ǶǯǾǽǺǼǴǼǷǴ ȃǷDzȂǿȊ DzǿǯdzǷǴǼȁǼǽǸ ǶǯǺǷDZǹǽǸ ǼǯȆǷǼǯȎ ǽȁ ȆǴǿǼǽDzǽ ȅDZǴȁǯ DZ ȅǴǼȁǿǴ Ƿ ǶǯǹǯǼȆǷDZǯȎ ǰǴǺȊǻ Ǿǽ ǹǿǯȎǻ ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 4- ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ DZȊ DZǷdzǷȁǴ ȌǺǺǷǾȀ ȁǯǹ ǹǯǹ DZǼǴȇǼǷǸ ǹǿǯǸ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ǰǴǺȊǸ, Ƿ ȃǽǼǽDZȊǸ ȅDZǴȁ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ǯǼǯǺǽDzǷȆǴǼ ȅDZǴȁȂ DZǼǴȇ ǼǴǸ ȁǽȆǹǷ DzǿǯdzǷǴǼȁǯ
ǟǗǠ 7 ǖǯǾǽǺǼǴǼǷǴ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ Ȁ ǾǽǻǽȈȋȍ RadialGradientBrush.
ǡǽȆǹǷ DzǿǯdzǷǴǼȁǯ dzǺȎ RadialGradientBrush ǽǾǿǴdzǴǺȎȍȁȀȎ ȁǴǻǷ ǵǴ ǻǴȁǽdzǯǻǷ Ȇȁǽ Ƿ dzǺȎ LinearGradientBrush.
ǖǯdzǯǼǷǴ ȃǽǹȂȀǯ ǞǿǷ DZȊǾǽǺǼǴǼǷǷ ǶǯǺǷDZǹǷ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ RadialGradientBrush, ȂȀȁǯǼǽDZǷDZ ȀDZǽǸȀȁDZǽ GradientOrigin (ǥǴǼȁǿ DzǿǯdzǷǴǼȁǯ , ǻǽǵǼǽ ǶǯdzǯDZǯȁȋ ȃǽǹȂȀ ǶǯǺǷDZǹǷ Ǭȁǽ ȀDZǽǸȀȁDZǽ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǶǯdzǯǼǷȎ ȁǽȆǹǷ ǼǯȆǯǺǯ DzǿǯdzǷǴǼȁǯ ǹǽȁǽǿǯȎ ǽǰȊȆǼǽ ǿǯȀǾǽǺǯDzǯǴȁȀȎ DZ ȅǴǼȁǿǴ ǹǿȂDzǯ. ǜǴȀǻǽȁǿȎ Ǽǯ ǿǯdzǷǯǺȋǼȂȍ ǾǿǷǿǽdzȂ RadialGradientBrush ȃǽǹȂȀ ǶǯdzǯǴȁȀȎ DZ ǾǿȎǻǽȂDzǽǺȋǼǽǻ ǼǽǿǻǷǿǽDZǯǼǼǽǻ ǾǿǽȀȁǿǯǼȀȁDZǴ ǞǽȌȁǽǻȂ ǴȀǺǷ ǼǴǽǰȄǽdzǷǻǽ ǿǯȀǾǽǺǽǵǷȁȋ ȃǽǹȂȀ DZ DZǴǿȄǼǴǻ ǺǴDZǽǻ ȂDzǺȂ ǶǯdzǯǸȁǴ GradientOrigin ǶǼǯȆǴǼǷǴ ǴȀǺǷ ǵǴǺǯǴȁǴ ǿǯȀǾǽǺǽǵǷȁȋ ǴDzǽ DZ ǼǷǵǼǴǻ ǾǿǯDZǽǻ ȂDzǺȂ ǶǯdzǯǸȁǴ GradientOrigin ǶǼǯȆǴǼǷǴ ǠǺǴdzȂȍȈǷǸ ǾǿǷǻǴǿ ǾǽǹǯǶȊDZǯǴȁ DzǿǯdzǷǴǼȁǼȂȍ ǶǯǺǷDZǹȂ ȃǽǹȂȀǼǯȎ ȁǽȆǹǯ ǹǽȁǽǿǽǸ ǿǯȀǾǽǺǯDzǯǴȁȀȎ DZ ǼǷǵǼǴǻ ǾǿǯDZǽǻ ȂDzǺȂ ǽǰȉǴǹȁǯ Ȁ ǹǽǽǿdzǷǼǯȁǯǻǷ
ǜǯ ǿǷȀ -8 ǾǿǴdzȀȁǯDZǺǴǼǽ ǹǯǹ Ȍȁǽ DZȊDzǺȎdzǷȁ
ǒǺǯDZǯ ǝȀǼǽDZȊ ;$0/
77
ǟǗǠ 8 ǖǯdzǼǷǴ ȃǽǹȂȀǯ RadialGradientBrush.
ǗǶǻǴǼǴǼǷǴ SpreadMethod Ǡ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ SpreadMethod (ǛǴȁǽdz ǿǯȀǾǿǽȀȁǿǯǼǴǼǷȎ ǻǽǵǼǽ ǽǾǿǴdzǴǺȎȁȋ ȄǯǿǯǹȁǴǿ ǾǽDZȁǽǿǴǼǷȎ DzǿǯdzǷǴǼȁǯ ǠȂȈǴȀȁDZȂǴȁ ȁǿǷ DZǽǶǻǽǵǼȊȄ ǶǼǯȆǴǼǷȎ SpreadMethod: Pad ǖǯǾǽǺǼǴǼǷǴ Reflect ǝȁǿǯǵǴǼǷǴ Ƿ Repeat ǞǽDZȁǽǿ Pad ǶǯǾǽǺǼȎǴȁ ǹǿȂDz DzǿǯdzǷǴǼȁǼǽǸ ǶǯǺǷDZǹǽǸ ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ ǶǯdzǯǼǼȊǻ ǾǯǿǯǻǴȁǿǯǻ Ƿ ȎDZǺȎǴȁȀȎ ǶǼǯȆǴǼǷǴǻ Ǿǽ ȂǻǽǺȆǯǼǷȍ ǜǯ ǿǷȀ 4- Ƿ -8 ǾǽǹǯǶǯǼǯ ǾǿǽǿǷȀǽDZǹǯ ǰǯǶǽDZǽǸ RadialGradientBrush dzǺȎ ǹǽȁǽǿǽǸ ǶǯdzǯǼ ǻǴȁǽdz ǿǯȀǾǿǽȀȁǿǯǼǴǼǷȎ Pad. ǜǷǵǴ ǾǿǴdzȀȁǯDZǺǴǼ XAML ǽǾǷȀȊDZǯȍȈǷǸ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ǶǯǾǽǺǼǴǼǼȊǸ DzǿǯdzǷǴǼȁǼǽǸ ǶǯǺǷDZǹǽǸ dzǺȎ ȀDZǽǸȀȁDZǯ SpreadMethod ǹǽȁǽǿǽǸ ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ Reflect ǟǴǶȂǺȋȁǯȁȊ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 4-9.
Ǭȁǽ ǾǿǷDZǽdzǷȁ ǹ ǽȁǿǯǵǴǼǷȍ DzǿǯdzǷǴǼȁǯ ǹǯǹ DZǷdzǼǽ Ǽǯ ǿǷȀ 4-9. ǓǺȎ dzǯǼǼǽDzǽ DzǿǯdzǷǴǼȁǯ ǽǾǿǴdzǴǺǴǼǽ Ȇȁǽ ǽǼ dzǽǺǵǴǼ ǷǶǻǴǼȎȁȋȀȎ ǽȁ ȆǴǿǼǽDzǽ ǹ ǰǴǺǽǻȂ Ǽǽ ǽǼ DZǽǶDZǿǯȈǯǴȁȀȎ ǽǾȎȁȋ ǹ ȆǴǿǼǽǻȂ ǹǯǹ ǰȂdzȁǽ ǽȁǿǯǵǯǴȁȀȎ ǏǼǯǺǽDzǷȆǼǽ ǻǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ ǻǴȁǽdz Repeat dzǺȎ ǾǽDZȁǽǿǴǼǷȎ DzǿǯdzǷǴǼȁǯ ǽȁ ȆǴǿǼǽDzǽ ǹ ǰǴǺǽǻȂ ǜǯ ǿǷȀ 4- ǾǽǹǯǶǯǼ ǿǴǶȂǺȋȁǯȁ ȌȁǽDzǽ ǧǯǰǺǽǼ DzǿǯdzǷǴǼȁǯ ǾǽDZȁǽǿȎǴȁȀȎ Ȁ ȁǽDzǽ ǻǴȀȁǯ DzdzǴ ǾǿǷ ǽǰȊȆǼȊȄ ȂȀǺǽDZǷ ȎȄ ǽǼ ǰȊǺ ǰȊ ǶǯDZǴǿȇǴǼ ǾǽDZȁǽǿȎȎ ǾǴǿǴȄǽdz ǽȁ ȆǴǿǼǽDzǽ ǹ ǰǴǺǽǻȂ DZǾǺǽȁȋ dzǽ DZǼǴȇǼǷȄ ǹǿǯǴDZ ǾǿȎǻǽȂDzǽǺȋǼǷ ǹǯ
78
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǟǗǠ 9 ǗȀǾǽǺȋǶǽDZǯǼǷǴ SpreadMethod Ȁǽ ǶǼǯȆǴǼǷǴǻ Reflect.
ǟǗǠ 10 ǗȀǾǽǺȋǶǽDZǯǼǷǴ SpreadMethod Ȁǽ ǶǼǯȆǴǼǷǴǻ Repeat.
ǖǯdzǯǼǷǴ ǿǯdzǷȂȀǯ RadialGradientBrush ǓǺȎ ǶǯdzǯǼǷȎ ǼǴǽǰȄǽdzǷǻǽDzǽ ǿǯdzǷȂȀǯ DzǿǯdzǷǴǼȁǼǽǸ ǶǯǺǷDZǹǷ ǷȀǾǽǺȋǶȂȍȁȀȎ ȀDZǽǸȀȁDZǯ RadiusX Ƿ RadiusY. ǖǼǯȆǴǼǷǴ Ǿǽ ȂǻǽǺȆǯǼǷȍ dzǺȎ ȌȁǷȄ ȀDZǽǸȀȁDZ ² 0,5. ǔȀǺǷ Ƕǯdzǯȁȋ ǻǴǼȋȇǴǴ ǶǼǯȆǴǼǷǴ, ǰȂdzǴȁ ǶǯǹǿǯȇǴǼǽ ǰǽǺȋ ȇǴ ǽdzǼǽDzǽ ǹǿȂDzǯ Ȁ ȂȆǴȁǽǻ ǾǽDZǴdzǴǼǷȎ ǾǿǽǿǷȀǽDZǹǷ, ǹǽȁǽǿǽǴ ǽǾǿǴdzǴǺȎǴȁȀȎ ǻǴȁǽdzǽǻ SpreadMethod ǔȀǺǷ Ƕǯdzǯȁȋ ǶǼǯȆǴǼǷǴ ǰǽǺȋȇǴ DzǿǯdzǷǴǼȁ ǰȂdzǴȁ ©ǿǯȀȁȎǼȂȁª ǜǯǾǿǷǻǴǿ ȀǺǴdzȂȍȈǷǸ ȃǿǯDzǻǴǼȁ XAML-ǹǽdzǯ ǽǾǿǴdzǴǺȎǴȁ RadialGradientBrush dzǺȎ ȀDZǽǸȀȁDZ RadiusX ǷRadiusY ǹǽȁǽǿǽǸ ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ Ƿ ȀDZǽǸȀȁDZǽ SpreadMethod ǼǴ ǶǯdzǯǼǽ ȁǴ Ǿǽ ȂǻǽǺȆǯǼǷȍ ǽǼǽ ǾǿǷǼǷǻǯǴȁ ǶǼǯȆǴǼǷǴ Pad).
Ǭȁǽȁ ǹǽdz ǽǰǴȀǾǴȆǷȁ ȃǽǿǻǷǿǽDZǯǼǷǴ DZǷǶȂǯǺȋǼǽDzǽ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ǶǯǺǷDZǹǯ ǹǽȁǽǿǽDzǽ DZȊ ǾǽǺǼȎǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ RadialGradientBrush Ȁ ǿǯdzǷȂȀǽǻ ǾǽȌȁǽǻȂ ǽǼǯ DZ ǾȎȁȋ ǿǯǶ ǻǴǼȋȇǴ ǽǰȉǴǹȁǽDZ ǹǽ ȁǽǿȊǴ ǰȊǺǷ ǾǿǴdzȀȁǯDZǺǴǼȊ ǿǯǼǴǴ Ǭȁǽ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 4-11.
ǒǺǯDZǯ ǝȀǼǽDZȊ ;$0/
79
ǟǗǠ 11 ǖǯdzǯǼǷǴ ǿǯdzǷȂȀǯ RadialGradientBrush.
Ǒ ȀǽȆǴȁǯǼǷǷ Ȁ ǻǴȁǽdzǽǻ SpreadMethod ǻǽǵǼǽ ǾǽǺȂȆǷȁȋ ǼǴǹǽȁǽǿȊǴ ǷǼȁǴǿǴȀǼȊǴ ȌȃȃǴǹȁȊ ǞǿǷǻǴǿ Ƕǯdzǯ ǼǷȎ ǶǼǯȆǴǼǷȎ Reflect dzǺȎ SpreadMethod ǾǿǴdzȀȁǯDZǺǴǼ Ǽǯ ǿǷȀ 4-12.
ǟǗǠ 12 ǗǶǻǴǼǴǼǷǴ ǶǼǯȆǴǼǷǸ ǿǯdzǷȂȀǯ DZ ȀǽȆǴȁǯǼǷǷ Ȁ ǷǶǻǴǼǴǼǷǴǻ ǶǼǯȆǴǼǷǸ SpreadMethod.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ImageBrush ǓǺȎ ǶǯǾǽǺǼǴǼǷȎ ǽǰǺǯȀȁǷ ǷǶǽǰǿǯǵǴǼǷǴǻ ǷȀǾǽǺȋǶȂǴȁȀȎ ImageBrush ǙǷȀȁȋ-ǷǶǽǰǿǯǵǴǼǷǴ ǠǽDzǺǯȀǼǽ Ǿǽ DZǴdzǴǼǷȍ, Ǿǽ ȂǻǽǺȆǯǼǷȍ ǹǷȀȁȋ ǻǴǼȎǴȁ ǿǯǶǻǴǿ ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ ǿǯǶǻǴǿȂ ǷǶǽǰǿǯǵǴǼǷȎ ǽǰǴȀǾǴȆǷDZǯȎ Ȁǽ ȄǿǯǼǴǼǷǴ ǴDzǽ ǾǿǽǾǽǿȅǷǸ ǠǺǴdzȂȍȈǷǸ XAML-ǹǽdz ǽǰǴȀǾǴȆǷDZǯǴȁ ǶǯǾǽǺǼǴǼǷǴ ȀǽdzǴǿǵǷǻǽDzǽ ǾǿȎǻǽȂDzǽǺȋ ǼǷǹǯ ImageBrush ǟǴǶȂǺȋȁǯȁȊ ǾǿǴdzȀȁǯDZǺǴǼȊ Ǽǯ ǿǷȀ 4-13):
ǟǯȀȁȎDzǷDZǯǼǷǴ ǷǶǽǰǿǯǵǴǼǷȎ Ǡ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ Stretch ǟǯȀȁȎǵǴǼǷǴ ǻǽǵǼǽ ǽǾǿǴdzǴǺǷȁȋ ȁǽ ǹǯǹ ǷǶǽǰǿǯǵǴǼǷǴ ǶǯǾǽǺǼȎǴȁ ǶǯǹǿǯȇǷ DZǯǴǻȂȍ ǽǰǺǯȀȁȋ Ǭȁǽ ǻǽǵǼǽ Ƕǯdzǯȁȋ Ȁ ǾǽǻǽȈȋȍ ǿȎdzǯ ǿǯǶǺǷȆǼȊȄ ǿǴǵǷǻǽDZ ǿǯȀȁȎǵǴǼǷȎ None ǜǴȁ Uniform ǟǯDZǼǽǻǴǿǼǽǴ UniformToFill ǟǯDZǼǽǻǴǿǼǽǴ ǶǯǾǽǺǼǴǼǷǴ Ƿ Fill ǖǯǾǽǺǼǴǼǷǴ
80
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǟǴǵǷǻ None ȃǽǿǻǷǿȂǴȁ DZǷǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ǷǶǽǰǿǯǵǴǼǷȎ ǰǴǶ ǷǶǻǴǼǴǼǷǸ DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ ǿǯȀ ȁȎǵǴǼǷǴ ǼǴ ǾǿǷǻǴǼȎǴȁȀȎ ǖǼǯȆǴǼǷǴ Uniform ǽǰȂȀǺǽDZǺǷDZǯǴȁ ǷǶǻǴǼǴǼǷǴ ǿǯǶǻǴǿǽDZ ǷǶǽǰǿǯǵǴǼǷȎ ȁǯǹ Ȇȁǽ ǰȊ ǽǼǽ ǶǯǾǽǺǼȎǺǽ ǾǿȎǻǽȂDzǽǺȋǼǷǹ Ǽǽ ǾǿǷ Ȍȁǽǻ ǼǴ ǻǴǼȎǴȁ ǴDzǽ ǾǿǽǾǽǿȅǷǷ UniformToFill ǷǶǻǴǼȎǴȁ ǿǯǶ ǻǴǿ ǷǶǽǰǿǯǵǴǼǷȎ ȁǯǹ ȆȁǽǰȊ ǽǼǽ ǻǯǹȀǷǻǯǺȋǼǽ ǶǯǾǽǺǼȎǺǽ ǽǰǺǯȀȁȋ DZȊDZǽdzǯ Ǽǽ ǾǿǷ Ȍȁǽǻ ǼǴ ǻǴǼȎǴȁ ǴDzǽ ǾǿǽǾǽǿȅǷǷ ǽǰǿǴǶǯȎ ǷǶǽǰǿǯǵǴǼǷǴ DZ ȀǺȂȆǯǴ ǼǴǽǰȄǽdzǷǻǽȀȁǷ ǖǼǯȆǴǼǷǴ Fill ǽǰǴȀǾǴȆǷȁ ǶǯǾǽǺǼǴǼǷǴ ǷǶǽ ǰǿǯǵǴǼǷǴǻ DZȀǴǸ ǽǰǺǯȀȁǷ DZȊDZǽdzǯ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴ ǼǴǶǯDZǷȀǷǻǽDzǽ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷȎ Ǿǽ ǽȀȎǻ Ȅ Ƿ Ȃ ǡǯ ǹǷǻ ǽǰǿǯǶǽǻ ǷǶǽǰǿǯǵǴǼǷǴ ǰȂdzǴȁ ǷȀǹǯǵǴǼǽ Ǽǽ ǾǽǺǼǽȀȁȋȍ ǶǯǾǽǺǼǷȁ dzǽȀȁȂǾǼȂȍ ǽǰǺǯȀȁȋ ǑȀǴ ȌȁǷ DZǯǿǷǯǼȁȊ DZ dzǴǸȀȁDZǷǷ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 4- Ǽǯ ǹǽȁǽǿǽǻ ǾǿǴdzȀȁǯDZǺǴǼǽ ȆǴȁȊǿǴ ǾǿȎǻǽ ȂDzǽǺȋǼǷǹǯ ǶǯǺǷDZǹǯ ǹǽȁǽǿȊȄ DZȊǾǽǺǼǴǼǯ ǽdzǼǷǻ Ƿ ȁǴǻ ǵǴ ǷǶǽǰǿǯǵǴǼǷǴǻ Ǽǽ Ȁ ǿǯǶǼȊǻǷ ǿǴǵǷǻǯǻǷ ǿǯȀ ȁȎǵǴǼǷȎ
ǟǗǠ 13 ǖǯǺǷDZǹǯ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ Ȁ ǾǽǻǽȈȋȍ ImageBrush.
ǟǗǠ 4 14 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǿǯǶǼȊȄ ǿǴǵǷǻǽDZ ȀDZǽǸȀȁDZǯ Stretch DZ ImageBrush.
ǑȊǿǯDZǼǷDZǯǼǷǴ ǷǶǽǰǿǯǵǴǼǷȎ ǑȊǿǯDZǼǷDZǯǼǷǴ ǷǶǽǰǿǯǵǴǼǷȎ Ǿǽ ǽȀȎǻ Ȅ Ƿ Ȃ ǽǾǿǴdzǴǺȎǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZ AlignmentX Ƿ AlignmentY. ǗǶǽǰǿǯǵǴǼǷǴ ǻǽǵǴȁ ǰȊȁȋ DZȊǿǽDZǼǴǼǽ DZdzǽǺȋ ǽȀǷ Ȅ Ǿǽ ǺǴDZǽǻȂ ǹǿǯȍ Ǿǽ ǾǿǯDZǽǻȂ ǹǿǯȍ Ǿǽ ȅǴǼȁǿȂ Ƿ DZdzǽǺȋ ǽȀǷ \ Ǿǽ DZǴǿȄȂ ȅǴǼȁǿȂ ǷǺǷ ǼǷǶȂ ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ ǴȀǺǷ ǷǶǽǰǿǯǵǴǼǷǴ ǿǯȀȁȎDzǷDZǯǴȁȀȎ dzǺȎ
ǒǺǯDZǯ ǝȀǼǽDZȊ ;$0/
81
ǶǯǾǽǺǼǴǼǷȎ ǽǰǺǯȀȁǷ ǶǯdzǯǼǷǴ DZȊǿǯDZǼǷDZǯǼǷȎ ǼǴ ǰȂdzǴȁ ǷǻǴȁȋ ǼǷǹǯǹǽDzǽ ȌȃȃǴǹȁǯ; ǽǼǽ ǷǻǴǴȁ ȀǻȊȀǺ ȁǽǺȋ ǹǽ ǹǽDzdzǯ ȀDZǽǸȀȁDZȂ Stretch ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ None ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ DZȊǿǯDZǼǷDZǯǼǷȎ ǷǶǽǰǿǯǵǴ ǼǷȎ Ǿǽ ǾǿǯDZǽǻȂ ǹǿǯȍ Ƿ ǼǷǶȂ
Ǚǯǹ Ȍȁǽ DZȊDzǺȎdzǷȁ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 4-15.
ǟǗǠ. 4 15 ǗȀǾǽǺȋǶǽDZǯǼǷǴ image alignment.
VideoBrush VideoBrush (ǑǷdzǴǽ-ǹǷȀȁȋ) ǾǽǶDZǽǺȎǴȁ ǶǯǾǽǺǼȎȁȋ ǽǰǺǯȀȁȋ DZǷdzǴǽ-Ǿǽȁǽǹǽǻ. ǐǽǺǴǴ ǾǽdzǿǽǰǼǽ Ȍȁǯ ǹǷȀȁȋ ǰȂdzǴȁ ǽǰȀȂǵdzǯȁȋȀȎ DZ ǒǺǯDZǴ ©ǛȂǺȋȁǷǻǴdzǷǯ ǿȂǹǽǾǷȀǼȊǸ DZDZǽdz Ƿ Deep Zoomª DZ ǹǽȁǽǿǽǸ ȁǯǹǵǴ ǰǽǺǴǴ ǾǽǺǼǽ ǰȂdzǴȁ ǽǾǷȀǯǼ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ MediaElement.
ǑǷǶȂǯǺȋǼȊǴ ȀDZǽǸȀȁDZǯ XAML ǙǿǽǻǴ ǹǷȀȁǴǸ Ƿ ǾǯǿǯǻǴȁǿǽDZ Canvas, XAML ǾǿǴdzǽȀȁǯDZǺȎǴȁ ǻǼǽǵǴȀȁDZǽ dzǿȂDzǷȄ ȀDZǽǸȀȁDZ dzǺȎ ȂǾǿǯDZǺǴǼǷȎ ǾǿǴdzȀȁǯDZǺǴǼǷǴǻ ǽǰȉǴǹȁǯ ǝǼǷ ǾǽǶDZǽǺȎȍȁ ǶǯdzǯDZǯȁȋ ǿǯǶǻǴǿȊ ǾǿǽǶǿǯȆǼǽȀȁȋ ǽǰȉǴǹȁǯ ǾǽDZǴdzǴǼǷǴ ǹȂǿȀǽǿǯ Ƿ ǽǰDZǽdzǹȂ.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀDZǽǸȀȁDZ XAML dzǺȎ ǶǯdzǯǼǷȎ ǿǯǶǻǴǿǽDZ Ƿ ǻǴȀȁǽǾǽǺǽǵǴǼǷȎ ǟǯǶǻǴǿȊ DZ XAML ǶǯdzǯȍȁȀȎ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZ Height Ƿ Width ǹǽȁǽǿȊǴ ǾǿǷǼǷǻǯȍȁ ǶǼǯȆǴǼǷȎ ȁǷǾǯ double ǦȁǽǰȊ ȀǽǶdzǯȁȋ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ȇǷǿǷǼǽǸ ǾǷǹȀǴǺǽDZ Ƿ DZȊȀǽȁǽǸ ǾǷǹȀǴǺǽDZ ǼǯǾǿǷǻǴǿ ǼǴǽǰȄǽdzǷǻǽ ǰȊǺǽ ǰȊ ǼǯǾǷȀǯȁȋ ȀǺǴdzȂȍȈǷǸ XAML-ǹǽdz
ǙǿǽǻǴ ȁǽDzǽ ǾǽǻǼǷȁǴ Ȇȁǽ ǽȁǼǽȀǷȁǴǺȋǼǽǴ ǻǴȀȁǽǾǽǺǽǵǴǼǷǴ ǽǰȉǴǹȁǯ ǶǯdzǯǴȁȀȎ ȆǴǿǴǶ ȁǽȆǹȂ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZ Top Ƿ Left DZ ǿǽdzǷȁǴǺȋȀǹǽǻ ȌǺǴǻǴǼȁǴ.
82
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǟǯȀȀǻǽȁǿǷǻ ȀǺǴdzȂȍȈǷǸ XAML:
ǞǿǴdzǾǽǺǽǵǷǻ Ȇȁǽ ȀǯǻȊǸ DZǼǴȇǼǷǸ ȌǺǴǻǴǼȁ Canvas ȎDZǺȎǴȁȀȎ ǹǽǿǼǴDZȊǻ ȄǽǺȀȁǽǻ ȀȁǿǯǼǷȅȊ Ǒ ǿǴǶȂǺȋȁǯ ȁǴ Rectangle ǰȂdzǴȁ ǽȁǿǷȀǽDZǯǼ Ǽǯ ǿǯȀȀȁǽȎǼǷǷ ǾǷǹȀǴǺǽDZ ǽȁ DZǴǿȄǯ ȀȁǿǯǼǷȅȊ ǾǽȁǽǻȂ Ȇȁǽ ǴDzǽ ǿǽdzǷȁǴǺȋ ȀǹǷǸ ȄǽǺȀȁ ǽǾȂȈǴǼ Ǽǯ ǾǷǹȀǴǺǽDZ DZǼǷǶ Ƿ Rectangle ǿǯȀǾǽǺǽǵǴǼ Ǽǯ ǾǷǹȀǴǺǽDZ DZǼǷǶ ǽȁ DZǴǿȄǼǴDzǽ ǹǿǯȎ ȀDZǽǴDzǽ ǿǽdzǷȁǴǺȎ Ȇȁǽ DZ ȀȂǻǻǴ dzǯǴȁ ǾǷǹȀǴǺǽDZ
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǾǿǽǶǿǯȆǼǽȀȁǷ ǞǿǽǶǿǯȆǼǽȀȁȋ ǽǰȉǴǹȁǯ ǻǽǵǴȁ ǰȊȁȋ ǶǯdzǯǼǯ dzDZȂǻȎ ȀǾǽȀǽǰǯǻǷ ǞǴǿDZȊǸ ² Ȁ ǾǽǻǽȈȋȍ ǯǺȋȃǯ-ǹǯǼǯǺǯ ǹǷȀȁǷ ǹǽȁǽǿǯȎ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǶǯǺǷDZǹǷ ǽǰȉǴǹȁǯ ǠǺǴdzȂȍȈǷǸ XAML-ǹǽdz ǽǰǴȀǾǴȆǷȁ ȀǽǶdzǯǼǷǴ ȆǴǿǼǽDzǽ ǾǿȎǻǽ ȂDzǽǺȋǼǷǹǯ ǾǽDZǴǿȄ ǿǷȀȂǼǹǯ
Ǒ ǹǯȆǴȀȁDZǴ ǶǼǯȆǴǼǷȎ ȀDZǽǸȀȁDZǯ Fill ǶǯdzǯǴȁȀȎ ȆǴǿǼȊǸ ȅDZǴȁ ǾǽȁǽǻȂ Ȇȁǽ ǹǿǯȀǼǽǻȂ ǶǴǺǴǼǽǻȂ Ƿ ȀǷǼǴǻȂ ǹǯ ǼǯǺǯǻ ǶǯdzǯǼ Ƿ ǯǺȋȃǯ-ǹǯǼǯǺ ǶǯdzǯǼ ǼǴǾǿǽǶǿǯȆǼȊǻ ǶǼǯȆǴǼǷǴ FF ǛǴǼȎȎ ǶǼǯȆǴǼǷǴ ǹǯǼǯǺǯ ǯǺȋȃǯ, ǻǽǵǼǽ ȀdzǴǺǯȁȋ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ǾǽǺȂǾǿǽǶǿǯȆǼȊǻ
ǡǴǾǴǿȋ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ǰȂdzǴȁ DZȊDzǺȎdzǴȁȋ ȀǴǿȊǻ Ƿ ȀǹDZǽǶȋ ǼǴDzǽ ǰȂdzǴȁ DZǷdzǼǽ ǷǶǽǰǿǯǵǴǼǷǴ ǑȁǽǿǽǸ ǻǴȁǽdz ² ǷȀǾǽǺȋǶǽDZǯȁȋ ȀDZǽǸȀȁDZǽ Opacity (ǜǴǾǿǽǶǿǯȆǼǽȀȁȋ ǹǽȁǽǿǽǴ ǾǿǷǼǷǻǯǴȁ ǶǼǯȆǴǼǷȎ DZ dzǷǯ ǾǯǶǽǼǴ ǽȁ ǾǽǺǼǽȀȁȋȍ ǾǿǽǶǿǯȆǼȊǸ dzǽ ǾǽǺǼǽȀȁȋȍ ǼǴǾǿǽǶǿǯȆǼȊǸ Ǭȁǽ ȀDZǽǸȀȁDZǽ ǾǿǷǻǴǼȎǴȁȀȎ DZ Ȁǽ ȆǴȁǯǼǷǷ Ȁ ǽǾǿǴdzǴǺǴǼǷǴǻ ǯǺȋȃǯ-ǹǯǼǯǺǯ ǹǷȀȁǷ ǔȀǺǷ dzǺȎ ǶǯǺǷDZǹǷ ȃǷDzȂǿȊ ǷȀǾǽǺȋǶǽDZǯȁȋ ǹǷȀȁȋ ȅDZǴȁǯ ǼǯǾǿǷǻǴǿ Ƿ ǶǯȁǴǻ Ƕǯdzǯȁȋ ȀDZǽǸȀȁDZȂ Opacity ǶǼǯȆǴǼǷǴ ǾǿȎǻǽȂDzǽǺȋǼǷǹ DZȀǴ ǿǯDZǼǽ ǰȂdzǴȁ ǼǴ ǾǿǽǶǿǯȆǼȊǻ ǔȀǺǷ Ƕǯdzǯȁȋ ȀDZǽǸȀȁDZȂ Opacity ǶǼǯȆǴǼǷǴ 0, ǾǿȎǻǽȂDzǽǺȋǼǷǹ ǰȂdzǴȁ ȀǽDZǴǿȇǴǼǼǽ ǾǿǽǶǿǯȆǼȊǻ. ǠDZǽǸȀȁDZǽ Opacity ȂdzǽǰǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ dzǺȎ ǯǼǷǻǯȅǷǷ ǾǿǽǶǿǯȆǼǽȀȁǷ ǽǰȉǴǹȁǯ ǝǼǽ ǾǽǶDZǽǺȎǴȁ ǰǴǶ ȁǿȂdzǯ ǿǴǯǺǷǶǽDZǯȁȋ ȌȃȃǴǹȁ ǾǽȀȁǴǾǴǼǼǽDzǽ ǷȀȆǴǶǼǽDZǴǼǷȎ Ƿ ǾǽȎDZǺǴǼǷȎ ǽǰȉǴǹȁǯ ȆǴǿǴǶ DoubleAnimation. ǐǽǺǴǴ ǾǽdzǿǽǰǼǽ ǯǼǷǻǯȅǷȎ ǿǯȀȀǻǯȁǿǷDZǯǴȁȀȎ DZ ǒǺǯDZǴ ©ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷǻǯȅǷȎ XAMLª
ǞǽDZǴdzǴǼǷǴ ǹȂǿȀǽǿǯ ǐǽǺȋȇǷǼȀȁDZǽ ȌǺǴǻǴǼȁǽDZ XAML ǾǽǶDZǽǺȎȍȁ ǷȀǾǽǺȋǶǽDZǯȁȋ ȀDZǽǸȀȁDZǽ Cursor ǙȂǿȀǽǿ dzǺȎ ǶǯdzǯǼǷȎ DZǷdzǯ ǹȂǿȀǽǿǯ ǾǿǷ ǴDzǽ ǾǿǽȄǽǵdzǴǼǷǷ Ǿǽ ȌǺǴǻǴǼȁȂ Ǭȁǽ ȀDZǽǸȀȁDZǯ ǾǿǷǼǷǻǯǴȁ ǶǼǯȆǴǼǷȎ ǾǴǿǴȆǷȀǺǴǼǷȎ MouseCursor ǙȂǿȀǽǿ ǻȊȇǷ x
Arrow ǠȁǿǴǺǹǯ
ǝȁǽǰǿǯǵǯǴȁȀȎ ǽǰȊȆǼȊǸ ȀȁǯǼdzǯǿȁǼȊǸ ǹȂǿȀǽǿ-ȀȁǿǴǺǹǯ
x
Default ǠȁǯǼdzǯǿȁǼȊǸ ǜǴȁ ǾǿǴdzǾǽȆȁǷȁǴǺȋǼǽDzǽ ǹȂǿȀǽǿǯ ǷȀǾǽǺȋǶȂǴȁȀȎ ǹȂǿȀǽǿ ǿǽdzǷȁǴǺȋȀǹǽDzǽ ȌǺǴǻǴǼȁǯ, ǴȀǺǷ ȁǯǹǽDZǽǸ ǶǯdzǯǼ
x
Hand ǟȂǹǯ
x
IBeam (I-ǽǰǿǯǶǼȊǸ
x
None ǜǴȁ
x
Wait ǝǵǷdzǯǼǷǴ ǖǯdzǯǴȁ ǶǼǯȆǽǹ ǹǽȁǽǿȊǸ ǽǰǽǶǼǯȆǯǴȁ ȀǽȀȁǽȎǼǷǴ ǽǵǷdzǯǼǷȎ
ǝȁǽǰǿǯǵǯǴȁȀȎ ǹȂǿȀǽǿ-ǿȂǹǯ ǽǰȊȆǼǽ ǷȀǾǽǺȋǶȂǴǻȊǸ dzǺȎ ȀȀȊǺǽǹ ǝǾǿǴdzǴǺȎǴȁ I-ǽǰǿǯǶǼȊǸ ǹȂǿȀǽǿ ǽǰȊȆǼǽ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ DZȊǰǽǿǯ ȁǴǹȀȁǯ
ǙȂǿȀǽǿ ǽȁȀȂȁȀȁDZȂǴȁ
ǢǾǿǯDZǺǴǼǷǴ ȀDZǽǸȀȁDZǽǻ Stroke ǠDZǽǸȀȁDZǽ Stroke ǽǾǿǴdzǴǺȎǴȁ ǹǯǹ ǹǽǼȁȂǿ ȃǷDzȂǿȊ ǽȁǿǷȀǽDZȊDZǯǴȁȀȎ Ǽǯ ȌǹǿǯǼǴ ǝǰDZǽdzǹǯ ȃǷDzȂǿȊ ǽȁǺǷȆǯǴȁȀȎ ǽȁ ǴǴ ǶǯǺǷDZǹǷ.
ǒǺǯDZǯ ǝȀǼǽDZȊ ;$0/
83
Stroke ǶǯdzǯǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ ǹǷȀȁǷ ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ XAML-ǹǽdzǯ DZ ǹǽȁǽǿǽǻ ǾǿǽǿǷȀǽDZǹǯ ǾǿȎ ǻǽȂDzǽǺȋǼǷǹǯ ȃǽǿǻǷǿȂǴȁȀȎ ȆǴǿǼȊǻ ǹǽǼȁȂǿǽǻ ǶǯdzǯǼǼȊǻ Ȁ ǾǽǻǽȈȋȍ ǾǿǽȀȁǽǸ ǽǰDZǽdzǹǷ
Ǟǽ ȀȂȁǷ ȀDZǽǸȀȁDZǽ Stroke, DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ, ǷȀǾǽǺȋǶȂǴȁ SolidColorBrush ȆǴǿǼǽDzǽ ȅDZǴȁǯ Black). ǠǷǼȁǯǹȀǷ ȆǴȀǹǷ Ȍȁǽ ȌǹDZǷDZǯǺǴǼȁǼǽ ȀǺǴdzȂȍȈǴǻȂ XAML:
ǗȀǾǽǺȋǶȂȎ ȁǯǹǽǸ ȀǷǼȁǯǹȀǷȀ ǽǾǿǴdzǴǺǴǼǷǴ ǹǷȀȁǷ DZ ǹǯȆǴȀȁDZǴ ǾǿǷȀǽǴdzǷǼǴǼǼǽDzǽ ȀDZǽǸȀȁDZǯ Stroke ǻǽǵǼǽ ǶǯdzǯDZǯȁȋ ǿǯǶǼȊǴ ȁǷǾȊ ǹǷȀȁǴǸ dzǺȎ ǽȁǿǷȀǽDZǹǷ ǽǰDZǽdzǹǷ ȃǷDzȂǿȊ ǓǯǺǴǴ ǾǿǷDZǴdzǴǼ ǾǿǷǻǴǿ ǾǿǷǻǴǼǴǼǷȎ LinearGradientBrush dzǺȎ ǽǰDZǽdzǹǷ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ:
Ǚǯǹ Ȍȁǽ DZȊDzǺȎdzǷȁ Ǽǯ ȌǹǿǯǼǴ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 4-16.
ǟǗǠ 16 ǗȀǾǽǺȋǶǽDZǯǼǷǴ LinearGradientBrush dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ ǽǰDZǽdzǹǷ ȃǷDzȂǿȊ
ǖǯdzǯǼǷǴ ȇǷǿǷǼȊ ǽǰDZǽdzǹǷ ǑǽǶǻǽǵǼǽ DZȊ ǶǯǻǴȁǷǺǷ Ȇȁǽ DZ Ȍȁǽǻ ǾǿǷǻǴǿǴ ǰȊǺǯ ǶǯdzǯǼǯ ȇǷǿǷǼǯ ǽǰDZǽdzǹǷ Ǭȁǽ ȀdzǴǺǯǼǽ dzǺȎ dzǴǻǽǼ ȀȁǿǯȅǷǷ DzǿǯdzǷǴǼȁǼǽDzǽ ǷǶǻǴǼǴǼǷȎ ȅDZǴȁǯ ǾǽȀǹǽǺȋǹȂ ǾǿǷ ǷȀǾǽǺȋǶǽDZǯǼǷǷ ǶǼǯȆǴǼǷȎ ȁǽǺȈǷǼȊ Ǿǽ ȂǻǽǺȆǯ ǼǷȍ ǴDzǽ ǾǿǽȀȁǽ ǼǴ ǰȊǺǽ ǰȊ DZǷdzǼǽ ǧǷǿǷǼǯ ǽǰDZǽdzǹǷ ǶǯdzǯǴȁȀȎ ȀDZǽǸȀȁDZǽǻ StrokeThickness ǡǽǺȈǷǼǯ ǽǰDZǽdzǹǷ ǝǼǽ ǽǾǿǴdzǴǺȎǴȁ ȇǷǿǷǼȂ ǽǰ DZǽdzǹǷ DZ ǾǷǹȀǴǺǯȄ
84
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǖǯdzǯǼǷǴ ǽǰDZǽdzǹǷ ǾȂǼǹȁǷǿǽǻ ǠDZǽǸȀȁDZǽ StrokeDashArray (ǛǯȀȀǷDZ dzǺǷǼ ȌǺǴǻǴǼȁǽDZ ǽǰDZǽdzǹǷ ǾȂǼǹȁǷǿǽǻ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǶǯdzǯǼǷȎ ȇǯǰ ǺǽǼǯ ǽǰDZǽdzǹǷ ǾȂǼǹȁǷǿǽǻ Ǒ ȀǽȆǴȁǯǼǷǷ Ȁǽ ȀDZǽǸȀȁDZǯǻǷ StrokeDashCap (ǜǯǹǽǼǴȆǼǷǹǷ ȌǺǴǻǴǼȁǽDZ ǽǰDZǽdzǹǷ ǾȂǼǹȁǷǿǽǻ Ƿ StrokeDashOffset ǠǻǴȈǴǼǷǴ ǽǰDZǽdzǹǷ ǾȂǼǹȁǷǿǽǻ ǽǼǽ ǽǰǴȀǾǴȆǷDZǯǴȁ dzǴȁǯǺȋǼǽǴ ǽǾǷȀǯǼǷǴ ǽǰDZǽdzǹǷ ǾȂǼǹȁǷǿǽǻ ǦȁǽǰȊ ǽǰDZǽdzǹǯ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ǰȊǺǯ DZȊǾǽǺǼǴǼǯ ǾȂǼǹȁǷǿǽǻ Ǿǽ ǽǾǿǴdzǴǺǴǼǼǽǻȂ ǾǽDZȁǽǿȎȍȈǴǻȂȀȎ ȇǯǰǺǽǼȂ ǶǯdzǯǴȁȀȎ ǻǯȀȀǷDZ ǶǼǯȆǴǼǷǸ ȁǷǾǯ double ǹǽȁǽǿȊǴ ǾǿǴdzȀȁǯDZǺȎȍȁ dzǺǷǼȊ ȆǴǿǴdzȂȍȈǷȄȀȎ ȇȁǿǷȄǽDZ Ƿ ǾǿǽǰǴǺǽDZ ǦȁǽǰȊ ǽǾǿǴdzǴǺǷȁȋ ȇǯǰǺǽǼ ǾȂǼǹȁǷǿǯ Ȁ dzǺǷǼǽǸ ȇȁǿǷȄǯ ǴdzǷǼǷȅȊ Ƕǯ ǹǽȁǽǿȊǻ ȀǺǴdzȂǴȁ ǾǿǽǰǴǺ dzǺǷǼǽǸ ǴdzǷǼǷȅǯ ȇȁǿǷȄ dzǺǷǼǽǸ ǴdzǷǼǷȅȊ Ƿ ǾǿǽǰǴǺ dzǺǷǼǽǸ ǴdzǷǼǷȅǯ ȀDZǽǸȀȁDZȂ StrokeDashArray ǰȊǺǽ ǰȊ ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ Ǒǽȁ ǾǿǷǻǴǿ
ǜǯ ǿǷȀ 4- ǾǽǹǯǶǯǼǽ ǹǯǹ Ȍȁǽ DZȊDzǺȎdzǴǺǽ ǰȊ Ǽǯ ȌǹǿǯǼǴ
ǟǗǠ 17 ǖǯdzǯǼǷǴ ȇǯǰǺǽǼǯ ǽǰDZǽdzǹǷ ǾȂǼǹȁǷǿǽǻ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ StrokeDashArray.
Ǚǯǹ DZǷdzǷǻ ȇȁǿǷȄǷ ǽǰDZǽdzǹǷ ǷǻǴȍȁ ǾǿȎǻǽȂDzǽǺȋǼȂȍ ȃǽǿǻȂ Ȁ ǼǴȀǹǽȇǴǼǼȊǻǷ ǹǿǽǻǹǯǻǷ ǗǶǻǴǼǷȁȋ Ȍȁǽ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ǻǽǵǼǽ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ StrokeDashCap Ǒ ǹǯȆǴȀȁDZǴ ǴDzǽ ǶǼǯȆǴǼǷǸ ǷȀǾǽǺȋǶȂǴȁȀȎ ǶǼǯ ȆǴǼǷȎ ǾǴǿǴȆǷȀǺǴǼǷȎ PenLineCap (ǜǯǹǽǼǴȆǼǷǹǷ ǺǷǼǷǸ): x
Flat ǞǺǽȀǹǷǸ Ǭȁǽ ǶǼǯȆǴǼǷǴ Ǿǽ ȂǻǽǺȆǯǼǷȍ; ǽǼǽ ǽǾǿǴdzǴǺȎǴȁ Ȇȁǽ ǼǯǹǽǼǴȆǼǷǹ ǼǴ DZȊȄǽdzǷȁ Ƕǯ ǹǿǯǸ ǺǷǼǷǷ ² ǯǼǯǺǽDzǷȆǼǽ ǽȁȀȂȁȀȁDZǷȍ ǼǯǹǽǼǴȆǼǷǹǯ.
x
Round ǙǿȂDzǺȊǸ
x
Square ǙDZǯdzǿǯȁǼȊǸ
x
Triangle ǡǿǴȂDzǽǺȋǼȊǸ ǝǾǿǴdzǴǺȎǴȁ ǿǯDZǼǽǰǴdzǿǴǼǼȊǸ ȁǿǴȂDzǽǺȋǼȊǸ ǼǯǹǽǼǴȆǼǷǹ ǰǯǶǽDZǯȎ dzǺǷǼǯ ǹǽȁǽǿǽDzǽ ǿǯDZǼǯ ȁǽǺȈǷǼǴ ǽǰDZǽdzǹǷ
ǖǯdzǯǴȁ ǾǽǺȂǹǿȂDz dzǷǯǻǴȁǿ ǹǽȁǽǿǽDzǽ ǿǯDZǴǼ ȁǽǺȈǷǼǴ ǺǷǼǷǷ ǝǾǿǴdzǴǺȎǴȁ ǹDZǯdzǿǯȁǼȊǸ ǼǯǹǽǼǴȆǼǷǹ.
ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ ǷȀǾǽǺȋǶǽDZǯǼǷȎ StrokeDashCap dzǺȎ ǶǯdzǯǼǷȎ ȀǹǿȂDzǺǴǼǼȊȄ ȇȁǿǷȄǽDZ ǽǰDZǽdzǹǷ ǾȂǼǹȁǷǿǽǻ
ǜǯ ǿǷȀ 4- ǾǽǹǯǶǯǼǽ ǹǯǹ Ȍȁǽ ǰȂdzǴȁ DZȊDzǺȎdzǴȁȋ Ǽǯ ȌǹǿǯǼǴ
ǒǺǯDZǯ ǝȀǼǽDZȊ ;$0/
85
ǟǗǠ 18 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀDZǽǸȀȁDZǯ StrokeDashCap.
ǝǾǿǴdzǴǺǴǼǷǴ ȁǷǾǯ ȀǽǴdzǷǼǴǼǷȎ ǺǷǼǷǸ ǔȀǺǷ DZǶDzǺȎǼȂȁȋ ǼǴ ǾǿǴdzȊdzȂȈǷǴ ǾǿǷǻǴǿȊ ǻǽǵǼǽ ǶǯǻǴȁǷȁȋ Ȇȁǽ ȇȁǿǷȄǷ ǾȂǼǹȁǷǿǯ ǾǴǿǴȀǴǹǯȍȁȀȎ DZ ȂDzǺǯȄ Ƿ ǽȁǿǷȀǽDZȊDZǯȍȁȀȎ ȀǾǿȎǻǺǴǼǼȊǻǷ Ǭȁǽ ȀȆǷȁǯǴȁȀȎ ȀǽǴdzǷǼǴǼǷǴǻ ǺǷǼǷǸ Ǡ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ StrokeLineJoin ǠǽǴdzǷǼǴǼǷǴ ǺǷǼǷǸ ǽǰDZǽdzǹǷ ǻǽǵǼǽ ǽǾǿǴdzǴǺȎȁȋ ǾǽDZǴdzǴǼǷǴ ǾǴǿǯ ǾǿǷ ȀǽǴdzǷǼǴǼǷǷ ǺǷǼǷǸ Ǭȁǽ ȀDZǽǸȀȁDZǽ ǾǿǷǼǷǻǯǴȁ ǾǴǿǴȆǷȀǺǴǼǷǴ PenLineJoin ǹǽȁǽǿǽǴ ǻǽǵǴȁ ȀǽdzǴǿǵǯȁȋ ǽdzǼǽ ǷǶ ȀǺǴdzȂȍȈǷȄ ȁǿǴȄ ǶǼǯȆǴǼǷǸ x
Bevel ǠǹǽȀ ǠǿǴǶǯǴȁ ǹǿǯȎ ȀǽǴdzǷǼǴǼǷȎ
x
Miter ǞǿȎǻǽǸ ȂDzǽǺ
ǠǽȄǿǯǼȎǴȁ ǽȀȁǿȊǴ ǹǿǯȎ
x
Round ǠǹǿȂDzǺǴǼǷǴ
ǠǹǿȂDzǺȎǴȁ ǹǿǯȎ ȀǽǴdzǷǼǴǼǷȎ
ǓǯǼǼȊǸ XAML-ǹǽdz ȀǽǶdzǯǴȁ ǾǿȎǻǽȂDzǽǺȋǼǷǹ dzǺȎ ǹǽȁǽǿǽDzǽ ǶǯdzǯǼ ȁǷǾ ȀǽǴdzǷǼǴǼǷȎ ǺǷǼǷǸ Bevel:
Ǚǯǹ Ȍȁǽ ǽȁǽǰǿǯǵǯǴȁȀȎ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 4-19.
ǟǗǠ. 4 19 ǗȀǾǽǺȋǶǽDZǯǼǷǴ StrokeLineJoin dzǺȎ ǶǯdzǯǼǷȎ ȀǿǴǶǯǼǼȊȄ ȂDzǺǽDZ
86
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǣǷDzȂǿȊ DZ XAML XAML ǾǽdzdzǴǿǵǷDZǯǴȁ ǿȎdz ǰǯǶǽDZȊȄ ȃǷDzȂǿ ǹǽȁǽǿȊǴ ǻǽDzȂȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ȀǽǶdzǯǼǷȎ ǰǽǺǴǴ ȀǺǽǵǼȊȄ ǽǰȉǴǹȁǽDZ Ǚ ǼǷǻ ǽȁǼǽȀȎȁȀȎ: x
Ellipse ǬǺǺǷǾȀ
ǝȁǿǷȀǽDZȊDZǯǴȁ ȌǺǺǷǾȀ ǹǿȂDz ² Ȍȁǽ ȌǺǺǷǾȀ Ȁ ǿǯDZǼȊǻǷ ǿǯdzǷȂȀǯǻǷ Ǿǽ ǽȀȎǻ X Ƿ Y
x
Rectangle ǞǿȎǻǽȂDzǽǺȋǼǷǹ ǝȁǿǷȀǽDZȊDZǯǴȁ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ǹDZǯdzǿǯȁ ² Ȍȁǽ ǾǿȎǻǽȂDzǽǺȋǼǷǹ Ȁ ǿǯDZ ǼȊǻǷ ǿǯǶǻǴǿǯǻǷ Ǿǽ ǽȀȎǻ X ǷY
x
Line ǚǷǼǷȎ
x
Path ǙǽǼȁȂǿ ǝȁǿǷȀǽDZȊDZǯǴȁ ǾǽȀǺǴdzǽDZǯȁǴǺȋǼǽȀȁȋ ȀǽǴdzǷǼǴǼǼȊȄ ǾǿȎǻȊȄ Ƿ ǹǿǷDZȊȄ ǺǷǼǷǸ ȀǽǽȁDZǴȁ ȀȁDZǴǼǼǽ ȎǶȊǹȂ ǽǾǷȀǯǼǷȎ ǹǽǼȁȂǿǽDZ
x
Polygon ǛǼǽDzǽȂDzǽǺȋǼǷǹ ǺǷǼǷǸ
x
Polyline (ǚǽǻǯǼǯȎ)
ǝȁǿǷȀǽDZȊDZǯǴȁ ǾǿȎǻȂȍ ǺǷǼǷȍ
ǝȁǿǷȀǽDZȊDZǯǴȁ ǶǯǻǹǼȂȁȂȍ ȃǷDzȂǿȂ ǽǰǿǯǶǽDZǯǼǼȂȍ ǿȎdzǽǻ ȀǽǴdzǷǼǴǼǼȊȄ
ǝȁǿǷȀǽDZȊDZǯǴȁ ǿȎdz ǾǽȀǺǴdzǽDZǯȁǴǺȋǼǽ ȀǽǴdzǷǼǴǼǼȊȄ ǾǿȎǻȊȄ
Ǒ ȀǺǴdzȂȍȈǷȄ ǿǯǶdzǴǺǯȄ ǻȊ ǿǯȀȀǻǽȁǿǷǻ ǹǯǵdzȂȍ ǷǶ ȌȁǷȄ ȃǷDzȂǿ.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǽǰȉǴǹȁǯ Ellipse ǣǷDzȂǿǯ Ellipse ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǽȁǿǷȀǽDZǹǷ ȌǺǺǷǾȀǯ ǷǺǷ ǹǿȂDzǯ ǑȊȀǽȁǯ Ellipse ǽǾǿǴdzǴǺȎǴȁȀȎ DZǴǿȁǷǹǯǺȋǼȊǻ dzǷǯǻǴȁǿǽǻ ȁǴ dzDZǽǸǼȊǻ ǿǯdzǷȂȀǽǻ Ǿǽ DZǴǿȁǷǹǯǺǷ , ǴDzǽ ȇǷǿǷǼǯ ǽǾǿǴdzǴǺȎǴȁȀȎ DzǽǿǷǶǽǼȁǯǺȋǼȊǻ dzǷǯǻǴȁǿǽǻ ǔȀǺǷ ȌȁǷ ǶǼǯȆǴǼǷȎ ǿǯDZǼȊ XAML ȀȃǽǿǻǷǿȂǴȁ ǹǿȂDz ǙǽǼȁȂǿ Ellipse ǽȁǿǷȀǽDZȊDZǯǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ Stroke Ƿ ǶǯǹǿǯȇǷDZǯǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ Brush.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǽǰȉǴǹȁǯ Rectangle Rectangle ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǽȁǿǷȀǽDZǹǷ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ǷǺǷ ǹDZǯdzǿǯȁǯ ǟǯǶǻǴǿȊ dzǯǼǼǽǸ ȃǷDzȂǿȊ ǶǯdzǯȍȁȀȎ ȀDZǽǸȀȁDZǯǻǷ Width Ƿ Height. ǔȀǺǷ ǶǼǯȆǴǼǷȎ ȌȁǷȄ ȀDZǽǸȀȁDZ ǿǯDZǼȊ ǾǽǺȂȆǯǴǻ ǹDZǯdzǿǯȁ Ǚǯǹ Ƿ dzǺȎ Ellipse ǹǽǼȁȂǿ Rectangle ǽȁǿǷȀǽDZȊDZǯǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ Stroke dzǺȎ ǶǯǺǷDZǹǷ ǷȀǾǽǺȋǶȂǴȁȀȎ Brush. ǗȀǾǽǺȋǶȂȎ ȀDZǽǸȀȁDZǯ RadiusX Ƿ RadiusY ǻǽǵǼǽ ȀǹǿȂDzǺǷȁȋ ȂDzǺȊ Rectangle ǖǯdzǯDZǯȎ ȌȁǷǻ ȀDZǽǸȀȁDZǯǻ ǶǼǯȆǴ ǼǷȎ ȁǷǾǯ double DZȊ ǽǾǿǴdzǴǺȎǴȁǴ ǼǴǽǰȄǽdzǷǻȊǸ ǿǯdzǷȂȀ ȀǹǿȂDzǺǴǼǷȎ Ǟǽ ȂǻǽǺȆǯǼǷȍ ǽǼǷ ǿǯDZǼȊ Ȇȁǽ ȂǹǯǶȊDZǯǴȁ Ǽǯ ǽȁȀȂȁȀȁDZǷǴ ȀǹǿȂDzǺǴǼǷȎ ǞǽȀǹǽǺȋǹȂ ȀDZǽǸȀȁDZǯ RadiusX Ƿ RadiusY ǶǯdzǯȍȁȀȎ ǼǴǶǯDZǷȀǷǻǽ dzǿȂDz ǽȁ dzǿȂDzǯ ǾǿǷǻǴǼȎȎ ǿǯǶǼȊǴ ǶǼǯȆǴǼǷȎ dzǺȎ ǼǷȄ ǻǽǵǼǽ ǾǽǺȂȆǷȁȋ ȌǺǺǷǾȁǷȆǴȀǹǷǴ ȀǹǿȂDzǺǴǼǷȎ ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ Ȁǽ ȀǹǿȂDzǺǴǼǼȊǻǷ ȂDzǺǯǻǷ ǠDZǽǸȀȁDZȂ RadiusY ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ Ƿ ȀDZǽǸȀȁDZȂ RadiusX ² ǶǼǯȆǴǼǷǴ Ǭȁǽ ȂǹǯǶȊDZǯǴȁ Ǽǯ ȁǽ Ȇȁǽ ȂDzǺȊ ǰȂdzȂȁ ǰǽǺǴǴ ǾǽǺǽDzǷǻǷ DZ DZǴǿȁǷǹǯǺȋǼǽǻ ǼǯǾǿǯDZǺǴǼǷǷ
ǟǴǶȂǺȋȁǯȁȊ ǶǯdzǯǼǷȎ ȁǯǹǷȄ ǶǼǯȆǴǼǷǸ DZ dzǴǸȀȁDZǷǷ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 4-20.
ǒǺǯDZǯ ǝȀǼǽDZȊ ;$0/
87
ǟǗǠ 20 ǠǹǿȂDzǺǴǼǷǴ ȂDzǺǽDZ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǽǰȉǴǹȁǯ Line Ǡ ǾǽǻǽȈȋȍ ǽǰȉǴǹȁǯ Line ǻǽǵǼǽ ȀǽǶdzǯȁȋ ǾǿǽȀȁȂȍ ǺǷǼǷȍ DZ XAML. ǓǺȎ ȌȁǽDzǽ ǶǯdzǯȍȁȀȎ ǹǽǽǿdzǷǼǯȁȊ (X1,Y Ƿ X2,Y Ƿ ǺǷǼǷȎ ǽȁǿǷȀǽDZȊDZǯǴȁȀȎ ǻǴǵdzȂ ȌȁǷǻǷ ȁǽȆǹǯǻǷ ǓǯǼǼȊǴ ǹǽǽǿdzǷǼǯȁȊ ǶǯdzǯȍȁȀȎ ǽȁǼǽȀǷ ȁǴǺȋǼǽ DZǴǿȄǼǴDzǽ ǺǴDZǽDzǽ ȂDzǺǯ ǽǰǺǯȀȁǷ ǹǽȁǽǿȊǸ ǽǾǿǴdzǴǺȎǴȁȀȎ ȀDZǽǸȀȁDZǯǻǷ Canvas.Top Ƿ Canvas.Left ǹǯǹ ǽǰȊȆǼǽ ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ ȆȁǽǰȊ ǺǷǼǷȎ ǰȊǺǯ ǽȁǿǷȀǽDZǯǼǯ ǽǰȎǶǯȁǴǺȋǼǽ dzǽǺǵǼǯ ǰȊȁȋ ǽǾǿǴdzǴǺǴǼǯ ǽǰDZǽdzǹǯ ȄǽȁȎ ǰȊ ǴǴ ȅDZǴȁ ǟǯȀȀǻǽȁǿǷǻ ȀǺǴdzȂȍȈǷǸ XAML:
Ǭȁǽ ǽǰǴȀǾǴȆǷȁ ǽȁǿǷȀǽDZǹȂ ǺǷǼǷǷ ȀǽǴdzǷǼȎȍȈǴǸ ȁǽȆǹȂ Ȁ ȁǽȆǹǽǸ ǝdzǼǯǹǽ ǴȀǺǷ dzǽǰǯDZǷȁȋ ȀDZǽǸȀȁDZǯ Canvas.Top ǷǷǺǷ Canvas.Left ǺǷǼǷȎ ǰȂdzǴȁ ǽȁǿǷȀǽDZȊDZǯȁȋȀȎȀǽ ȀǻǴȈǴǼǷǴǻ. ǔȀǺǷ ǾǿǴdzǾǽǺǽǵǷȁȋ Ȇȁǽ ǿǽdzǷȁǴǺȋȀǹǷǸ ȄǽǺȀȁ ǼǴ ǾǽǶǷȅǷǽǼǷǿǽDZǯǼ ȀǺǴdzȂȍȈǷǸ XAML ǽǰǴȀǾǴȆǷȁ ȀǽǶdzǯǼǷǴ ǺǷǼǷǷ ȀǽǴdzǷǼȎȍ ȈǴǸ ȁǽȆǹǷ Ƿ ǔȀǺǷ ǾǽǶǷȅǷǽǼǷǿǽDZǯǼǷǴ ǾǿǷȀȂȁȀȁDZȂǴȁ Silverlight ǽȁǿǷȀȂǴȁ ǺǷǼǷȍ ǽȁǼǽ ȀǷȁǴǺȋǼǽ ǾǽǶǷȅǷǷ ǿǽdzǷȁǴǺȋȀǹǽDzǽ ȌǺǴǻǴǼȁǯ
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǹǽǼȁȂǿǽDZ Ƿ DzǴǽǻǴȁǿǷȆǴȀǹǷȄ ȌǺǴǻǴǼȁǽDZ ǝǰȉǴǹȁ Path ǽȁǿǷȀǽDZȊDZǯǴȁ ǾǽȀǺǴdzǽDZǯȁǴǺȋǼǽȀȁȋ ȀǽǴdzǷǼǴǼǼȊȄ ǾǿȎǻȊȄ Ƿ ǹǿǷDZȊȄ ǺǷǼǷǸ ǬȁǷ ǾǿȎǻȊǴ Ƿ ǹǿǷDZȊǴ ǽǾǿǴdzǴǺȎȍȁȀȎ ȁǷǾǽǻ DzǴǽǻǴȁǿǷȆǴȀǹǽDzǽ ȌǺǴǻǴǼȁǯ. ǖdzǴȀȋ ǰȂdzȂȁ ǿǯȀȀǻǽȁǿǴǼȊ ǿǯǶǺǷȆǼȊǴ ȁǷǾȊ DzǴǽǻǴȁǿǷȆǴȀǹǷȄ ȌǺǴǻǴǼȁǽDZ. EllipseGeometry (ǒǴǽǻǴȁǿǷȆǴȀǹǷǸ ȌǺǴǻǴǼȁ ȌǺǺǷǾȀ ǽǾǿǴdzǴǺȎǴȁ ǹǽǼȁȂǿ ǹǯǹ ǾǿǽȀȁǽǸ ȌǺǺǷǾȀ ǜǯǾǿǷǻǴǿ:
ǟǯǶǻǴǿȊ ȌǺǺǷǾȀǯ ǽǰǿǯǶȂȍȈǴDzǽ ǹǽǼȁȂǿ ǶǯdzǯȍȁȀȎ DZ EllipseGeometry Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZ RadiusX Ƿ RadiusY ǡǯǹǵǴ Ȁ ǾǽǻǽȈȋȍ ǯȁǿǷǰȂȁǯ Center ǥǴǼȁǿ ǻǽǵǼǽ Ƕǯdzǯȁȋ ȅǴǼȁǿ ȌǺǺǷǾȀǯ ǜǯǾǿǷǻǴǿ
88
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
LineGeometry (ǒǴǽǻǴȁǿǷȆǴȀǹǷǸ ȌǺǴǻǴǼȁ ǾǿȎǻǯȎ) ǽǾǿǴdzǴǺȎǴȁ ǹǽǼȁȂǿ ǹǯǹ ǽdzǼȂ ǺǷǼǷȍ ǼǯȆǷǼǯȍȈȂȍȀȎ DZ StartPoint Ƿ ǶǯǹǯǼȆǷDZǯȍȈȂȍȀȎ DZ EndPoint ǬȁǷ ȁǽȆǹǷ ǶǯdzǯȍȁȀȎ Ȁ ǾǽǻǽȈȋȍ ǾǿǽȀȁȊȄ ǹǽǽǿdzǷǼǯȁ Ȅ Ƿ Ȃ ȁǯ ǹǷǻ ǽǰǿǯǶǽǻ DZǴǿȄǼǷǸ ǺǴDZȊǸ ȂDzǽǺ ǶǯdzǯǴȁȀȎ ǹǯǹ (0,0). Ǒǽȁ ǾǿǷǻǴǿ LineGeometry:
RectangleGeometry ǽǾǿǴdzǴǺȎǴȁ ǹǽǼȁȂǿ ǹǯǹ ǽȁdzǴǺȋǼȊǸ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ǟǯǶǻǴǿȊ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ Ƕǯdzǯ ȍȁȀȎ ȀDZǽǸȀȁDZǽǻ Rect Ǭȁǽ Ȁȁǿǽǹǯ ǷǶ ȆǴȁȊǿǴȄ ǶǼǯȆǴǼǷǸ ȀǽǽȁDZǴȁȀȁDZȂȍȈǷȄ ǽȁȀȁȂǾȂ ȀDZǴǿȄȂ ǽȁȀȁȂǾȂ ȀǺǴDZǯ DZȊȀǽȁǴ Ƿ ȇǷǿǷǼǴ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ Ǘȁǯǹ ȆȁǽǰȊ ǽȁǿǷȀǽDZǯȁȋ ǾǿȎǻǽȂDzǽǺȋǼǷǹ Ǽǯ ǾǷǹȀǴǺǽDZ DZǴǿȄ ǼǷǸ ǺǴDZȊǸ ȂDzǽǺ ǹǽȁǽǿǽDzǽ ǿǯȀǾǽǺǯDzǯǴȁȀȎ DZ ȁǽȆǹǴ ǷȀǾǽǺȋǶǽDZǯǺȀȎ ǰȊ ȀǺǴdzȂȍȈǷǸ Path:
ǝǰȉǴǹȁ PathGeometry ǒǴǽǻǴȁǿǷȆǴȀǹǷǸ ȌǺǴǻǴǼȁ ǹǽǼȁȂǿ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǶǯdzǯǼǷȎ ȀǺǽǵǼǽDzǽ ǹǽǼȁȂǿǯ ȀǽȀȁǽȎȈǴDzǽ ǷǶ ǿǯǶǼȊȄ ȀǴDzǻǴǼȁǽDZ DZǹǺȍȆǯȎ dzȂDzǷ ǹǿǷDZȊǴ ǐǴǶȋǴ ǾǿȎǻȊǴ ǺǷǼǷǷ ǹǿǷDZȊǴ ǐǴǶȋǴ DZȊȀȇǷȄ ȀȁǴǾǴǼǴǸ ǾǽǺǷǹDZǯdzǿǯȁǷȆǴȀǹǷǴ ǹǿǷDZȊǴ ǐǴǶȋǴ Ƿ ǹDZǯdzǿǯȁǷȆǴȀǹǷǴ ǹǿǷDZȊǴ ǐǴǶȋǴ ǠǴDzǻǴǼȁȊ ǽǰǿǯǶȂȍȁ PathFigure ǣǽǿǻǯ ǹǽǼȁȂǿǯ Ƿ ǽdzǷǼ ǷǺǷ ǰǽǺǴǴ ǽǰȉǴǹȁǽDZ PathFigure ǽǰǿǯǶȂȍȁ PathGeometry. PathGeometry ȁǯǹǵǴ ǶǯdzǯǴȁ ǼǯȆǯǺȋǼȂȍ ȁǽȆǹȂ ǹǽǼȁȂǿǯ ǔȀǺǷ ǷǻǴǴȁȀȎ ǻǼǽǵǴȀȁDZǽ ȀǴDzǻǴǼȁǽDZ ǼǯȆǯǺȋǼǽǸ ȁǽȆǹǽǸ ǹǯǵ dzǽDzǽ ǾǽȀǺǴdzȂȍȈǴDzǽ ȀǴDzǻǴǼȁǯ ǰȂdzǴȁ ǹǽǼǴȆǼǯȎ ȁǽȆǹǯ ǾǿǴdzȊdzȂȈǴDzǽ ȀǴDzǻǴǼȁǯ.
ǝǰȉǴǹȁ ArcSegment ǝǰȉǴǹȁ ArcSegment ǠǴDzǻǴǼȁ dzȂDzǯ ǽȁǿǷȀǽDZȊDZǯǴȁ ǾǿǽȀȁȂȍ ȌǺǺǷǾȁǷȆǴȀǹȂȍ dzȂDzȂ ǻǴǵdzȂ dzDZȂǻȎ ȁǽȆǹǯǻǷ ǓȂDzǯ ǽǾǷȀȊDZǯǴȁȀȎ ǿȎdzǽǻ ǿǯǶǼǽǽǰǿǯǶǼȊȄ ȀDZǽǸȀȁDZ x
Point (ǡǽȆǹǯ)
ǖǯdzǯǴȁ ǼǯȆǯǺȋǼȂȍ ȁǽȆǹȂ dzȂDzǷ
x
Size (ǟǯǶǻǴǿ) ǖǯdzǯǴȁ ǿǯdzǷȂȀ dzȂDzǷ Ǿǽ ǽȀȎǻ x Ƿ y
x
RotationAngle (ǢDzǽǺ ǾǽDZǽǿǽȁǯ) ǖǯdzǯǴȁ ȂDzǽǺ ǾǽDZǽǿǽȁǯ, ȁ.Ǵ. ȁǽ ǼǯȀǹǽǺȋǹǽ ȀǷǺȋǼǽ dzȂDzǯ ǶǯǹǿȂȆǴǼǯ DZǽǹǿȂDz ǽȀǷ Ȅ
x
IsLargeArc (ǮDZǺȎǴȁȀȎ ǺǷ dzȂDzǯ ǹǿȂǾǼǽǸ) ǝǾǿǴdzǴǺȎǴȁ, ȎDZǺȎǴȁȀȎ ǺǷ dzȂDzǯ ǹǿȂǾǼǽǸ, DzdzǴ ǹǿȂǾǼǽǸ ȀȆǷ ȁǯǴȁȀȎ dzȂDzǯ ǰǽǺǴǴ
x
SweepDirection (ǜǯǾǿǯDZǺǴǼǷǴ ǿǯǶDZǴǿȁȊDZǯǼǷȎ) ǖǯdzǯǴȁ ǼǯǾǿǯDZǺǴǼǷǴ ǽȁǿǷȀǽDZǹǷ dzȂDzǷ (Clockwise (Ǟǽ ȆǯȀǽDZǽǸ ȀȁǿǴǺǹǴ ǷǺǷ CounterClockwise (ǞǿǽȁǷDZ ȆǯȀǽDZǽǸ ȀȁǿǴǺǹǷ )
Ǒǽȁ ǾǿǷǻǴǿ Path Ȁ ǽdzǼǷǻ dzȂDzǽDZȊǻ ȀǴDzǻǴǼȁǽǻ DZ ǹǽȁǽǿǽǻ dzǴǻǽǼȀȁǿǷǿȂȍȁȀȎ dzǯǼǼȊǴ ȀDZǽǸȀȁDZǯ
ǝǰȉǴǹȁ LineSegment ǓǽǰǯDZǷȁȋ ǾǿȎǻȂȍ ǺǷǼǷȍ DZ PathSegment (ǠǴDzǻǴǼȁ ǹǽǼȁȂǿǯ) ǻǽǵǼǽ Ȁ ǾǽǻǽȈȋȍ ǽǰȉǴǹȁǯ LineSegment (ǠǴDzǻǴǼȁ ǺǷǼǷȎ). ǝǼ ǾǿǽȀȁǽ ǽȁǿǷȀǽDZȊDZǯǴȁ ǾǿȎǻȂȍ ǺǷǼǷȍ ǽȁ ȁǴǹȂȈǴǸ ǷǺǷ ǼǯȆǯǺȋǼǽǸ ȁǽȆǹǷ dzǽ ȁǽȆǹǷ
ǒǺǯDZǯ ǝȀǼǽDZȊ ;$0/
89
ǶǯdzǯǼǼǽǸ ȀDZǽǸȀȁDZǽǻ Point Ǘȁǯǹ ȆȁǽǰȊ ǽȁǿǷȀǽDZǯȁȋ ǾǿȎǻȂȍ ǷǶ ȁǽȆǹǷ dzǽ ȁǽȆǹǷ Ƿ Ƕǯ ȁǴǻ ǴȈǴ ǽdzǼȂ dzǽ ȁǽȆǹǷ ȀǽǶdzǯǴȁȀȎ PathFigure ȀǽdzǴǿǵǯȈǷǸ ǼǴȀǹǽǺȋǹǽ ǺǷǼǴǸǼȊȄ ȀǴDzǻǴǼȁǽDZ
ǝǰȉǴǹȁ PolyLineSegment Ǚǯǹ ȀǺǴdzȂǴȁ ǷǶ ǴDzǽ ǷǻǴǼǷ, Ȁ ǾǽǻǽȈȋȍ ǽǰȉǴǹȁǯ PolyLineSegment (ǠǴDzǻǴǼȁ ǺǽǻǯǼǯȎ) ǻǽǵǼǽ ǽȁǿǷȀǽDZǯȁȋ ǿȎdz ǾǿȎǻȊȄ, ǾǿǽȀȁǽ ǶǯdzǯDZ ȁǽȆǹǷ. ǞǴǿDZǯȎ ǺǷǼǷȎ ǽȁǿǷȀǽDZȊDZǯǴȁȀȎ ǻǴǵdzȂ ǼǯȆǯǺȋǼǽǸ ȁǽȆǹǽǸ Ƿ ǾǴǿDZǽǸ Ƕǯ dzǯǼǼǽǸ ȁǽȆǹǽǸ DZȁǽǿǯȎ ² ǻǴǵdzȂ ȌȁǽǸ ȁǽȆǹǽǸ Ƿ DZȁǽǿǽǸ ǶǯdzǯǼǼǽǸ ȁǽȆǹǽǸ Ƿ ȁdz ǓǯǺǴǴ ǾǿǷDZǴdzǴǼ XAML-ǹǽdz dzǴǻǽǼȀȁǿǷǿȂȍȈǷǸ PolyLineSegment:
ǝǰȉǴǹȁ BezierSegment Ǭȁǽȁ ǽǰȉǴǹȁ ǾǽǶDZǽǺȎǴȁ ǽǾǷȀȊDZǯȁȋ ǹǿǷDZȂȍ ǐǴǶȋǴ ǹǽȁǽǿǯȎ ȎDZǺȎǴȁȀȎ ǹǿǷDZǽǸ ǻǴǵdzȂ dzDZȂǻȎ ȁǽȆǹǯǻǷ ǽǾǿǴdzǴ ǺȎǴǻǽǸ ǽdzǼǽǸ ǷǺǷ dzDZȂǻȎ ǽǾǽǿǼȊǻǷ ȁǽȆǹǯǻǷ ǝǰȉǴǹȁ BezierSegment ǠǴDzǻǴǼȁ ǹǿǷDZǯȎ ǐǴǶȋǴ ǾǿǷǼǷǻǯǴȁ DZ ǹǯȆǴȀȁDZǴ ǾǯǿǯǻǴȁǿǽDZ ȁǿǷ ȁǽȆǹǷ ǼǯǶȊDZǯǴǻȊǴ Point1, Point2 Ƿ Point3 Ǒ ǶǯDZǷȀǷǻǽȀȁǷ ǽȁ ȁǽDzǽ ȀǹǽǺȋǹǽ ȁǽȆǴǹ ǷȀǾǽǺȋǶȂǴȁȀȎ DZȊ ǾǽǺȂȆǯǴȁǴ ǿǯǶǼǽǴ ǾǽDZǴdzǴǼǷǴ Ǘȁǯǹ ǼǯǾǿǷǻǴǿ ǴȀǺǷ ǶǯdzǯǼȊ Point1 Ƿ Point2 ǹǿǷDZǯȎ ǰȂdzǴȁ ȀȃǽǿǻǷǿǽDZǯǼǯ ǽȁ ǼǯȆǯǺȋǼǽǸ ȁǽȆǹǷ DZ ȁǽȆǹȂ Point2 Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ Point1 DZ ǹǯȆǴȀȁDZǴ ǽǾǽǿǼǽǸ ȁǽȆǹǷ ǔȀ ǺǷ ǶǯdzǯǼȊ Point1, Point2 Ƿ Point3 ǹǿǷDZǯȎ ȃǽǿǻǷǿȂǴȁȀȎ ǽȁ ǼǯȆǯǺȋǼǽǸ ȁǽȆǹǷ DZ ȁǽȆǹȂ Point3, Point1 Ƿ Point2 ǷȀǾǽǺȋǶȂȍȁȀȎ ǹǯǹ ǽǾǽǿǼȊǴ Ǒǽȁ ǾǿǷǻǴǿ PathFigure, ȀǽdzǴǿǵǯȈǴDzǽ BezierSegment:
ǝǰȉǴǹȁ PolyBezierSegment Ǭȁǽȁ ǽǰȉǴǹȁ ǾǽǶDZǽǺȎǴȁ ǶǯdzǯDZǯȁȋ DzǿȂǾǾȂ ȁǽȆǴǹ ǹǽȁǽǿȊǴ Silverlight ǷǼȁǴǿǾǿǴȁǷǿȂǴȁ DZ Ǽǯǰǽǿ ǽǾǽǿǼȊȄ ȁǽ ȆǴǹ dzǺȎ DzǿȂǾǾȊ ǹǿǷDZȊȄ ǐǴǶȋǴ ǟǯȀȀǻǽȁǿǷǻ ȀǺǴdzȂȍȈǷǸ XAML:
90
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
Ǚǯǹ ǯǺȋȁǴǿǼǯȁǷDZǼȊǸ DZǯǿǷǯǼȁ ǻǽǵǼǽ Ƕǯdzǯȁȋ ǿȎdz ȁǽȆǴǹ Ȁ ǾǽǻǽȈȋȍ ǹǽǺǺǴǹȅǷǷ ȁǽȆǴǹ ȄǿǯǼȎȈǴǸȀȎ DZ DZǷdzǴ ȀȁǿǽǹǷ ǶǼǯȆǴǼǷǸ ǿǯǶdzǴǺǴǼǼȊȄ ǶǯǾȎȁȊǻǷ
ǑǷǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ȌȁǽDzǽ XAML-ȃǿǯDzǻǴǼȁǯ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 4- Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ ǼǯȆǯǺȋǼǯȎ ȁǽȆǹǯ ǽǾǿǴdzǴǺǴǼǯ ǹǽǽǿdzǷǼǯȁǯǻǷ Ȍȁǽ DZǴǿȄǼȎȎ ǺǴDZǯȎ ȁǽȆǹǯ DZȀǴǸ ǹǿǷDZǽǸ ǞǴǿDZǯȎ ǹǿǷDZǯȎ ǐǴǶȋǴ ǶǯǹǯǼȆǷDZǯǴȁȀȎ DZ ȁǽȆǹǴ ǷȀǾǽǺȋǶȂȎ ȁǽȆǹǷ Ƿ DZ ǹǯȆǴȀȁDZǴ ǽǾǽǿǼȊȄ ǞǽȀǹǽǺȋǹȂ ȌȁǷ ȁǽȆǹǷ ȌȃȃǴǹȁǷDZǼǽ ǽȁǻǴǼȎȍȁ dzǴǸȀȁDZǷǴ dzǿȂDz dzǿȂDzǯ ǽǼǷ ǿǯDZǼǽȂdzǯǺǴǼȊ ǽȁ ǺǷǼǷǷ ȀǽǴdzǷǼȎȍȈǴǸ ȁǽȆǹǷ [100,100] Ƿ [250,250] ǾǴǿDZǯȎ ǹǿǷDZǯȎ ǐǴǶȋǴ ȎDZǺȎǴȁȀȎ ǾǿȎǻǽǸ ǺǷǼǷǴǸ ǽǹǯǼȆǷDZǯȍȈǴǸȀȎ DZ ȁǽȆǹǴ (250,250). ǑȁǽǿǯȎ ǹǿǷDZǯȎ ǐǴǶȋǴ ǼǯȆǷǼǯǴȁȀȎ DZ ȌȁǽǸ ȁǽȆǹǴ Ƿ ǶǯǹǯǼȆǷDZǯǴȁȀȎ DZ ȁǽȆǹǴ Ȁ ǽǾǽǿǼȊǻǷ ȁǽȆǹǯǻǷ (100,200) Ƿ (200,100), ǰǺǯDzǽdzǯǿȎ ȆǴǻȂ ǽǼǯ ǾǿǷǼǷǻǯǴȁ DZǷdz ǾǴȁǺǷ
ǟǗǠ. 4 21 ǗȀǾǽǺȋǶǽDZǯǼǷǴ PolyBezierSegment.
ǝǰȉǴǹȁ QuadraticBezierSegment ǙDZǯdzǿǯȁǷȆǴȀǹǯȎ ǹǿǷDZǯȎ ǐǴǶȋǴ ² Ȍȁǽ ǾǿǽȀȁǽ ǹǿǷDZǯȎ ǐǴǶȋǴ, ǾǽȀȁǿǽǴǼǼǯȎ ǹǯǹ ǽǰȊȆǼǯȎ ǹDZǯdzǿǯȁǷȆǴȀǹǯȎ ǹǿǷDZǯȎ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǴdzǷǼȀȁDZǴǼǼǽǸ ǽǾǽǿǼǽǸ ȁǽȆǹǷ. QuadraticBezierSegment ǠǴDzǻǴǼȁ ǹDZǯdzǿǯȁǷȆǴ ȀǹǯȎ ǹǿǷDZǯȎ ǐǴǶȋǴ ǾǿǷǼǷǻǯǴȁ dzDZǯ ǽǰȉǴǹȁǯ Point ǔȀǺǷ ǷȀǾǽǺȋǶȂǴȁȀȎ ȁǽǺȋǹǽ ǽdzǷǼ ǽǰȉǴǹȁ ǽǼ ȀȁǯǼǽDZǷȁȀȎ ǹǽǼǴȆǼǽǸ ȁǽȆǹǽǸ ǹǿǷDZǽǸ Ǒ Ȍȁǽǻ ȀǺȂȆǯǴ ǹǽǼȁǿǽǺȋǼǽǸ ȁǽȆǹǷ ǼǴȁ Ƿ ǹǿǷDZǯȎ ǾǿǷǼǷǻǯǴȁ ȃǽǿǻȂ ǾǿȎǻǽǸ ǺǷǼǷǷ ȀǽǴdzǷǼȎȍȈǴǸ ǼǯȆǯǺȋǼȂȍ Ƿ ǶǯdzǯǼǼȂȍ ǹǽǼǴȆǼȂȍ ȁǽȆǹǷ ǔȀǺǷ ǶǯdzǯǴȁȀȎ dzDZǴ ȁǽȆǹǷ DZȁǽǿǯȎ ȁǽȆǹǯ
ǒǺǯDZǯ ǝȀǼǽDZȊ ;$0/
91
ǾǿǷǼǷǻǯǴȁȀȎ Ƕǯ ǹǽǼǴȆǼȂȍ ȁǽȆǹȂ ǹǿǷDZǽǸ ǯ ǾǴǿDZǯȎ ȁǽȆǹǯ ȀȁǯǼǽDZǷȁȀȎ ǹDZǯdzǿǯȁǷȆǴȀǹǽǸ ǽǾǽǿȁǼǽǸ ȁǽȆǹǽǸ Ǒǽȁ ǾǿǷǻǴǿ:
ǙǿǷDZǯȎ ȃǽǿǻǷǿȂǴǻǯȎ dzǯǼǼȊǻ XAML ǾǿǴdzȀȁǯDZǺǴǼǯ Ǽǯ ǿǷȀ 4-22.
ǟǗǠ 22 ǞǿǽȀȁǯȎ ǹDZǯdzǿǯȁǷȆǴȀǹǯȎ ǹǿǷDZǯȎ ǐǴǶȋǴ
ǝǰȉǴǹȁ PolyQuadraticBezierSegment Ǚǯǹ ȀǺǴdzȂǴȁ ǷǶ ǴDzǽ ǷǻǴǼǷ PolyQuadraticBezierSegment ǠǴDzǻǴǼȁ ǾǽǺǷǹDZǯdzǿǯȁǷȆǴȀǹǯȎ ǹǿǷDZǯȎ ǐǴǶȋǴ ȎDZǺȎǴȁȀȎ ǹǽǺǺǴǹȅǷǴǸ ȀǽǴdzǷǼǴǼǼȊȄ ǹDZǯdzǿǯȁǷȆǴȀǹǷȄ ǹǿǷDZȊȄ ǐǴǶȋǴ ǽǾǿǴdzǴǺǴǼǼȊȄ Ƿ ǾǽȀȁǿǽǴǼǼȊȄ ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ ȀǾǷȀǹȂ ǽǾǽǿǼȊȄ ȁǽȆǴǹ ǯǼǯǺǽDzǷȆǼǽ ȁǽǻȂ ǹǯǹ Ȍȁǽ ǽǾǷȀȊDZǯǺǽȀȋ ǿǯǼǴǴ dzǺȎ ǽǰȉǴǹȁǯ PolyBezierSegment ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ PolyQuadraticBezierSegment DZ dzǴǸȀȁDZǷǷ
ǑǷǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ dzǯǼǼǽDzǽ XAML-ȃǿǯDzǻǴǼȁǯ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ. 4-23.
92
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǟǗǠ 23 ǝǰȉǴǹȁ DZ dzǴǸȀȁDZǷǷ PolyQuadraticBezier.
ǓǯǼǼȊǸ ǹǽdz ǽǰǴȀǾǴȆǷDZǯǴȁ ǾǽȀȁǿǽǴǼǷǴ ǿȎdzǯ ǹDZǯdzǿǯȁǷȆǴȀǹǷȄ ǹǿǷDZȊȄ ǐǴǶȋǴ ǞǴǿDZǯȎ ȀȁǿǽǷȁȀȎ ǻǴǵdzȂ Ǽǯ ȆǯǺȋǼǽǸ ȁǽȆǹǽǸ (100,100), Ƿ ȁǽȆǹǽǸ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ȁǽȆǹǷ (50,50) DZ ǹǯȆǴȀȁDZǴ ǽǾǽǿǼǽǸ, Ȇȁǽ DZ ǿǴǶȂǺȋȁǯȁǴ dzǯǴȁ ǾǿȎǻȂȍ ǺǷǼǷȍ ǽǹǯǼȆǷDZǯȍȈȂȍȀȎ DZ ȁǽȆǹǴ (150,150) ǑȁǽǿǯȎ ǹǿǷDZǯȎ ǼǯȆǷǼǯǴȁȀȎ DZ ȁǽȆǹǴ (150,150) Ƿ ǶǯǹǯǼȆǷDZǯǴȁȀȎ DZ ȁǽȆǹǴ (100,200) Ȁ ǽǾǽǿǼǽǸ ȁǽȆǹǽǸ (250,250) Ǭȁǽ ȀǴDzǻǴǼȁ DZ ǹǽȁǽǿǽǻ ǹǿǷDZǯȎ ǿǯǶDZǽǿǯȆǷDZǯǴȁȀȎ DZǺǴDZǽ ǡǿǴȁȋȎ ǹǿǷDZǯȎ ǼǯȆǷǼǯǴȁȀȎ DZ ȁǽȆǹǴ (100,200) Ƿ ǶǯǹǯǼȆǷDZǯǴȁȀȎ DZ ȁǽȆǹǴ (300,300) Ȁ ǽǾǽǿǼǽǸ ȁǽȆǹǽǸ ǜǯ ǿǷȀ. 4-23 Ȍȁǽ dzǺǷǼǼǯȎ ȀDzǺǯǵǴǼǼǯȎ ǹǿǷDZǯȎ ǷdzȂȈǯȎ ȀǺǴDZǯ ǼǯǾǿǯDZǽ
ǠǽȀȁǯDZǼȊǴ ȀǴDzǻǴǼȁȊ ǹǽǼȁȂǿǯ ǙǯǵdzȊǸ ǷǶ ǿǯȀȀǻǽȁǿǴǼǼȊȄ ȁǷǾǽDZ ȀǴDzǻǴǼȁǽDZ ǻǽǵǴȁ DZȄǽdzǷȁȋ DZ ȀǽȀȁǯDZ ȀǴDzǻǴǼȁǯ PathFigure ǙǿǽǻǴ ȁǽDzǽ ȀǴDzǻǴǼȁȊ PathFigure ǻǽDzȂȁ ȀǽǰǷǿǯȁȋȀȎ DZ ǹǽǺǺǴǹȅǷǷ DZ ǿǯǻǹǯȄ PathGeometry dzǺȎ ȀǽǶdzǯǼǷȎ ȀǺǽǵǼǽDzǽ Ǽǯ ǰǽǿǯ ȀǴDzǻǴǼȁǽDZ ǓǯǺǴǴ ǾǿǷDZǴdzǴǼ ǾǿǷǻǴǿ PathGeometry DZ ȀǽȀȁǯDZ ǹǽȁǽǿǽDzǽ DZȄǽdzȎȁ dzDZǯ ǽǰȉǴǹȁǯ PathFigure ǞǴǿDZȊǸ ǽǰȉ Ǵǹȁ ȀǽdzǴǿǵǷȁ LineSegment, PolyQuadraticBezierSegment Ƿ ǴȈǴ ǽdzǷǼ LineSegment ǑȁǽǿǽǸ ǽǰȉǴǹȁ DZǹǺȍȆǯ Ǵȁ ȁǽǺȋǹǽ ǽdzǷǼ LineSegment.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǽǰȉǴǹȁǯ GeometryGroup Ǒ ǾǿǴdzȊdzȂȈǷȄ ǿǯǶdzǴǺǯȄ ǰȊǺǷ ǾǿǴdzȀȁǯDZǺǴǼȊ DZȀǴDZǽǶǻǽǵǼȊǴ DzǴǽǻǴȁǿǷȆǴȀǹǷǴ ȌǺǴǻǴǼȁȊ ǼǯȆǷǼǯȎ ǽȁ Ȁǯ ǻȊȄ ǾǿǽȀȁȊȄ ȁǯǹǷȄ ǹǯǹ EllipseGeometry, LineGeometry Ƿ RectangleGeometry, dzǽ ȀǺǽǵǼȊȄ ǽǰǿǯǶǽDZǯǼǼȊȄ ǻǼǽǵǴȀȁDZǽǻ ǽǰȉǴǹȁǽDZ PathSegment DZ ǿǯǻǹǯȄ PathGeometry ǝǰȉǴǹȁ GeometryGroup ǒǿȂǾǾǯ DzǴǽǻǴȁǿǷ ȆǴȀǹǷȄ ȌǺǴǻǴǼȁǽDZ ǾǽǶDZǽǺȎǴȁ ǹǽǻǰǷǼǷǿǽDZǯȁȋ DZȀǴ ȌȁǷ ǽǰȉǴǹȁȊ
ǒǺǯDZǯ ǝȀǼǽDZȊ ;$0/
93
ǑȊ ǾǿǽȀȁǽ ǽǾǷȀȊDZǯǴȁǴ DzǴǽǻǴȁǿǷȆǴȀǹǷǴ ȌǺǴǻǴǼȁȊ ǹǽȁǽǿȊǴ ȄǽȁǷȁǴ DZǹǺȍȆǷȁȋ ǹǯǹ ǹǽǺǺǴǹȅǷȍ DZ Ȍȁǽȁ ǽǰȉ Ǵǹȁ ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǽǰȉǴǹȁ GeometryGroup ȀǽdzǴǿǵǯȈǷǸ EllipseGeometry, RectangleGeometry Ƿ ǶǯȁǴǻ ȁǽȁ ǵǴ ȀǺǽǵǼȊǸ PathGeometry ǹǽȁǽǿȊǸ ǷȀǾǽǺȋǶǽDZǯǺȀȎ DZ ǾǿǴdzȊdzȂȈǴǻ ǿǯǶdzǴǺǴ
ǟǷȀ. 4-24 ǾǿǴdzȀȁǯDZǺȎǴȁ ǹǯǹ Ȍȁǽ ǰȂdzǴȁ DZȊDzǺȎdzǴȁȋ.
ǟǗǠ 24 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǽǰȉǴǹȁǯ GeometryGroup dzǺȎ DzǿȂǾǾǷǿǽDZǹǷ ǻǼǽǵǴȀȁDZǯ DzǴǽǻǴȁǿǷȆǴȀǹǷȄ ȌǺǴǻǴǼȁǽDZ.
ǮǶȊǹ ǽǾǷȀǯǼǷȎ ǹǽǼȁȂǿǽDZ ǝǰȉǴǹȁ Path ǷǻǴǴȁ ȀDZǽǸȀȁDZǽ Data ǓǯǼǼȊǴ DZ ǹǽȁǽǿǽǻ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ȎǶȊǹ ǽǾǷȀǯǼǷȎ ǹǽǼȁȂǿǽDZ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ ȀǺǽǵǼȊȄ ǹǽǼȁȂǿǽDZ Ǒ Ȍȁǽǻ ȎǶȊǹǴ ǷȀǾǽǺȋǶȂǴȁȀȎ ȀǺǴdzȂȍȈǷǸ ȀǷǼȁǯǹȀǷȀ ǰȂǹDZǯ ǹǽǻǯǼdzȊ Ƕǯ ǼǴǸ ȆǴǿǴǶ ǾǿǽǰǴǺ ȀǺǴdzȂǴȁ ȀǾǷȀǽǹ ǿǯǶdzǴǺǴǼǼȊȄ ǶǯǾȎȁȊǻǷ ȆǷȀǴǺ Ƕǯ ǹǽȁǽǿȊǻ ȆǴǿǴǶ ǾǿǽǰǴǺ ǷdzǴȁ ȀǺǴ dzȂȍȈǯȎ ǰȂǹDZǯ ǹǽǻǯǼdzȊ Ǒǽȁ ǾǿǷǻǴǿ
x
Ǒ Ȍȁǽǻ ȌǹǶǴǻǾǺȎǿǴ ǹǽǼȁȂǿ ǽȁǿǷȀǽDZȊDZǯǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ ǹǽǻǯǼdzȊ M ǽǰǽǶǼǯȆǯȍȈǴǸ Move ǞǴǿǴǸȁǷ dzǺȎ ǾǴǿǴȄǽdzǯ DZ ȁǽȆǹȂ (100,100) Ƿ ǹǽǻǯǼdzȊ L ǽǰǽǶǼǯȆǯȍȈǴǸ Line dzǺȎ ǾǽȀȁǿǽǴǼǷȎ ǾǿȎǻǽǸ ǺǷǼǷǷ dzǽ ȁǽȆǹǷ (200,200). ǬȁǷ ǹǽǻǯǼdzȊ ǻǽDzȂȁ ǰȊȁȋ ǶǯdzǯǼȊ ǺǷǰǽ ǾǿǽǾǷȀǼȊǻǷ ǰȂǹDZǯǻǷ ǼǯǾǿǷǻǴǿ M Ȇȁǽ ȀDZǷdzǴȁǴǺȋȀȁDZȂǴȁ ǽ ǾǿǷǻǴǼǴǼǷǷ ǯǰȀǽǺȍȁǼȊȄ ǹǽǽǿdzǷǼǯȁ ǷǺǷ ȀȁǿǽȆǼȊǻǷ ǰȂǹDZǯǻǷ ǼǯǾǿǷǻǴǿ m Ȇȁǽ ǽǾǿǴdzǴǺȎǴȁ ǽȁǼǽȀǷȁǴǺȋǼȊǴ ǹǽǽǿdzǷǼǯȁȊ ǙǽǻǯǼdzǯ M ǾǽǻǴȈǯǴȁ ǾǴǿǽ DZ ǶǯdzǯǼǼȂȍ ȁǽȆǹȂ ǰǴǶ ǽȁǿǷȀǽDZ
94
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǹǷ ǺǷǼǷǷ ǻǴǵdzȂ ȁǽȆǹǽǸ DZ ǹǽȁǽǿǽǸ ǽǼ ǼǯȄǽdzǷȁȀȎ DZ ǼǯȀȁǽȎȈǷǸ ǻǽǻǴǼȁ Ƿ ǶǯdzǯǼǼǽǸ ȁǽȆǹǽǸ ȁǴ ǾǴǿǽ ǾǴǿǴǻǴȈǯǴȁȀȎ DZ ǼǯȆǯǺȋǼȂȍ ȁǽȆǹȂ ǖǯȁǴǻ ǰȂdzǴȁ ǾǿǽDZǴdzǴǼǯ ǺǷǼǷȎ ǷǶ ȁǽȆǹǷ (100,100) DZ ȁǽȆǹȂ (200,200) ǾǿǷ ȂȀǺǽDZǷǷ ǽȁȀȂȁȀȁDZǷȎ ǾǽǶǷȅǷǽǼǷǿǽDZǯǼǷȎ ǿǽdzǷȁǴǺȋȀǹǽDzǽ ȄǽǺȀȁǯ ǔȀǺǷ ǿǽdzǷȁǴǺȋȀǹǷǸ ȄǽǺȀȁ ǾǽǶǷȅǷǽǼǷǿǽDZǯǼ Silverlight ǽȁǿǷȀȂǴȁ ǺǷǼǷȍ ǽȁǼǽȀǷȁǴǺȋǼǽ ǴDzǽ ǾǽǺǽǵǴǼǷȎ x
ǙǽǻǯǼdzǯ L (ǽǶǼǯȆǯȍȈǯȎ Line) ǽǰǴȀǾǴȆǷDZǯǴȁ ǾǽȀȁǿǽǴǼǷǴ ǾǿȎǻǽǸ ǺǷǼǷǷ ǽȁ ȁǴǹȂȈǴǸ ȁǽȆǹǷ DZ ǶǯdzǯǼ ǼȂȍ.
x
ǙǽǻǯǼdzǯ H ǾǿǷǼǷǻǯǴȁ DZ ǹǯȆǴȀȁDZǴ ǾǯǿǯǻǴȁǿǯ ȁǽǺȋǹǽ ǽdzǼǽ ȆǷȀǺǽ Ƿ ǽȁǿǷȀǽDZȊDZǯǴȁ DzǽǿǷǶǽǼȁǯǺȋǼȂȍ ǾǿȎǻȂȍ ǻǴǵdzȂ ȁǴǹȂȈǴǸ ȁǽȆǹǽǸ Ƿ ǶǯdzǯǼǼȊǻ ǶǼǯȆǴǼǷǴǻ Ǿǽ ǽȀǷ Ȅ.
x
ǙǽǻǯǼdzǯ V ǾǿǷǼǷǻǯǴȁ DZ ǹǯȆǴȀȁDZǴ ǾǯǿǯǻǴȁǿǯ ȁǽǺȋǹǽ ǽdzǼǽ ȆǷȀǺǽ Ƿ ǽȁǿǷȀǽDZȊDZǯǴȁ DZǴǿȁǷǹǯǺȋǼȂȍ ǾǿȎ ǻȂȍ ǻǴǵdzȂ ȁǴǹȂȈǴǸ ȁǽȆǹǽǸ Ƿ ǶǯdzǯǼǼȊǻ ǶǼǯȆǴǼǷǴǻ Ǿǽ ǽȀǷ Ȃ.
x
ǙǽǻǯǼdzǯ C ǾǿǷǼǷǻǯǴȁ DZ ǹǯȆǴȀȁDZǴ ǾǯǿǯǻǴȁǿǽDZ ȁǿǷ ȁǽȆǹǷ. ǝǼǯ ǽǰǴȀǾǴȆǷDZǯǴȁ ǾǽȀȁǿǽǴǼǷǴ ǹȂǰǷȆǴȀǹǽǸ ǹǿǷDZǽǸ ǐǴǶȋǴ ǻǴǵdzȂ ȁǴǹȂȈǴǸ ȁǽȆǹǽǸ Ƿ ȁǿǴȁȋǴǸ ǷǶ ǶǯdzǯǼǼȊȄ ȁǽȆǴǹ ǓDZǴ ǾǴǿDZȊǴ ȁǽȆǹǷ ǷȀǾǽǺȋǶȂȍȁȀȎ ǹǯǹ ǽǾǽǿǼȊǴ.
x
ǙǽǻǯǼdzǯ Q ǾǿǷǼǷǻǯǴȁ DZ ǹǯȆǴȀȁDZǴ ǾǯǿǯǻǴȁǿǽDZ dzDZǴ ȁǽȆǹǷ Ƿ ǽȁǿǷȀǽDZȊDZǯǴȁ ǹDZǯdzǿǯȁǷȆǴȀǹȂȍ ǹǿǷDZȂȍ ǐǴǶȋǴ ǻǴǵdzȂ ȁǴǹȂȈǴǸ ȁǽȆǹǽǸ Ƿ DZȁǽǿǽǸ ǷǶ ǶǯdzǯǼǼȊȄ ȁǽȆǴǹ. ǞǴǿDZǯȎ ǶǯdzǯǼǼǯȎ ȁǽȆǹǯ ǷȀǾǽǺȋǶȂǴȁȀȎ ǹǯǹ ǽǾǽǿǼǯȎ.
x
ǙǽǻǯǼdzǯ S ǾǿǷǼǷǻǯǴȁ DZ ǹǯȆǴȀȁDZǴ ǾǯǿǯǻǴȁǿǽDZ dzDZǴ ȁǽȆǹǷ Ƿ ǽȁǿǷȀǽDZȊDZǯǴȁ ȀDzǺǯǵǴǼǼȂȍ ǹȂǰǷȆǴȀǹȂȍ ǹǿǷDZȂȍ ǐǴǶȋǴ ǻǴǵdzȂ ȁǴǹȂȈǴǸ ȁǽȆǹǽǸ Ƿ DZȁǽǿǽǸ ǷǶ ǶǯdzǯǼǼȊȄ ȁǽȆǴǹ. ǓǺȎ ȃǽǿǻǷǿǽDZǯǼǷȎ ȀDzǺǯǵǴǼǼǽǸ ǹǿǷDZǽǸ ǷȀǾǽǺȋǶȂǴȁȀȎ dzDZǴ ǽǾǽǿǼȊǴ ȁǽȆǹǷ: ȁǴǹȂȈǯȎ ȁǽȆǹǯ Ƿ ǾǴǿDZȊǸ ǷǶ dzDZȂȄ ǾǯǿǯǻǴȁǿǽDZ.
x
ǙǽǻǯǼdzǯ T dzǴǸȀȁDZȂǴȁ ǯǼǯǺǽDzǷȆǼǽ ǹǽǻǯǼdzǴ S, Ƕǯ ǷȀǹǺȍȆǴǼǷǴǻ ȁǽDzǽ Ȇȁǽ ǽǼǯ ǽǰǴȀǾǴȆǷDZǯǴȁ ǾǽȀȁǿǽǴ ǼǷǴ ȀDzǺǯǵǴǼǼǽǸ ǹDZǯdzǿǯȁǷȆǴȀǹǽǸ ǹǿǷDZǽǸ ǐǴǶȋǴ.
x
ǙǽǻǯǼdzǯ A ǾǿǷǼǷǻǯǴȁ ǾȎȁȋ ǾǯǿǯǻǴȁǿǽDZ: ǿǯǶǻǴǿ, ȂDzǽǺ ǾǽDZǽǿǽȁǯ isLargeArc, sweepDirection Ƿ ǹǽǼǴȆ ǼȂȍ ȁǽȆǹȂ. ǬȁǷ ǾǯǿǯǻǴȁǿȊ ǷȀǾǽǺȋǶȂȍȁȀȎ dzǺȎ ǾǽȀȁǿǽǴǼǷȎ ȌǺǺǷǾȁǷȆǴȀǹǽǸ dzȂDzǷ.
x
ǙǽǻǯǼdzǯ Z ǶǯDZǴǿȇǯǴȁ ȁǴǹȂȈǷǸ ǹǽǼȁȂǿ ǾǿǽDZǽdzȎ ǾǿȎǻȂȍ ǺǷǼǷȍ ǻǴǵdzȂ ȁǴǹȂȈǴǸ ȁǽȆǹǽǸ Ƿ ǼǯȆǯǺȋǼǽǸ ȁǽȆǹǽǸ ǹǽǼȁȂǿǯ Ƿ ǽǰǿǯǶȂȎ ǶǯǻǹǼȂȁȂȍ ȃǷDzȂǿȂ.
ǑȊǿǴǶǯǼǷǴ Ƿ DzǴǽǻǴȁǿǷȆǴȀǹǷǴ ȌǺǴǻǴǼȁȊ DZ XAML ǬǺǴǻǴǼȁȊ XAML ǻǽDzȂȁ ǰȊȁȋ DZȊǿǴǶǯǼȊ Ǿǽ ǾǿǯDZǷǺȂ ǽǾǿǴdzǴǺȎǴǻǽǻȂ ȁǷǾǽǻ DzǴǽǻǴȁǿǷȆǴȀǹǽǸ ȃǽǿǻȊ Ǚǯǹ ǰȊǺǽ ǾǽǹǯǶǯǼǽ DZ ǾǿǴdzȊdzȂȈǴǻ ǿǯǶdzǴǺǴ ȌȁǷ ȁǷǾȊ ǻǽDzȂȁ ǰȊȁȋ ǾǿǽȀȁȊǻǷ EllipseGeometry, LineGeometry ǷǺǷ RectangleGeometry ȀǺǽǵǼȊǻǷ ǷȀǾǽǺȋǶȂȍȈǷǻǷ DzǴǽǻǴȁǿǷȆǴȀǹȂȍ ȃǽǿǻȂ ǽǾǿǴdzǴǺǴǼǼȂȍ ǽǰȉǴǹȁǽǻ PathGeometry ǷǺǷ DzǿȂǾǾǽǸ ǷǶ ȌȁǷȄ ǽǰȉǴǹȁǽDZ DZ ȀǽȀȁǯDZǴ GeometryCollection. ǦȁǽǰȊ ǽǾǿǴdzǴǺǷȁȋ ǻǴȁǽdz DZȊǿǴǶǯǼǷȎ ǽǰȉǴǹȁǯ ǴDzǽ ǾǿǷȀǽǴdzǷǼǴǼǼǽǻȂ ȀDZǽǸȀȁDZȂ Clip ǾǿǽȀȁǽ ǶǯdzǯǴȁȀȎ ȁǷǾ DzǴǽǻǴȁǿǷȆǴȀǹǽǸ ȃǽǿǻȊ ǠǺǴdzȂȍȈǷǸ ǾǿǷǻǴǿ ǾǿǴdzȀȁǯDZǺȎǴȁ ǷǶǽǰǿǯǵǴǼǷǴ DZȊǿǴǶǯǼǼǽǴ EllipseGeometry:
ǢDZǷdzǴȁȋ ǹǯǹ Ȍȁǽ DZȊDzǺȎdzǷȁ ǻǽǵǼǽ Ǽǯ ǿǷȀ 4-25.
ǒǺǯDZǯ ǝȀǼǽDZȊ ;$0/
95
ǟǗǠ 25 ǑȊǿǴǶǯǼǷǴ ǽǰȉǴǹȁǯ DzǴǽǻǴȁǿǷȆǴȀǹǽǸ ȃǽǿǻǽǸ.
ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ XAML DZ Silverlight ǟǯǶǿǯǰǽȁȆǷǹǯǻ Ǽǯ Silverlight dzǽȀȁȂǾǴǼ ǿȎdz ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ XAML Ǚ ǼǷǻ ǽȁǼǽȀȎȁȀȎ x
Canvas
x
Image
x
Glyphs
x
TextBlock
x
MediaElement
Ǚǽ DZȀǴǻ ȌȁǷǻ ȌǺǴǻǴǼȁǯǻ ǻǽDzȂȁ ǾǿǷǻǴǼȎȁȋȀȎ DZȀǴ ȀDZǽǸȀȁDZǯ Ƿ ǽǾǴǿǯȅǷǷ ǽǰȀȂǵdzǯǴǻȊǴ DZ dzǯǼǼǽǸ DzǺǯDZǴ DZȊȇǴ ȁǯǹǷǴ ǹǯǹ DZȊǿǴǶǯǼǷǴ ǹǷȀȁǷ ǹǽǻǾǽǼǽDZǹǯ Ƿ Ǿǿ ǞǴǿDZȊǴ ȆǴȁȊǿǴ ȌǺǴǻǴǼȁǯ ǰȂdzȂȁ ǿǯȀȀǻǽȁǿǴǼȊ DZ ȀǺǴdzȂȍȈǷȄ ǾǽdzǿǯǶdzǴǺǯȄ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ MediaElement ǾǽdzǿǽǰǼǽ ǿǯȀȀǻǯȁǿǷDZǯǴȁȀȎ DZ ǒǺǯDZǴ 11.
ǬǺǴǻǴǼȁ Canvas Ǭȁǽȁ ȌǺǴǻǴǼȁ ǽǾǿǴdzǴǺȎǴȁ ǽǰǺǯȀȁȋ ȀȁǿǯǼǷȅȊ DZ ǹǽȁǽǿȂȍ ǻǽDzȂȁ ǰȊȁȋ ǾǽǻǴȈǴǼȊ dzǽȆǴǿǼǷǴ ȌǺǴǻǴǼȁȊ ǝǼ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ DZǷǶȂǯǺȋǼǽǸ DzǿȂǾǾǷǿǽDZǹǷ ȌǺǴǻǴǼȁǽDZ ǾǿǷ Ȍȁǽǻ ǷȄ ǹǽǻǾǽǼǽDZǹǯ Ƿ ǾǽǶǷȅǷǽǼǷ ǿǽDZǯǼǷǴ DZȊǾǽǺǼȎȍȁȀȎ ǽȁǼǽȀǷȁǴǺȋǼǽ ǼǴDzǽ ǙǿǽǻǴ ȁǽDzǽ ǽǰȉǴǹȁ Canvas ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ǷȀǹǺȍȆǷ ȁǴǺȋǼǽ ǹǯǹ ǹǽǼȁǴǸǼǴǿ dzǺȎ dzǿȂDzǷȄ ǽǰȉǴǹȁǽDZ ǽǰǴȀǾǴȆǷDZǯȎ DZǽǶǻǽǵǼǽȀȁȋ ǿǯȀȀǻǯȁǿǷDZǯȁȋ ǷȄ ǹǯǹ ǴdzǷǼȊǸ ǽǰȉǴǹȁ ǾǿǷ ǿǯǶǻǴȈǴǼǷǷ Ƿ ǽǰǿǯǰǽȁǹǴ ȀǽǰȊȁǷǸ Ǒǽȁ ǾǿǷǻǴǿ ǽǿDzǯǼǷǶǯȅǷǷ ǾǿȎǻǽȂDzǽǺȋǼǷǹǽDZ DZ DzǿȂǾǾȊ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ȌǺǴǻǴǼȁǽDZ Canvas:
96
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǬǺǴǻǴǼȁ Image ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Image ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ DzǿǯȃǷȆǴȀǹǽDzǽ ǽǰȉǴǹȁǯ ǝǼ ǶǯdzǯǴȁȀȎ ǢǼǷDZǴǿ ȀǯǺȋǼȊǻ ǷdzǴǼȁǷȃǷǹǯȁǽǿǽǻ ǿǴȀȂǿȀǯ URI ǷǶǽǰǿǯǵǴǼǷȎ ǹǽȁǽǿǽǴ ǻǽǵǴȁ ǰȊȁȋ ǿǯȀȁǿǽDZȊǻ DZ ȃǽǿǻǯȁǴ .jpg ǷǺǷ .png. ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ, DZ ǹǽȁǽǿǽǻ ǹǽǻǾǽǼǽDZǹǯ ǷǶǽǰǿǯǵǴǼǷȎ ǶǯdzǯǼǯ ȀDZǽǸȀȁDZǯǻǷ Height, Width, Canvas.Left Ƿ Canvas.Top Ƿ DZ ǹǯȆǴȀȁDZǴ Source ǗȀȁǽȆǼǷǹ ǷǶǽǰǿǯǵǴǼǷȎ ǶǯdzǯǼ ´smily.jpgµ
ǬǺǴǻǴǼȁ Glyphs ǬǺǴǻǴǼȁ Glyphs ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǽȁǽǰǿǯǵǴǼǷȎ ȁǴǹȀȁǯ Ȁ ǶǯdzǯǼǼȊǻ ȇǿǷȃȁǽǻ ǡǯǹǵǴ ǽǼ ǻǽǵǴȁ ǾǿǷǻǴ ǼȎȁȋȀȎ dzǺȎ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ȀǷǻDZǽǺǽDZ ǼǴ ȀDZȎǶǯǼǼȊȄ Ȁ ǹǽǼǹǿǴȁǼȊǻǷ ǹǺǯDZǷȇǯǻǷ ǹǯǹǽDZȊǻǷ ȎDZǺȎȍȁȀȎ ǻǼǽDzǷǴ DzǿǯȃǷȆǴȀǹǷǴ ȀǷǻDZǽǺȊ ǷȀǾǽǺȋǶȂǴǻȊǴ DZ ȇǿǷȃȁǯȄ DZǹǺȍȆǯȎ ȁǴǹȀȁ Wingdings ǷǺǷ Unicode. ǞǿǷ ǷȀǾǽǺȋǶǽDZǯǼǷǷ Glyphs ǼǴǽǰȄǽdzǷǻǽ ȀǽǰǺȍdzǯȁȋ ǾǿǯDZǷǺǽ ȆȁǽǰȊ ȇǿǷȃȁ ǻǽDz ǽȁǽǰǿǯǵǯȁȋȀȎ ǽǼ dzǽǺ ǵǴǼ ǰȊȁȋ ȂȀȁǯǼǽDZǺǴǼ Ǽǯ dzǯǼǼǽǻ ǹǽǻǾȋȍȁǴǿǴ ǡǯǹǷǻ ǽǰǿǯǶǽǻ Ȁ Glyphs ǻǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ ȁǽǺȋǹǽ ȁǴ ȇǿǷȃȁȊ ǾǿǯDZǯǻǷ Ǽǯ ǿǯȀǾǿǽȀȁǿǯǼǴǼǷǴ ǹǽȁǽǿȊȄ DZȊ ǽǰǺǯdzǯǴȁǴ ǧǿǷȃȁ dzǺȎ ȌǺǴǻǴǼȁǯ Glyphs ǶǯdzǯǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ FontUri (Uri ȇǿǷȃȁǯ ǖǯȁǴǻ ȀDZǽǸȀȁDZǯǻǷ Indices ǗǼdzǴǹȀȊ ǷǺǷ UnicodeString Ǡȁǿǽǹǯ Unicode ǶǯdzǯȍȁȀȎ ȀǷǻDZǽǺȊ ǾǿǽǿǷȀǽDZǹȂ ǹǽȁǽǿȊȄ ǼȂǵǼǽ ȀǽǶdzǯȁȋ Ǒ ȀDZǽǸȀȁDZǴ Indices dzǺȎ ǽǾǷȀǯǼǷȎ ȀǷǻDZǽǺǽDZ ǷȀǾǽǺȋǶȂȍȁȀȎ ǷȄ ȀǻǴȈǴǼǷȎ DZ ǽǾǷȀǯǼǷǷ ȇǿǷȃȁǯ ǠǻǴȈǴǼǷȎ Ƕǯ dzǯȍȁȀȎ DZ DZǷdzǴ ȌǺǴǻǴǼȁǽDZ ȀǾǷȀǹǯ ǿǯǶdzǴǺǴǼǼȊȄ ȁǽȆǹǯǻǷ Ȁ ǶǯǾȎȁǽǸ ǙǿǽǻǴ ȁǽDzǽ, ǼǴǽǰȄǽdzǷǻǽ Ƕǯdzǯȁȋ ǿǯǶǻǴǿ ȇǿǷȃȁǯ. ǓǺȎ ȌȁǽDzǽ ǷȀǾǽǺȋǶȂǴȁȀȎ ȀDZǽǸȀȁDZǽ FontRenderingEmSize ǟǯǶǻǴǿ ǰȂǹDZȊ M ȃǽǿǻǷǿȂǴǻǽDzǽ ȇǿǷȃȁǯ . Ǟǽ ǵǴǺǯǼǷȍ ǻǽǵǼǽ Ƕǯdzǯȁȋ ȀDZǽǸȀȁDZǽ StyleSimulations ǗǻǷȁǯ ȅǷȎ ȀȁǷǺǴǸ dzǺȎ ǷǻǷȁǯȅǷǷ ȀȁǷǺǴǸ ȇǿǷȃȁǽDZ. Ǭȁǽ ȀDZǽǸȀȁDZǽ ǾǿǷǼǷǻǯǴȁ ǶǼǯȆǴǼǷȎ BoldSimulation (ǗǻǷȁǯȅǷȎ ǵǷǿǼǽDzǽ ȇǿǷȃȁǯ , ItalicSimulation (ǗǻǷȁǯȅǷȎ ǹȂǿȀǷDZǯ) ǷǺǷ BoldItalicSimulation ǗǻǷȁǯȅǷȎ ǵǷǿǼǽDzǽ ǹȂǿȀǷ DZǯ , ǯ ȁǯǹǵǴ ǶǼǯȆǴǼǷǴ Ǿǽ ȂǻǽǺȆǯǼǷȍ, None. ǓǯǺǴǴ ǾǿǷDZǽdzǷȁȀȎ ǾǿǷǻǴǿ ȌǺǴǻǴǼȁǯ Glyphs Ǒ ǼǴǻ dzǺȎ ǽȁǿǷȀǽDZǹǷ ǼǴǹǽȁǽǿȊȄ ȀǷǻDZǽǺǽDZ ǷȀǾǽǺȋǶȂǴȁȀȎ ȇǿǷȃȁ Webdings Ƿ ȀǻǴȈǴǼǷȎ ȀǷǻDZǽǺǽDZ ǞǿǷǻǴȆǯǼǷǴ
ǓǺȎ DZȊǾǽǺǼǴǼǷȎ dzǯǼǼǽDzǽ ǾǿǷǺǽǵǴǼǷȎ ǼǴǽǰȄǽdzǷǻǽ, ȆȁǽǰȊ ȃǯǸǺ ȇǿǷȃȁǯ webdings.ttf ǿǯȀǾǽ ǺǯDzǯǺȀȎ Ǽǯ DZǯȇǴǻ ȀǴǿDZǴǿǴ DZ ǽdzǼǽǻ ǹǯȁǯǺǽDzǴ Ȁ ǾǿǷǺǽǵǴǼǷǴǻ Silverlight. ǔȀǺǷ Ȍȁǽȁ ȇǿǷȃȁ ǼǴdzǽȀȁȂǾǴǼ ǾǿǽȀȁǽ ǶǯǻǴǼǷȁǴ ǴDzǽ dzǿȂDzǷǻ ǷǻǴȍȈǷǻȀȎ DZ ǼǯǺǷȆǷǷ ǹǽȁǽǿȊǸ ǻǽǵǴȁ ȃǽǿǻǷǿǽDZǯȁȋ ǾǿǽǿǷȀǽDZǹȂ ǶǯdzǯǼǼȊȄ ȀǷǻDZǽǺǽDZ ǑǯǵǼǽ ǾǽǻǼǷȁȋ, Ȇȁǽ ǾǿǷ ǷȀǾǽǺȋǶǽDZǯǼǷǷ ȌȁǽǸ ȁǴȄǼǷǹǷ DZ ǿǯǰǽȆǴǸ ȀǿǴdzǴ, ǼǴǽǰȄǽdzǷǻǽ ǷǻǴȁȋ ǿǯǶǿǴȇǴǼǷǴ Ǽǯ ǿǯȀǾǿǽȀȁǿǯǼǴǼǷǴ ǷȀǾǽǺȋǶȂǴǻȊȄ ȇǿǷȃȁǽDZ.
Ǚǯǹ Ȍȁǽ ǰȂdzǴȁ ǾǿǴdzȀȁǯDZǺǴǼǽ DZ Silverlight ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 4-26.
ǒǺǯDZǯ ǝȀǼǽDZȊ ;$0/
97
ǟǗǠ. 4 26 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǽǰȉǴǹȁǯ Glyphs.
ǬǺǴǻǴǼȁ TextBlock Ǭȁǽ ǽǰǺǴDzȆǴǼǼȊǸ ǽǰȉǴǹȁ ǽǰǴȀǾǴȆǷDZǯȍȈǷǸ ǽȁǽǰǿǯǵǴǼǷǴ ǽdzǼǽǸ ǷǺǷ ǻǼǽǵǴȀȁDZǯ Ȁȁǿǽǹ ȁǴǹȀȁǯ ǷǻǴȍȈǷǸ ǻǼǽǵǴȀȁDZǽ ǽǾȅǷǸ ȃǽǿǻǯȁǷǿǽDZǯǼǷȎ ǝǼ ȀȂȈǴȀȁDZǴǼǼǽ ǽȁǺǷȆǯǴȁȀȎ ǽȁ ȌǺǴǻǴǼȁǯ Glyphs ȁǴǻ Ȇȁǽ ǼǴ ȁǿǴǰȂǴȁ ǶǯdzǯǼǷȎ ȇǿǷȃȁǯ ǡǯǹǷǻ ǽǰǿǯǶǽǻ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ȁǴǹȀȁǯ ǰȂdzǴȁ ǽdzǷǼǯǹǽDZȊǻ ǼǴǶǯDZǷȀǷǻǽ ǽȁ ǷȀǾǽǺȋǶȂǴ ǻǽǸ ǽǾǴǿǯȅǷǽǼǼǽǸ ȀǷȀȁǴǻȊ ǷǺǷ ǰǿǯȂǶǴǿǯ Ǡ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ FontFamily ǠǴǻǴǸȀȁDZǽ ȇǿǷȃȁǽDZ ǶǯdzǯǴȁȀȎ ȀǴǻǴǸȀȁDZǽ ȇǿǷȃȁǽDZ ǹǽȁǽǿǽǴ dzǽǺǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ȃǽǿǻǷǿǽDZǯǼǷȎ DZǷǶȂǯǺȋǼǽDzǽ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ȁǴǹȀȁǯ Silverlight 2 DZ ǽȁǺǷȆǷǴ ǽȁ Silverlight 1.0, ǾǽdzdzǴǿǵǷDZǯǴȁ DZȀǴ ȇǿǷȃȁȊ ȂȀȁǯǼǽDZǺǴǼǼȊǴ DZ ǽǾǴǿǯȅǷǽǼǼǽǸ ȀǷȀȁǴǻǴ Ǽǽ ȀǺǴdzȂȍȈǷǴ dzǴ DZȎȁȋ ȎDZǺȎȍȁȀȎ DZȀȁǿǽǴǼǼȊǻǷ ȇǿǷȃȁǯǻǷ x
Arial
x
Arial Black
x
Comic Sans MS
x
Courier New
x
Georgia
x
Lucida Grande/Lucida Sans Unicode
x
Times New Roman
x
Trebuchet MS
x
Verdana
ǬȁǷ ȇǿǷȃȁȊ ȀȆǷȁǯȍȁȀȎ ©ǑǴǰ-ǰǴǶǽǾǯȀǼȊǻǷª ȁǴ DZ ȀǺȂȆǯǴ ǷȄ ǾǿǷǻǴǼǴǼǷȎ ǿǴǶȂǺȋȁǯȁȊ ǰȂdzȂȁ ǴdzǷǼǽǽǰ ǿǯǶǼȊǻǷ ǼǴǶǯDZǷȀǷǻǽ ǽȁ ǰǿǯȂǶǴǿǯ ǷǺǷ ǽǾǴǿǯȅǷǽǼǼǽǸ ȀǷȀȁǴǻȊ ǷȀǾǽǺȋǶȂǴǻǽǸ dzǺȎ ǽȁǽǰǿǯǵǴǼǷȎ ȁǴǹȀȁǯ ǔȀǺǷ DZȊ ǷȀǾǽǺȋǶȂǴȁǴ ȇǿǷȃȁȊ ǼǴ DZȄǽdzȎȈǷǴ DZ Ȍȁǽȁ Ǽǯǰǽǿ Ƿ ǼǴ DZȀȁǿǽǴǼǼȊǴ DZ ǾǿǷǺǽǵǴǼǷǴ ǰǿǯȂǶǴǿ Ǿǿǽ DZǴǿǷȁ ǷȄ ǼǯǺǷȆǷǴ DZ ȀǷȀȁǴǻǴ Ƿ ǴȀǺǷ ǼǯǸdzǴȁ ǷȄ ǰȂdzǴȁ ǷȄ ǷȀǾǽǺȋǶǽDZǯȁȋ ǔȀǺǷ ȇǿǷȃȁ ǼǴ ǰȂdzǴȁ ǼǯǸdzǴǼ Ƿ ǽǼ ǼǴ DZȀȁǿǽǴǼ DZ ǾǿǷǺǽǵǴǼǷǴ Ǿǽ ǾǿǯDZǷǺǯǻ ǶǯǻǴȈǴǼǷȎ ȇǿǷȃȁǽDZ ǷǶ ǾǿǴdzǺǯDzǯǴǻȊȄ ȀǷȀȁǴǻǼȊȄ ȇǿǷȃȁǽDZ ǰȂ dzǴȁ DZȊǰǿǯǼ ǼǯǷǰǽǺǴǴ ǾǽdzȄǽdzȎȈǷǸ ǠDZǽǸȀȁDZǽ FontSize ǟǯǶǻǴǿ ȇǿǷȃȁǯ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǶǯdzǯǼǷȎ ǿǯǶǻǴǿ ȁǴǹȀȁǯ ǹǽȁǽǿȊǸ dzǽǺǵǴǼ ǰȊȁȋ ǽȁǽǰǿǯǵǴǼ DZ ǾǷǹȀǴǺǯȄ ǠDZǽǸȀȁDZǽ FontStyle ǠȁǷǺȋ ȇǿǷȃȁǯ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ ȀȁǷǺȎ ǽȁǽ ǰǿǯǵǯǴǻǽDzǽ ȇǿǷȃȁǯ ǔǻȂ ǻǽǵǴȁ ǰȊȁȋ ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ Normal ǝǰȊȆǼȊǸ ǷǺǷ Italic ǙȂǿȀǷDZ
98
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǠDZǽǸȀȁDZǽ FontWeight (ǜǯȀȊȈǴǼǼǽȀȁȋ ȇǿǷȃȁǯ ǽǾǿǴdzǴǺȎǴȁ ǼǯȀȊȈǴǼǼǽȀȁȋ ȇǿǷȃȁǯ ǾǿǷ ǴDzǽ ǾǿǽǿǷȀǽDZǹǴ ǑǽǶǻǽǵǼȊǻǷ ǶǼǯȆǴǼǷȎǻǷ dzǯǼǼǽDzǽ ȀDZǽǸȀȁDZǯ ȎDZǺȎȍȁȀȎ Thin ǡǽǼǹǷǸ ExtraLight ǝȆǴǼȋ ȀDZǴȁǺȊǸ Light ǠDZǴȁǺȊǸ Normal, Medium ǠǿǴdzǼǷǸ SemiBold ǞǽǺȂǵǷǿǼȊǸ Bold ǕǷǿǼȊǸ ExtraBold ǝȆǴǼȋ ǵǷǿ ǼȊǸ Black ǦǴǿǼȊǸ ǷǺǷ ExtraBlack ǝȆǴǼȋ ȆǴǿǼȊǸ ǠDZǽǸȀȁDZǽ TextDecorations ǓǴǹǽǿǷǿǽDZǯǼǷǴ ȇǿǷȃȁǯ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ ȁǽDzǽ ǰȂdzǴȁ ǺǷ ȁǴǹȀȁ DZ TextBlock ǽȁǽǰǿǯǵǯȁȋȀȎ Ȁ ǾǽdzȆǴǿǹǽǻ ǬȁǽǻȂ ǶǼǯȆǴǼǷȍ ǻǽǵǴȁ ǰȊȁȋ ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ Underline Ǟǽdz ȆǴǿǹ ǷǺǷ None. ǠDZǽǸȀȁDZǽ TextWrapping ǞǴǿǴǼǽȀ ȁǴǹȀȁǯ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ ȁǽDzǽ ǰȂdzǴȁ ǺǷ TextBlock DZȊǾǽǺ ǼȎȁȋ ǾǴǿǴǼǽȀ ȁǴǹȀȁǯ ǔǻȂ ǻǽǵǴȁ ǰȊȁȋ ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ NoWrap ǐǴǶ ǾǴǿǴǼǽȀǯ ȁǯǹǷǻ ǽǰǿǯǶǽǻ ȁǴǹȀȁ ǰȂdzǴȁ DZȊDZǴdzǴǼ DZ ǽdzǼȂ ȀȁǿǽǹȂ Ƿ ǽǰǿǴǶǯǼ Ǿǽ ȇǷǿǷǼǴ TextBlock ǷǺǷ Wrap Ǡ ǾǴǿǴǼǽȀǽǻ ȁǽDzdzǯ ȁǴǹȀȁ ǰȂdzǴȁ ǾǴǿǴǼǽȀǷȁȋȀȎ Ǽǯ ǼǽDZȂȍ ȀȁǿǽǹȂ Ǿǽ dzǽȀȁǷǵǴǼǷǷ dzǽȀȁȂǾǼǽǸ ȇǷǿǷǼȊ DZ DzǽǿǷǶǽǼȁǯǺȋǼǽǻ ǼǯǾǿǯDZǺǴǼǷǷ ǠDZǽǸȀȁDZǽ ǾǴǿǴǼǽȀǯ ȁǴǹȀȁǯ ǻǽǵǴȁ DZǺǷȎȁȋ Ǽǯ ǿǯǶǻǴǿȊ ȁǴǹȀȁǽDZǽDzǽ ǾǽǺȎ Ƕǯ ȀȆǴȁ ǷǶǻǴǼǴǼǷȎ ȇǷǿǷǼȊ ȆǴǿǴǶ ǽDzǿǯǼǷȆǴǼǷǴ ȁǴǹȀȁǯ Ƿ DZȊȀǽȁȊ ȆǴǿǴǶ dzǽǰǯDZǺǴǼǷǴ dzǽǾǽǺǼǷȁǴǺȋǼȊȄ Ȁȁǿǽǹ Ǒ ǿǴǶȂǺȋȁǯȁǴ ȀȁǯǼdzǯǿȁǼȊǴ ȀDZǽǸȀȁDZǯ Width Ƿ Height ǻǽDzȂȁ DZǽǶDZǿǯȈǯȁȋ ǼǴȀǽǽȁDZǴȁȀȁDZȂȍȈǷǴ ǶǼǯȆǴǼǷȎ ǞǽȌȁǽǻȂ TextBlock ǾǿǴdzǺǯDzǯǴȁ ȀDZǽǸȀȁDZǯ ActualWidth ǣǯǹȁǷȆǴȀǹǯȎ ȇǷǿǷǼǯ Ƿ ActualHeight ǣǯǹȁǷȆǴȀǹǯȎ DZȊȀǽȁǯ ǹǽȁǽǿȊǴ DZǽǶDZǿǯȈǯȍȁ ǿǴǯǺȋǼȊǴ ǶǼǯȆǴǼǷȎ
ǢȆǯȀȁǹǷ Ƿ ǿǯǶǿȊDZȊ Ȁȁǿǽǹ ǬǺǴǻǴǼȁ Run ǢȆǯȀȁǽǹ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǷǶǻǴǼǴǼǷȎ ȃǽǿǻǯȁǷǿǽDZǯǼǷȎ ǷǺǷ ȀȁǷǺǴDZǽDzǽ ǽȃǽǿǻǺǴǼǷȎ ȁǴǹȀȁǯ DZ TextBlock ǔȀǺǷ DZ ȁǴǹȀȁǽDZǽǻ ǾǽǺǴ ǼǴǽǰȄǽdzǷǻǽ Ƕǯdzǯȁȋ ȁǿǷ ǿǯǶǼȊȄ ȀȁǷǺȎ ȁǴǹȀȁǯ ǷǺǷ ȇǿǷȃȁǯ dzǺȎ TextBlock ǶǯdzǯǴȁȀȎ ǾǴǿDZȊǸ ȀȁǷǺȋ Ƿ DZ ǹǯȆǴȀȁDZǴ ǶǼǯȆǴǼǷȎ ǴDzǽ ȀDZǽǸȀȁDZǯ Text ǶǯdzǯǴȁȀȎ ǼǴǽǰȄǽdzǷǻȊǸ ȁǴǹȀȁ ǖǯȁǴǻ dzǽ ǰǯDZǺȎǴȁȀȎ ȂȆǯȀȁǽǹ Ȁǽ DZȁǽǿȊǻ ȀȁǷǺǴǻ Ƿ ȁǴǹȀȁǽǻ Ƿ ǴȈǴ ǽdzǷǼ ȂȆǯȀȁǽǹ Ȁ ȁǿǴȁȋǷǻ ȀȁǷǺǴǻ Ƿ ȁǴǹȀȁǽǻ ǟǯȀȀǻǽȁ ǿǷǻ ǾǿǷǻǴǿ: Large Comic Sans Italic Verdana
Ǒ TextBlock ǶǯDzǿȂǵǯǴȁȀȎ ȁǴǹȀȁ ©ArialTextLarge Comic SansItalic Verdanaª ǝdzǼǯǹǽ ǾǽȀǹǽǺȋǹȂ DZ Run ǶǯdzǯǼ ȁǴǹȀȁ ©Large Comic Sansª Ȁ ǽdzǼǷǻ ȇǿǷȃȁǽǻ Ƿ ȀȁǷǺǴǻ Ƿ DZ ȀǺǴdzȂȍȈǴǻ Run ǶǯdzǯǼ ȁǴǹȀȁ ©Italic Verdanaª Ȁ ȁǿǴȁȋǷǻǷ ǾǯǿǯǻǴȁǿǯǻǷ Ǽǯ DZȊDZǽdzǴ ǰȂdzȂȁ ǾǿǴdzȀȁǯDZǺǴǼȊ DZȀǴ ǶǯdzǯǼǼȊǴ ȁǴǹȀȁȊ DZ ǽdzǼȂ ȀȁǿǽǹȂ DZ ǿǯǶǼȊȄ ȃǽǿǻǯȁǯȄ ǟǴǶȂǺȋȁǯȁȊ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 4-27.
ǒǺǯDZǯ ǝȀǼǽDZȊ ;$0/
99
ǟǗǠ 27 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǾǴǿǴȄǽdzǽDZ DZ TextBlock.
ǟǯǶǿȊDZȊ DZ ȁǴǹȀȁǴ TextBlock ǻǽǵǼǽ ȀǽǶdzǯȁȋ Ȁ ǾǽǻǽȈȋȍ ȌǺǴǻǴǼȁǯ LineBreak ǟǯǶǿȊDZ ȀȁǿǽǹǷ ǓǺȎ ȀǽǶdzǯ ǼǷȎ ǿǯǶǿȊDZǯ ȀȁǿǽǹǷ Ȍȁǽȁ ȌǺǴǻǴǼȁ ǾǿǽȀȁǽ DZȀȁǯDZǺȎǴȁȀȎ ǻǴǵdzȂ ȌǺǴǻǴǼȁǯǻǷ 5XQ Ǒǽȁ ǾǿǴdzȊdzȂȈǷǸ ǾǿǷǻǴǿ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǿǯǶǿȊDZǯ ȀȁǿǽǹǷ: Large Comic Sans Italic Verdana
ǟǷȀ 4-28 ǾǿǴdzȀȁǯDZǺȎǴȁ ǹǯǹ Ȍȁǽ ǰȂdzǴȁ DZȊDzǺȎdzǴȁȋ Ǽǯ ȌǹǿǯǼǴ. Ǚǯǹ DZǷdzǷǻ ǿǯǶǿȊDZ ȀȁǿǽǹǷ DZȊǾǽǺǼȎǴȁȀȎ ǻǴ ǵdzȂ ȀǺǽDZǯǻǷ ©Sansª Ƿ ©Italicª.
ǟǗǠ 28 ǗȀǾǽǺȋǶǽDZǯǼǷǴ LineBreak DZ TextBlock.
ǖǯǹǺȍȆǴǼǷǴ Ǒ dzǯǼǼǽǸ DzǺǯDZǴ ǾǽdzǿǽǰǼǽ ǿǯȀȀǻǽȁǿǴǼǯ ǼǯȀȁǿǽǸǹǯ DZǷǶȂǯǺȋǼȊȄ ȌǺǴǻǴǼȁǽDZ Ȁ ǾǽǻǽȈȋȍ XAML. ǞǿǴdzȀȁǯDZ ǺǴǼȊ ǹǽǻǾǽǼǽDZǹǯ ǾǽǶǷȅǷǽǼǷǿǽDZǯǼǷǴ ǶǯǺǷDZǹǯ ǽǰDZǽdzǹǷ ǾǿǽǶǿǯȆǼǽȀȁȋ ǹǽǼȁȂǿȊ DzǴǽǻǴȁǿǷȆǴȀǹǷǴ ȌǺǴ ǻǴǼȁȊ Ƿ DZȊǿǴǶǯǼǷǴ ² DZȀǴ ȁǴ DZǽǶǻǽǵǼǽȀȁǷ ǹǽȁǽǿȊǴ ǾǽǶDZǽǺȎȍȁ ȂǾǿǯDZǺȎȁȋ ȁǴǻ Ȇȁǽ DZȊ DZǷdzǷȁǴ DZ ȀDZǽǴǻ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǽǻ ǷǼȁǴǿȃǴǸȀǴ ǙǿǽǻǴ ȁǽDzǽ DZȊ ǾǽǶǼǯǹǽǻǷǺǷȀȋ Ȁ ȂǼǷDZǴǿȀǯǺȋǼȊǻǷ ȌǺǴǻǴǼȁǯǻǷ ȂǾǿǯDZ ǺǴǼǷȎ ȎDZǺȎȍȈǷǻǷȀȎ ǹǽǼȁǴǸǼǴǿǯǻǷ dzǺȎ dzǿȂDzǷȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ Ƿ ȁǯǹǵǴ ǷȀǾǽǺȋǶȂǴǻȊǻǷ dzǺȎ ǽȁǽǰǿǯǵǴǼǷȎ ȁǴǹȀȁǯ ǠǺǴdzȂȍȈǯȎ DzǺǯDZǯ ǰȂdzǴȁ ǾǽȀDZȎȈǴǼǯ ǷȀǾǽǺȋǶǽDZǯǼǷȍ XAML dzǺȎ ǽǵǷDZǺǴǼǷȎ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǽDzǽ ǷǼȁǴǿ ȃǴǸȀǯ ȆǴǿǴǶ DZDZǴdzǴǼǷǴ ȁǿǯǼȀȃǽǿǻǯȅǷǸ Ƿ ǯǼǷǻǯȅǷǷ!
ǒǺǯDZǯ 5
ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷǻǯȅǷȎ DZ XAML Ǒ ǒǺǯDZǴ ©ǝȀǼǽDZȊ XAMLª DZȊ ǼǯȂȆǷǺǷȀȋ Ȁ ǾǽǻǽȈȋȍ XAML ȃǽǿǻǷǿǽDZǯȁȋ DZǷǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ DzǿǯȃǷȆǴȀǹǷȄ ȌǺǴǻǴǼȁǽDZ Ǽǯ ȌǹǿǯǼǴ ǰȂdzȋ ȁǽ DZǴǹȁǽǿǼǯȎ DzǿǯȃǷǹǯ ǿǯȀȁǿǽDZȊǴ ǷǶǽǰǿǯǵǴǼǷȎ Ȁ ǾǽǻǽȈȋȍ ǽǰȉǴǹȁǯ Image ǷǺǷ DZǷdzǴǽ Ǒ dzǯǼǼǽǸ DzǺǯDZǴ ǰȂdzǴȁ ǿǯȀȀǻǽȁǿǴǼǽ ǹǯǹ ȂǺȂȆȇǷȁȋ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ȌȁǷȄ DzǿǯȃǷ ȆǴȀǹǷȄ ȌǺǴǻǴǼȁǽDZ Ȁ ǾǽǻǽȈȋȍ ǿǯǶǺǷȆǼȊȄ ȁǷǾǽDZ ȁǿǯǼȀȃǽǿǻǯȅǷǸ dzǺȎ ǷǶǻǴǼǴǼǷȎ ǷȄ DZǷdzǯ Ƿ ǯǼǷǻǯȅǷǷ dzǺȎ ǷǶǻǴǼǴǼǷȎ ǯȁǿǷǰȂȁǽDZ ǽǰȉǴǹȁǯ DZǽ DZǿǴǻǴǼǷ ǙǿǽǻǴ ȁǽDzǽ ǰȂdzǴȁ ǾǿǴdzȀȁǯDZǺǴǼǯ ǯǼǷǻǯȅǷȎ Ǿǽ ǹǺȍȆǴ DZȊǻ ǹǯdzǿǯǻ Ƿ ǽǾǷȀǯǼǽ ǷȄ ǷȀǾǽǺȋǶǽDZǯǼǷǴ ǾǿǷ ȀǽǶdzǯǼǷǷ ǰǽǺǴǴ ȀǺǽǵǼǽDzǽ ǾǽDZǴdzǴǼǷȎ Ǒ ǶǯDZǴǿȇǴǼǷǴ ǻȊ ǽǾȎȁȋ ǼǴǼǯdzǽǺDzǽ DZǴǿǼǴǻȀȎ ǹ Expression Blend Ƿ ǾǽǹǯǵǴǻ ǹǯǹ ǴDzǽ ǻǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ dzǺȎ ȀǽǶdzǯǼǷȎ ǯǼǷǻǯȅǷǷ
ǡǿǯǼȀȃǽǿǻǯȅǷǷ Ǒ DzǿǯȃǷǹǴ ȁǿǯǼȀȃǽǿǻǯȅǷȎ ǽǾǿǴdzǴǺȎǴȁ ǹǯǹ ȁǽȆǹǷ ǷǶ ǽdzǼǽDzǽ ǹǽǽǿdzǷǼǯȁǼǽDzǽ ǾǿǽȀȁǿǯǼȀȁDZǯ ǽȁǽǰǿǯǵǯȍȁ ȀȎ DZ dzǿȂDzǽǻ ǹǽǽǿdzǷǼǯȁǼǽǻ ǾǿǽȀȁǿǯǼȀȁDZǴ ǝǰȊȆǼǽ Ȍȁǽ ǽǾǷȀȊDZǯǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ ǻǯȁǿǷȅȊ ȁǿǯǼȀȃǽǿ ǻǯȅǷǷ (transformation matrix ȀǾǴȅǷǯǺȋǼǽǸ ǻǯȁǴǻǯȁǷȆǴȀǹǽǸ ȀȁǿȂǹȁȂǿȊ ǹǽȁǽǿǯȎ ǽǰǴȀǾǴȆǷDZǯǴȁ ǾǿǽȀȁǽǴ ǻǯȁǴǻǯȁǷȆǴȀǹǽǴ ǾǿǴǽǰǿǯǶǽDZǯǼǷǴ ǷǶ ǽdzǼǽǸ ȀǷȀȁǴǻȊ DZ dzǿȂDzȂȍ Silverlight XAML ǾǽǶDZǽǺȎǴȁ ǯǰȀȁǿǯDzǷǿǽ DZǯȁȋ Ȍȁǽ Ƿ DZ dzǯǼǼǽǸ ǹǼǷDzǴ ǻȊ ǼǴ ǰȂdzǴǻ DZdzǯDZǯȁȋȀȎ DZ ǻǯȁǴǻǯȁǷȆǴȀǹǷǴ dzǴȁǯǺǷ Silverlight XAML ǾǽdzdzǴǿ ǵǷDZǯǴȁ ȆǴȁȊǿǴ DZǷdzǯ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ȌǺǴǻǴǼȁǽDZ DZǿǯȈǴǼǷǴ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷǴ ǼǯǹǺǽǼ Ƿ ȁǿǯǼȀǺȎȅǷȍ ǾǴǿǴǻǴȈǴǼǷǴ ǯ ȁǯǹǵǴ ǽȀǽǰȊǸ ȁǷǾ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ǹǽȁǽǿȊǸ ǾǽǶDZǽǺȎǴȁ ǿǴǯǺǷǶǽDZȊDZǯȁȋ ȀǽǰȀȁDZǴǼǼȂȍ ǻǯȁǿǷȅȂ dzǺȎ ȀǽȆǴȁǯǼǷȎ ȁǿǯǼȀȃǽǿǻǯȅǷǸ ǡǿǯǼȀȃǽǿǻǯȅǷǷ ǿǴǯǺǷǶȂȍȁȀȎ ȆǴǿǴǶ ȀDZǽǸȀȁDZǯ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ǠȂȈǴȀȁDZȂǴȁ ǼǴȀǹǽǺȋǹǽ ǿǯǶǼȊȄ ȁǷǾǽDZ ȀDZǽǸȀȁDZ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ǾǿǷǻǴǼȎǴǻȊȄ ǹ ǿǯǶǼȊǻ ȁǷǾǯǻ ǽǰȉǴǹȁǽDZ ǡǯǹ ǾǿǷ ǷȀǾǽǺȋǶǽDZǯǼǷǷ ȁǷǾǯ Brush ȁǿǯǼȀȃǽǿǻǯȅǷȎ ǽǾǿǴdzǴǺȎǴȁȀȎ ǺǷǰǽ ȆǴǿǴǶ ȀDZǽǸȀȁDZǽ Brush.Transform (ǡǿǯǼȀȃǽǿǻǯȅǷȎ ǹǷȀȁǷ) ǴȀǺǷ ǼǴǽǰȄǽdzǷǻǽ ǷǶǻǴǼǷȁȋ ȀǽdzǴǿǵǷǻǽǴ ǹǷȀȁǷ ǼǯǾǿǷǻǴǿ ǴȀǺǷ DZȊ ȄǽȁǷȁǴ Ǿǽ DZǴǿǼȂȁȋ ǷǶǽǰǿǯǵǴǼǷǴ ǾǿǴǵdzǴ ȆǴǻ ǷȀǾǽǺȋǶǽDZǯȁȋ ǴDzǽ DZ ImageBrush ǺǷǰǽ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ Brush.RelativeTransform (ǝȁǼǽȀǷȁǴǺȋǼǯȎ ȁǿǯǼȀȃǽǿǻǯȅǷȎ ǹǷȀȁǷ) ǹǽȁǽǿǽǴ ǾǽǶDZǽǺȎǴȁ ȁǿǯǼȀȃǽǿǻǷǿǽDZǯȁȋ ǹǷȀȁȋ ǷȀǾǽǺȋǶȂȎ ǽȁǼǽȀǷȁǴǺȋǼȊǴ ǶǼǯȆǴǼǷȎ Ȍȁǽ ǾǿǷDzǽdzǷȁȋȀȎ ǾǿǷ ǶǯǹǿǯȇǷDZǯǼǷǷ ǽdzǼǽǸ ǹǷȀȁȋȍ ǿǯǶǼȊȄ ǽǰǺǯȀȁǴǸ ǿǯǶǼȊȄ ǿǯǶǻǴǿǽDZ ǞǿǽȀȁȊǴ ȁǿǯǼȀȃǽǿǻǯȅǷǷ dzǺȎ ȁǷǾǯ Geometry DZȊǾǽǺǼȎȍȁȀȎ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ Geometry.Transform. Ǭȁǽȁ ȁǷǾ ǼǴ ǾǽdzdzǴǿǵǷDZǯǴȁ ǽȁǼǽȀǷȁǴǺȋǼȊǴ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ǜǯǹǽǼǴȅ ǾǿǷ ǷȀǾǽǺȋǶǽDZǯǼǷǷ ȌǺǴǻǴǼȁǯ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǽDzǽ ǷǼȁǴǿȃǴǸȀǯ UI ȁǿǯǼȀȃǽǿǻǯȅǷȎ ǶǯdzǯǴȁȀȎ ȆǴǿǴǶ ȀDZǽǸȀȁDZǽ RenderTransform ǜǯǾǿǷǻǴǿ ȁǿǯǼȀȃǽǿǻǯȅǷȎ ȌǺǺǷǾȀǯ ǰȂdzǴȁ DZȊǾǽǺǼȎȁȋȀȎ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ Ellipse.RenderTransform. Ǒ ȀǺǴdzȂȍȈǴǻ ǿǯǶdzǴǺǴ ǰȂdzȂȁ ǿǯȀȀǻǽȁǿǴǼȊ ǿǯǶǼȊǴ ȁǷǾȊ ȁǿǯǼȀȃǽǿǻǯȅǷǸ Ƿ ǾǽǹǯǶǯǼǽ ǷȀǾǽǺȋǶǽDZǯǼǷǴ ȌȁǷȄ ȀDZǽǸȀȁDZ dzǺȎ ǹǽǼǹǿǴȁǼȊȄ ȁǷǾǽDZ ǽǰȉǴǹȁǽDZ
ǑǿǯȈǴǼǷǴ Ȁ ǾǽǻǽȈȋȍ RotateTransform RotateTransform ǾǽǶDZǽǺȎǴȁ ǾǽDZǽǿǯȆǷDZǯȁȋ ȌǺǴǻǴǼȁ Ǽǯ ǶǯdzǯǼǼȊǸ ȂDzǽǺ DZǽǹǿȂDz ǶǯdzǯǼǼǽǸ ȅǴǼȁǿǯǺȋǼǽǸ ȁǽȆ ǹǷ ǢDzǽǺ ǾǽDZǽǿǽȁǯ ǶǯdzǯǴȁȀȎ ȀDZǽǸȀȁDZǽǻ Angle ǢDzǽǺ DZ DzǿǯdzȂȀǯȄ ǞǿǷǻǴǻ Ƕǯ ǼǯȆǯǺǽ ǽȁȀȆǴȁǯ DzǿǯdzȂȀǽDZ DzǽǿǷǶǽǼȁǯǺȋǼȊǸ DZǴǹȁǽǿ ǼǯǾǿǯDZǺǴǼǼȊǸ DZǾǿǯDZǽ ǞȂȀȁȋ DZǿǯȈǴǼǷǴ DZȊǾǽǺǼȎǴȁȀȎ Ǿǽ ȆǯȀǽDZǽǸ ȀȁǿǴǺǹǴ ȁǽ Dzdzǯ DZǴǿȁǷǹǯǺȋǼȊǸ DZǴǹȁǽǿ ȂǹǯǶȊDZǯȍȈǷǸ DZǼǷǶ ȎDZǺȎǴȁȀȎ ǿǴǶȂǺȋȁǯȁǽǻ ǾǽDZǽǿǽȁǯ Ǽǯ DzǿǯdzȂȀǽDZ ǙǽǽǿdzǷǼǯȁȊ ȅǴǼȁǿǯ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ǶǯdzǯȍȁȀȎ ȀDZǽǸȀȁDZǯǻǷ CenterX Ƿ CenterY Ǟǽ ȂǻǽǺȆǯǼǷȍ ȅǴǼȁǿ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ǷǻǴǴȁ ǹǽǽǿdzǷǼǯȁȊ ȁǯǹǷǻ ǽǰǿǯǶǽǻ ǽȀȋ DZǿǯȈǴǼǷȎ Ǿǽ ȂǻǽǺȆǯǼǷȍ ǼǯȄǽdzǷȁȀȎ DZ DZǴǿȄ ǼǴǻ ǺǴDZǽǻ ȂDzǺȂ ǹǽǼȁǴǸǼǴǿǯ
ǒǺǯDZǯ ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷǻǯȅǷȎ DZ ;$0/
101
ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ XAML-ǹǽdzǯ DZ ǹǽȁǽǿǽǻ DZȊǾǽǺǼȎǴȁȀȎ DZǿǯȈǴǼǷǴ TextBlock Ȁ ǾǽǻǽȈȋȍ RenderTransform, ȀǽdzǴǿǵǯȈǴDzǽ RotateTransform, ǹǽȁǽǿȊǸ ǽǾǿǴdzǴǺȎǴȁ ǾǽDZǽǿǽȁ Ǽǯ 45 DzǿǯdzȂȀǽDZ:
Ǚǯǹ Ȍȁǽ DZȊDzǺȎdzǷȁ ǾǿǴdzȀȁǯDZǺǴǼǽ Ǽǯ ǿǷȀ 5-1.
ǟǗǠ 5 1 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀDZǽǸȀȁDZǯ RotateTransform.
Ǚǯǹ DZǷdzǷȁǴ ǾǽDZǽǿǽȁ ȌȁǽDzǽ ȁǴǹȀȁǯ ǰȊǺ DZȊǾǽǺǼǴǼ ǽȁǼǽȀǷȁǴǺȋǼǽ ȅǴǼȁǿǯǺȋǼǽǸ ȁǽȆǹǷ Ȁ ǹǽǽǿdzǷǼǯȁǯǻǷ ȁǴ DZǴǿȄǼǴDzǽ ǺǴDZǽDzǽ ȂDzǺǯ Ǒ ȀǺǴdzȂȍȈǴǻ XAML ǾǽǹǯǶǯǼǽ ǹǯǹ ǷȀǾǽǺȋǶǽDZǯȁȋ CenterX Ƿ CenterY dzǺȎ DZȊǾǽǺǼǴǼǷȎ DZǿǯȈǴǼǷȎ DZǽǹǿȂDz dzǿȂDzǽǸ ȁǽȆǹǷ Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ, ǾǽDZǽǿǽȁ DZȊǾǽǺǼȎǴȁȀȎ DZǽǹǿȂDz ȁǽȆǹǷ (100,200):
ǟǴǶȂǺȋȁǯȁȊ ȌȁǽǸ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ǾǿǴdzȀȁǯDZǺǴǼȊ Ǽǯ ǿǷȀ 5-2.
ǟǗǠ 5 2 ǑǿǯȈǴǼǷǴ DZǽǹǿȂDz dzǿȂDzǽǸ ȅǴǼȁǿǯǺȋǼǽǸ ȁǽȆǹǷ.
102
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǛǯȀȇȁǯǰǷǿǽDZǯǼǷǴ Ȁ ǾǽǻǽȈȋȍ ScaleTransform ScaleTransform ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǷǶǻǴǼǴǼǷȎ ǿǯǶǻǴǿǯ ǽǰȉǴǹȁǯ DZ ǼǯǾǿǯDZǺǴǼǷǷ Ǿǽ DzǽǿǷǶǽǼȁǯǺȋǼǽǸ ǽȀǷ DZǴǿȁǷǹǯǺȋǼǽǸ ǽȀǷ ǷǺǷ DZ ǽǰǽǷȄ ǼǯǾǿǯDZǺǴǼǷȎȄ ǞǿǷ DZȊǾǽǺǼǴǼǷǷ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷȎ ǽǰȉǴǹȁǯ ǼǴǽǰȄǽdzǷǻǽ Ƕǯdzǯȁȋ Ǿǽ ǹǿǯǸǼǴǸ ǻǴǿǴ ǽdzǼȂ ǷǶ ǽȀǴǸ ǻǯȀ ȇȁǯǰǷǿǽDZǯǼǷȎ Ƿ ȁǽ Ǽǯ ȀǹǽǺȋǹǽ dzǽǺǵǴǼ ǰȊȁȋ ǷǶǻǴǼǴǼ ǻǯȀȇȁǯǰ ǽǰȉǴǹȁǯ Ǿǽ ȌȁǽǸ ǽȀǷ ǓǺȎ ǻǯȀȇȁǯǰǷǿǽ DZǯǼǷȎ ǽǰȉǴǹȁǯ Ǿǽ DzǽǿǷǶǽǼȁǯǺȋǼǽǸ ǽȀǷ ǽȀǷ Ȅ ǷȀǾǽǺȋǶȂǴȁȀȎ ȀDZǽǸȀȁDZǽ ScaleX Ƿ dzǺȎ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷȎ Ǿǽ DZǴǿȁǷǹǯǺȋǼǽǸ ǽȀǷ ǽȀǷ Ȃ ǷȀǾǽǺȋǶȂǴȁȀȎ ȀDZǽǸȀȁDZǽ ScaleY ǬȁǷ ȀDZǽǸȀȁDZǯ ǾǿǷǼǷǻǯȍȁ ǶǼǯȆǴǼǷȎ ȁǷǾǯ double, ǹǽȁǽǿȊǴ ǾǿǴdzȀȁǯDZǺȎȍȁ DZǽ ȀǹǽǺȋǹǽ ǿǯǶ dzǽǺǵǴǼ ǰȊȁȋ ǷǶǻǴǼǴǼ ǽǰȉǴǹȁ DZ ǼǯǾǿǯDZǺǴǼǷǷ Ǿǽ ǶǯdzǯǼǼǽǸ ǽȀǷ ǠǺǴdzǽDZǯȁǴǺȋǼǽ ǶǼǯȆǴǼǷȎ ǰǽǺȋȇǴ ǰȂdzȂȁ ȂDZǴǺǷȆǷDZǯȁȋ ǽǰȉǴǹȁ ǜǯǾǿǷǻǴǿ ǴȀǺǷ ȀDZǽǸȀȁDZȂ ScaleX Ƕǯdzǯȁȋ ǶǼǯȆǴǼǷǴ Ȍȁǽ ǽǰǴȀǾǴȆǷȁ ȂDZǴǺǷȆǴǼǷǴ ǿǯǶǻǴǿǯ ǽǰȉǴǹȁǯ Ǿǽ DzǽǿǷǶǽǼȁǯǺǷ DZ dzDZǯ ǿǯǶǯ ǖǼǯȆǴǼǷȎ ǻǴǼȋȇǴ Ǽǽ ǰǽǺȋȇǴ ǰȂdzȂȁ ǽǰȂȀǺǽDZǺǷDZǯȁȋ ȂǻǴǼȋȇǴǼǷǴ ǽǰȉǴǹȁǯ ǜǯǾǿǷǻǴǿ ǷȀǾǽǺȋǶǽDZǯǼǷǴ ǶǼǯȆǴǼǷȎ ǾǿǷDZǴdzǴȁ ǹ ȂǻǴǼȋȇǴǼǷȍ ǿǯǶǻǴǿǯ ǽǰȉǴǹȁǯ DZdzDZǽǴ DZ ǶǯdzǯǼǼǽǻ ǼǯǾǿǯDZǺǴǼǷǷ Ǘȁǯǹ ǿǯȀȀǻǽȁǿǷǻ XAML-ǹǽdz ǹǽȁǽǿȊǸ ǽǰǴȀǾǴȆǷDZǯǴȁ ȀǽǶdzǯǼǷǴ ǹǿǯȀǼǽDzǽ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ȇǷǿǷǼǽǸ ǾǷǹȀǴǺǽDZ Ƿ DZȊȀǽȁǽǸ ǾǷǹȀǴǺǽDZ
ǜǯ ǿǷȀ 5-3 ǾǽǹǯǶǯǼǽ ǹǯǹ Ȍȁǽ DZȊDzǺȎdzǷȁ DZ Silverlight.
ǟǗǠ 5 3 ǞǿǴdzȀȁǯDZǺǴǼǷǴ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ DZ Silverlight.
ǦȁǽǰȊ ǾǿǷǻǴǼǷȁȋ ǹ ȌȁǽǻȂ ǽǰȉǴǹȁȂ ScaleTransform, ǷȀǾǽǺȋǶȂǴȁȀȎ RenderTransform Ƿ ǶǯdzǯǴȁȀȎ ȁǿǯǼȀȃǽǿ ǻǯȅǷȎ ScaleTransform. Ǒǽȁ ȀǽǽȁDZǴȁȀȁDZȂȍȈǷǸ XAML:
ǜǯ ǿǷȀ 5-4 ǾǽǹǯǶǯǼǽ ǹǯǹ Ȍȁǽ DZȊDzǺȎdzǷȁ DZ Silverlight.
ǒǺǯDZǯ ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷǻǯȅǷȎ DZ ;$0/
103
ǟǗǠ 5 4 ǛǯȀȇȁǯǰǷǿǽDZǯǼǷǴ Ȁ ǾǽǻǽȈȋȍ ScaleTransform.
ǛǽǵǼǽ ǶǯǻǴȁǷȁȋ Ȇȁǽ DZ ǿǴǶȂǺȋȁǯȁǴ ǾǿǷǻǴǼǴǼǷȎ ScaleTransform ǾǿȎǻǽȂDzǽǺȋǼǷǹ DZȊȁȎǼȂǺȀȎ DZǾǿǯDZǽ Ǭȁǽ ǾǿǽǷǶǽȇǺǽ ǾǽȁǽǻȂ Ȇȁǽ ǼǴ ǰȊǺ ǶǯdzǯǼ ȅǴǼȁǿ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷȎ ǓǺȎ ǶǯdzǯǼǷȎ ȅǴǼȁǿǯ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷȎ ǷȀǾǽǺȋǶȂȍȁȀȎ ȀDZǽǸȀȁDZǯ CenterX dzǺȎ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷǷ Ǿǽ DzǽǿǷǶǽǼȁǯǺǷ Ƿ CenterY dzǺȎ ǻǯȀȇȁǯǰǷǿǽDZǯ ǼǷȎ Ǿǽ DZǴǿȁǷǹǯǺǷ ǬȁǷ ȀDZǽǸȀȁDZǯ ǽǾǿǴdzǴǺȎȍȁ ǹǽǽǿdzǷǼǯȁȊ ȅǴǼȁǿǯ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷȎ ǬȁǷ ǹǽǽǿdzǷǼǯȁȊ ǶǯdzǯȍȁȀȎ ǽȁǼǽȀǷȁǴǺȋǼǽ DZǴǿȄǼǴDzǽ ǺǴDZǽDzǽ ȂDzǺǯ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ǙǽǽǿdzǷǼǯȁǯ Ǿǽ ȂǻǽǺȆǯǼǷȍ ² ȁǴ ǷǶ ǻǴǼǴǼǷǴ ǿǯǶǻǴǿǯ ǰȂdzǴȁ ǾǿǽǷȀȄǽdzǷȁȋ DZǾǿǯDZǽ Ƿ DZǼǷǶ ǔȀǺǷ ȀDZǽǸȀȁDZȂ CenterX Ƕǯdzǯȁȋ ǾǽǺǽǵǷȁǴǺȋǼǽǴ ǶǼǯȆǴǼǷǴ ǼǯǾǿǷǻǴǿ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷǴ ǰȂdzǴȁ DZȊǾǽǺ ǼȎȁȋȀȎ ǽȁǼǽȀǷȁǴǺȋǼǽ ȁǽȆǹǷ X ȀǻǴȈǴǼǼǽǸ Ǽǯ ǾǷǹȀǴǺǽDZ DZǾǿǯDZǽ ǽȁ ǺǴDZǽDzǽ ǹǿǯȎ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ Ǒ ǿǴ ǶȂǺȋȁǯȁǴ ȌȁǽDzǽ ǰȂdzǴȁ ȀǽǶdzǯDZǯȁȋȀȎ DZǾǴȆǯȁǺǴǼǷǴ Ȇȁǽ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ȀǻǴȀȁǷǺȀȎ Ǽǯ ǼǴǹǽȁǽǿǽǴ ȆǷȀǺǽ ǾǷǹ ȀǴǺǽDZ DZ ǶǯDZǷȀǷǻǽȀȁǷ ǽȁ ǹǽȌȃȃǷȅǷǴǼȁǯ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷȎ ǽȁǼǽȀǷȁǴǺȋǼǽ ǷȀȄǽdzǼǽDzǽ ǾǽǺǽǵǴǼǷȎ Ǭȁǽ ǽǰȉȎȀǼȎǴȁȀȎ ȁǴǻ Ȇȁǽ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷǴ DZȊǾǽǺǼȎǴȁȀȎ ǽȁǼǽȀǷȁǴǺȋǼǽ ǶǯdzǯǼǼǽDzǽ ȅǴǼȁǿǯ Ƿ ǺǴDZǯȎ ȆǯȀȁȋ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ȂDZǴǺǷȆǷDZǯǴȁȀȎ ȁǽȆǼǽ ȁǯǹ ǵǴ ǹǯǹ Ƿ ǾǿǯDZǯȎ ǏǼǯǺǽDzǷȆǼȊǴ ǿǴǶȂǺȋȁǯȁȊ DZ DZǴǿȁǷǹǯǺȋǼǽǻ ǼǯǾǿǯDZǺǴǼǷǷ ǻǽǵǼǽ ǾǽǺȂȆǷȁȋ ǶǯdzǯDZǯȎ ScaleY Ƿ CenterY ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ:
Ǚǯǹ DZ ǿǴǶȂǺȋȁǯȁǴ ȌȁǽDzǽ ǷǶǻǴǼȎǴȁȀȎ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ ǟǷȀ 5-5.
ǟǗǠ 5 5 ǛǯȀȇȁǯǰǷǿǽDZǯǼǷǴ ǽȁǼǽȀǷȁǴǺȋǼǽ ȅǴǼȁǿǯ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷȎ.
ǞǴǿǴǻǴȈǴǼǷǴ ǽǰȉǴǹȁǯ Ȁ ǾǽǻǽȈȋȍ TranslateTransform ǡǿǯǼȀǺȎȅǷȎ (translation) ² Ȍȁǽ ȁǿǯǼȀȃǽǿǻǯȅǷȎ ǾȂȁǴǻ ǾǴǿǴǻǴȈǴǼǷȎ ǽǰȉǴǹȁǯ Ǽǯ ǾǺǽȀǹǽȀȁǷ ǷǶ ǽdzǼǽDzǽ ǻǴȀ ȁǯ DZ dzǿȂDzǽǴ ǝǾǷȀȊDZǯǴȁȀȎ ǽǼǯ ǾȂȁǴǻ ǶǯdzǯǼǷȎ DZǴǹȁǽǿǽDZ ǹǽȁǽǿȊǴ ǽǾǿǴdzǴǺȎȍȁ ǾǴǿǴǻǴȈǴǼǷǴ ǽǰȉǴǹȁǯ ǽȁ
104
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǼǽȀǷȁǴǺȋǼǽ ǽȀǴǸ Ȅ Ƿ Ȃ ǓǺȎ ȌȁǽDzǽ ǷȀǾǽǺȋǶȂȍȁȀȎ ȀDZǽǸȀȁDZǯ X Ƿ Y ǦȁǽǰȊ ǾǴǿǴdzDZǷǼȂȁȋ ȌǺǴǻǴǼȁ Ǽǯ dzDZǴ ǴdzǷ ǼǷȅȊ Ǿǽ DzǽǿǷǶǽǼȁǯǺǷ ǽǰȉǴǹȁ ǰȂdzǴȁ dzDZǷDzǯȁȋȀȎ DZǾǿǯDZǽ ȀDZǽǸȀȁDZȂ X ǶǯdzǯǴȁȀȎ ǶǼǯȆǴǼǷǴ ǦȁǽǰȊ ǾǴǿǴǻǴȀ ȁǷȁȋ ȌǺǴǻǴǼȁ DZǺǴDZǽ ǷȀǾǽǺȋǶȂǴȁȀȎ ǽȁǿǷȅǯȁǴǺȋǼǽǴ ǶǼǯȆǴǼǷǴ ǼǯǾǿǷǻǴǿ - ǏǼǯǺǽDzǷȆǼǽ dzǺȎ ǾǴǿǴǻǴȈǴ ǼǷȎ ǽǰȉǴǹȁǯ Ǿǽ DZǴǿȁǷǹǯǺǷ ǾǿǷǻǴǼȎǴȁȀȎ ȀDZǽǸȀȁDZǽ Y ǖǯdzǯǼǷǴ ǴǻȂ ǾǽǺǽǵǷȁǴǺȋǼȊȄ ǶǼǯȆǴǼǷǸ ǽǰȂȀǺǽDZǷȁ ǾǴǿǴǻǴȈǴǼǷǴ ǽǰȉǴǹȁǯ DZǼǷǶ Ǿǽ ȌǹǿǯǼȂ ȁǽDzdzǯ ǹǯǹ ǽȁǿǷȅǯȁǴǺȋǼȊǴ ǶǼǯȆǴǼǷȎ ǽǰǴȀǾǴȆǯȁ ǾǴǿǴǻǴȈǴǼǷǴ ǽǰȉǴǹȁǯ DZDZǴǿȄ ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ȁǿǯǼȀǺȎȅǷǴǸ ǹǽȁǽǿǯȎ ǽǰǴȀǾǴȆǷDZǯǴȁ ǾǴǿǴǻǴȈǴǼǷǴ ȂǵǴ ǶǼǯǹǽǻǽDzǽ Ǽǯǻ ǹǿǯȀǼǽDzǽ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ DZDZǴǿȄ Ƿ DZǺǴDZǽ ȆǴǿǴǶ ǶǯdzǯǼǷǴ ȀDZǽǸȀȁDZ X Ƿ Y ǬȁǷ ǶǼǯȆǴǼǷȎ ǽǰǿǯǶȂȍȁ DZǴǹ ȁǽǿ ǽǾǿǴdzǴǺȎȍȈǷǸ ȁǿǯǼȀȃǽǿǻǯȅǷȍ
ǟǴǶȂǺȋȁǯȁȊ ȌȁǽǸ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ǾǿǴdzȀȁǯDZǺǴǼȊ Ǽǯ ǿǷȀ 5-6. ǞǿȎǻǽȂDzǽǺȋǼǷǹ ǾǴǿǴǻǴȀȁǷǺȀȎ DZDZǴǿȄ Ƿ DZǺǴ DZǽ ǽȁǼǽȀǷȁǴǺȋǼǽ ǴDzǽ ǷȀȄǽdzǼǽDzǽ ǾǽǺǽǵǴǼǷȎ (ǿǷȀ. 5-3).
ǟǗǠ 5 6 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀDZǽǸȀȁDZǯ TranslateTransform.
ǜǯǹǺǽǼ ǽǰȉǴǹȁǯ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ SkewTransform ǜǯǹǺǽǼ ǽǰȉǴǹȁǯ ǾǽdzǿǯǶȂǻǴDZǯǴȁ ǴDzǽ ǾǽȀȁȂǾǯȁǴǺȋǼǽǴ ǾǿǽǾǽǿȅǷǽǼǯǺȋǼǽǴ ǷǶǻǴǼǴǼǷǴ DZdzǽǺȋ ǽdzǼǽǸ ǷǶ ǽȀǴǸ Ǒ ǿǴǶȂǺȋȁǯȁǴ ǹDZǯdzǿǯȁ ǷǺǷ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ǾǿǴDZǿǯȈǯǴȁȀȎ DZ ǾǯǿǯǺǺǴǺǽDzǿǯǻǻ Ǭȁǽȁ DZǷǶȂǯǺȋǼȊǸ Ȍȃ ȃǴǹȁ ǽȆǴǼȋ ǾǽǺǴǶǴǼ ǾǿǷ ȀǽǶdzǯǼǷǷ DZǾǴȆǯȁǺǴǼǷȎ ȁǿǴȄǻǴǿǼǽDzǽ ǷǶǽǰǿǯǵǴǼǷȎ Ǽǯ ǾǺǽȀǹǽȀȁǷ ǛǽǵǼǽ ǶǯdzǯDZǯȁȋ ǼǯǹǺǽǼ Ǿǽdz ǽǾǿǴdzǴǺǴǼǼȊǻ ȂDzǺǽǻ DZdzǽǺȋ ǽȀǷ Ȅ ǷǺǷ Ȃ Ƿ ǽȁǼǽȀǷȁǴǺȋǼǽ ǽǾǿǴdzǴǺǴǼǼǽDzǽ ȅǴǼȁǿǯ ǙǽǼǴȆǼǽ DZȀǴ Ȍȁǽ ǻǽǵǼǽ ǹǽǻǰǷǼǷǿǽDZǯȁȋ Ƿ ǼǯǹǺǽǼȎȁȋ ǽǰȉǴǹȁ ǽȁǼǽȀǷȁǴǺȋǼǽ ǽǰǴǷȄ ǽȀǴǸ ǽdzǼǽ DZǿǴǻǴǼǼǽ ǟǯȀȀǻǽȁǿǷǻ XAML-ǹǽdz ǽǰǴȀǾǴȆǷDZǯȍȈǷǸ ǼǯǹǺǽǼ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ DZdzǽǺȋ ǽȀǷ Ȅ Ǽǯ DzǿǯdzȂȀǽDZ:
ǟǴǶȂǺȋȁǯȁ ǾǿǴdzȀȁǯDZǺǴǼ Ǽǯ ǿǷȀ 5-7.
ǒǺǯDZǯ ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷǻǯȅǷȎ DZ ;$0/
105
ǟǗǠ 5 7 ǜǯǹǺǽǼǴǼǷǴ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ Ȁ ǾǽǻǽȈȋȍ SkewTransform.
ǗǻǷȁǯȅǷȎ ȁǿǴȄǻǴǿǼǽDzǽ ǷǶǽǰǿǯǵǴǼǷȎ Ȁ ǾǽǻǽȈȋȍ SkewTransform ǜǯǹǺǽǼ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ȀǽǶdzǯǼǷȎ ȌȃȃǴǹȁǯ ȁǿǴȄǻǴǿǼǽDzǽ ǷǶǽǰǿǯǵǴǼǷȎ ǜǷǵǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ XAML-ǹǽdzǯ DZ ǹǽȁǽǿǽǻ ǷȀǾǽǺȋǶȂǴȁȀȎ ȁǿǷ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ dzDZǯ ǷǶ ǹǽȁǽǿȊȄ ǼǯǹǺǽǼǴǼȊ Ǿǽ ǽȀǷ Ȅ Ƿ ǽdzǷǼ ² Ǿǽ ǽȀǷ Ȃ Ȇȁǽ ȀǽǶdzǯǴȁ DZǾǴȆǯȁǺǴǼǷǴ ȁǿǴȄǻǴǿǼǽDzǽ ǷǶǽǰǿǯǵǴǼǷȎ
ǟǴǶȂǺȋȁǯȁȊ ȌȁǽDzǽ ǾǿǴdzȀȁǯDZǺǴǼȊ Ǽǯ ǿǷȀ 5-8.
106
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǟǗǠ 5 8 ǗǻǷȁǯȅǷȎ ȁǿǴȄǻǴǿǼǽDzǽ ǷǶǽǰǿǯǵǴǼǷȎ Ȁ ǾǽǻǽȈȋȍ SkewTransform.
ǝǾǿǴdzǴǺǴǼǷǴ ȀǽǰȀȁDZǴǼǼȊȄ ȁǿǯǼȀȃǽǿǻǯȅǷǸ Ȁ ǾǽǻǽȈȋȍ MatrixTransform ǑȀǴ ȁǿǯǼȀȃǽǿǻǯȅǷǷ Ǿǽ ȀȂȁǷ ȀDZǽǴǸ ǽȀȂȈǴȀȁDZǺȎȍȁȀȎ ǾȂȁǴǻ ȀǽDZǽǹȂǾǼǽDzǽ ǷǶǻǴǼǴǼǷȎ ǹǽǽǿdzǷǼǯȁǼǽDzǽ Ǿǿǽ ȀȁǿǯǼȀȁDZǯ ǽǰȉǴǹȁǯ Ȁ ǾǽǻǽȈȋȍ ǻǯȁǿǷȅȊ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ǑȀǴ ǾǿǴdzȀȁǯDZǺǴǼǼȊǴ dzǽ ȌȁǽDzǽ DZ dzǯǼǼǽǸ DzǺǯDZǴ ȁǿǯǼȀȃǽǿǻǯȅǷǸ ȇǷǿǽǹǽ ǷǶDZǴȀȁǼȊ Ƿ Ȅǽǿǽȇǽ ǽǾǷȀǯǼȊ ǛǯȁǴǻǯȁǷǹǯ ǻǯȁǿǷȅ Ƿ ǿǴǯǺǷǶǯȅǷȎ ȁǿǯǼȀȃǽǿǻǯȅǷǸ DZȊȄǽdzȎȁ Ƕǯ ǿǯǻǹǷ ǿǯȀȀǻǽȁǿǴǼǷȎ dzǯǼǼǽǸ ǹǼǷDzǽǸ Ǽǽ ǿǯdzǷ ȀǷǼȁǯǹȀǷȆǴȀǹǽǸ ǾǽǺǼǽȁȊ ǻȊ ǿǯȀȀǻǽȁǿǷǻ ǶdzǴȀȋ ǹǯǹ ǷȄ ǻǽǵǼǽ ǽǾǿǴdzǴǺȎȁȋ DZ Silverlight XAML. ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ ǻǯȁǿǷȅǯ ǷȀǾǽǺȋǶȂǴǻǯȎ DZ MatrixTransform ȎDZǺȎǴȁȀȎ ǯȃȃǷǼǼǽǸ Ǭȁǽ ǽǶǼǯȆǯǴȁ Ȇȁǽ ǾǽȀǺǴdzǼǷǸ ȀȁǽǺǰǴȅ ǻǯȁǿǷȅȊ DZȀǴDzdzǯ Ƿ ȁǯǹǷǻ ǽǰǿǯǶǽǻ ǶǯdzǯȍȁȀȎ ȁǽǺȋǹǽ ǾǴǿDZȊǴ dzDZǯ ȀȁǽǺǰȅǯ. ǓǺȎ ȌȁǽDzǽ ǷȀǾǽǺȋǶȂǴȁȀȎ ȀDZǽǸȀȁDZǽ Matrix ǛǯȁǿǷȅǯ ǹǽȁǽǿǽǴ ǾǿǷǼǷǻǯǴȁ ȀȁǿǽǹǽDZǽǴ ǶǼǯȆǴǼǷǴ ǽǰǿǯǶǽ DZǯǼǼǽǴ ǶǼǯȆǴǼǷȎǻǷ ǾǴǿDZȊȄ dzDZȂȄ ȀȁǽǺǰȅǽDZ ǶǯǾǷȀǯǼǼȊǻǷ ȆǴǿǴǶ ǾǿǽǰǴǺȊ ǜǷǵǴ ǾǿǷDZǴdzǴǼ ǾǿǷǻǴǿ:
ǜǯ ǿǷȀ 5- ǾǿǽdzǴǻǽǼȀȁǿǷǿǽDZǯǼ ǿǴǶȂǺȋȁǯȁ ǾǿǷǻǴǼǴǼǷȎ ȌȁǽǸ ǻǯȁǿǷȅȊ ² ǿǯȀȁȎǼȂȁȊǸ Ƿ ǼǯǹǺǽǼǴǼǼȊǸ ǾǿȎǻǽȂDzǽǺȋǼǷǹ
ǒǺǯDZǯ ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷǻǯȅǷȎ DZ ;$0/
107
ǟǗǠ 5 9 ǗȀǾǽǺȋǶǽDZǯǼǷǴ MatrixTransform.
ǠǽȆǴȁǯǼǷǴ ȁǿǯǼȀȃǽǿǻǯȅǷǸ Ǚǯǹ ǰȊǺǽ ǾǿǴdzȀȁǯDZǺǴǼǽ DZ ǾǿǴdzȊdzȂȈǴǻ ǾǿǷǻǴǿǴ Ȁ ǾǽǻǽȈȋȍ ǯȃȃǷǼǼǽǸ ǻǯȁǿǷȅȊ Ƿ MatrixTransform ǻǽǵǼǽ ȀǽǶdzǯDZǯȁȋ ȀǺǽǵǼȊǴ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ǝdzǼǯǹǽ ǼǴ DZȀǴ Ȅǽǿǽȇǽ ǿǯǶǰǷǿǯȍȁȀȎ DZ ǻǯȁǴǻǯȁǷǹǴ ǻǯȁǿǷȅ ǞǽȌȁǽǻȂ ǾǿǷǻǴǼȎǴȁȀȎ dzǿȂDzǯȎ ȁǴȄǼǷǹǯ ² ȀǽȆǴȁǯǼǷǴ ȁǿǯǼȀȃǽǿǻǯȅǷǸ Ȁ ǾǽǻǽȈȋȍ ȌǺǴǻǴǼȁǯ TransformGroup ǒǿȂǾǾǯ ȁǿǯǼȀȃǽǿǻǯȅǷǸ ǹǽȁǽǿȊǸ ǾǿǽȀȁǽ ǾǽǶDZǽǺȎǴȁ ǶǯdzǯDZǯȁȋ ǼǴȀǹǽǺȋǹǽ ȁǿǯǼȀȃǽǿǻǯȅǷǸ ǝǰȉǴǹȁ ǾǽdzDZǴǿDzǯǴȁȀȎ ǹǽǻǰǷǼǷǿǽDZǯǼǼǽǻȂ ȌȃȃǴǹȁȂ ǽȁ DZȀǴȄ ȁǿǯǼȀȃǽǿǻǯȅǷǸ DZǻǴȀȁǴ DZǶȎȁȊȄ ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ
Ǒ Ȍȁǽǻ ǾǿǷǻǴǿǴ ǹǽǻǰǷǼǷǿȂȍȁȀȎ ScaleTransform ǹǽȁǽǿȊǸ ǽǰǴȀǾǴȆǷDZǯǴȁ ȂDZǴǺǷȆǴǼǷǴ ǿǯǶǻǴǿǯ ȃǷDzȂǿȊ DZdzǽǺȋ ǽǰǴǷȄ ǽȀǴǸ Ǽǯ ǼǯǹǺǽǼ Ǽǯ DzǿǯdzȂȀǽDZ Ǿǽ ǽȀǷ Ȅ Ƿ ǾǽDZǽǿǽȁ Ǽǯ DzǿǯdzȂȀǽDZ ǟǴǶȂǺȋȁǯȁȊ ȌȁǽǸ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ǾǿǴdzȀȁǯDZǺǴǼȊ Ǽǯ ǿǷȀ 5-10.
108
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǟǗǠ 5 10 ǠǽȆǴȁǯǼǷǴ ȁǿǯǼȀȃǽǿǻǯȅǷǸ Ȁ ǾǽǻǽȈȋȍ TransformGroup.
ǏǼǷǻǯȅǷȎ ǠǺǽDZǽ ǯǼǷǻǯȅǷȎ ǰȂǹDZǯǺȋǼǽ ǽǶǼǯȆǯǴȁ ©ǽǵǷDZǷȁȋ Ȇȁǽ-ȁǽª ǡǯǹǷǻ ǽǰǿǯǶǽǻ Ȁ ǾǽǻǽȈȋȍ ǯǼǷǻǯȅǷǷ DZȊ ǻǽ ǵǴȁǴ DZdzǽȄǼȂȁȋ ǵǷǶǼȋ DZ ȀǽǶdzǯǼǼȊǴ DZǯǻǷ ǽǰȉǴǹȁȊ ǻǴǼȎȎ ǷȄ ǯȁǿǷǰȂȁȊ ȁǯǹǷǴ ǹǯǹ ȅDZǴȁ ǿǯǶǻǴǿ ǾǿǽǶǿǯȆ ǼǽȀȁȋ Ƿ dzǿȂDzǷǴ ȀDZǽǸȀȁDZǯ DZǽ DZǿǴǻǴǼǷ Ƿ DZ ǽȁDZǴȁ Ǽǯ dzǴǸȀȁDZǷȎ ǾǽǺȋǶǽDZǯȁǴǺȎ Ǒ XAML ǯǼǷǻǯȅǷȎ ȌǺǴǻǴǼȁǯ ǽȀȂȈǴȀȁDZǺȎǴȁȀȎ Ƕǯ ȀȆǴȁ ǷǶǻǴǼǴǼǷȎ ǽdzǼǽDzǽ ǷǺǷ ǰǽǺǴǴ ǴDzǽ ȀDZǽǸȀȁDZǽ DZǽ DZǿǴ ǻǴǼǷ Ǭȁǽ DZǿǴǻȎ ǽǾǿǴdzǴǺȎǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ DZǿǴǻǴǼǼǽǸ ȇǹǯǺȊ ǜǯǾǿǷǻǴǿ ȆȁǽǰȊ ȌǺǴǻǴǼȁ ǾǴǿǴȀǴǹ ȌǹǿǯǼ Ƕǯ ȀǴǹȂǼdz ǼǴǽǰȄǽdzǷǻǽ ǰȊǺǽ ǰȊ Ƕǯdzǯȁȋ DZǿǴǻǴǼǼȂȍ ȇǹǯǺȂ dzǺǷȁǴǺȋǼǽȀȁȋȍ ȀǴǹȂǼdz ǹǽȁǽǿǯȎ ǽǰǴȀǾǴ ȆǷǺǯ ǰȊ ǷǶǻǴǼǴǼǷǴ ȀDZǽǸȀȁDZǯ Canvas.Left ǽȁ dzǽ ǶǼǯȆǴǼǷȎ ȇǷǿǷǼȊ ȌǹǿǯǼǯ Ǒ ȀǺǴdzȂȍȈǷȄ ǿǯǶdzǴǺǯȄ ǰȂdzȂȁ ǽǰȀȂǵdzǯȁȋȀȎ DZȀǴ dzǽȀȁȂǾǼȊǴ ȁǷǾȊ ǯǼǷǻǯȅǷǷ Ƿ ǽȁǺǷȆǷȎ ǯǼǷǻǯȅǷǷ ȌȁǷȄ ȀDZǽǸȀȁDZ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǹǺȍ ȆǴDZȊȄ ǹǯdzǿǽDZ ǞǿǴǵdzǴ ȆǴǻ ǾǴǿǴȄǽdzǷȁȋ ǹ ǿǯǶǺǷȆǼȊǻ ȁǷǾǯ ǯǼǷǻǯȅǷǷ DZȊ dzǽǺǵǼȊ ǾǽǶǼǯǹǽǻǷȁȋȀȎ Ȁ ǻǴȄǯǼǷǶǻǯǻǷ ǯǼǷ ǻǯȅǷǸ ǹǽȁǽǿȊǴ DZǹǺȍȆǯȍȁ Triggers ǡǿǷDzDzǴǿȊ EventTriggers ǡǿǷDzDzǴǿȊ ȀǽǰȊȁǷǸ Ƿ Storyboards ǟǯȀǹǯdz ǿǽDZǹǷ ǠǼǯȆǯǺǯ ǿǯȀȀǻǽȁǿǷǻ ȌȁǷ ǹǽǼȅǴǾȅǷǷ ǯ ǶǯȁǴǻ ȂǵǴ ȂDzǺȂǰǷǻȀȎ DZ ǿǯǶǺǷȆǼȊǴ ȁǷǾȊ ǯǼǷǻǯȅǷǷ
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȁǿǷDzDzǴǿǽDZ Ƿ ȁǿǷDzDzǴǿǽDZ ȀǽǰȊȁǷǸ ǏǼǷǻǯȅǷǷ DZ Silverlight DZȊǾǽǺǼȎȍȁȀȎ DZ ǽȁDZǴȁ Ǽǯ ǼǴǹǽȁǽǿǽǴ ȀǽǰȊȁǷǴ ǹǽȁǽǿǽǴ ǽǾǿǴdzǴǺȎǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ ȁǿǷDzDzǴǿǯ Ǒ ǼǯȀȁǽȎȈǴǴ DZǿǴǻȎ Silverlight XAML ǾǽdzdzǴǿǵǷDZǯǴȁ ȁǽǺȋǹǽ ǽdzǷǼ ȁǷǾ ȁǿǷDzDzǴǿǽDZ ² EventTrigger. ǙǯǵdzǽǴ ȀDZǽǸȀȁDZǽ UI ǷǻǴǴȁ ǹǽǺǺǴǹȅǷȍ Triggers ǹǽȁǽǿǯȎ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ ǽdzǼǽDzǽ ǷǺǷ ǰǽ ǺǴǴ ȁǿǷDzDzǴǿǽDZ ȁǴ ǽdzǼǽDzǽ ǷǺǷ ǰǽǺǴǴ EventTriggers). Ǘȁǯǹ ǾǴǿDZȊǸ ȇǯDz DZ dzǽǰǯDZǺǴǼǷǷ ǯǼǷǻǯȅǷǷ DZ ȌǺǴǻǴǼȁ ² ȀǽǶdzǯǼǷǴ ǴDzǽ ǹǽǺǺǴǹȅǷǷ ȁǿǷDzDzǴǿǽDZ ǖǯȁǴǻ DZ ȌȁȂ ǹǽǺǺǴǹȅǷȍ ǼǴǽǰȄǽdzǷǻǽ ǰȂdzǴȁ dzǽǰǯDZǷȁȋ Ǿǽ ǹǿǯǸǼǴǸ ǻǴǿǴ ǽdzǷǼ ȁǿǷDzDzǴǿ ȀǽǰȊȁǷȎ ǜǯǾǿǷǻǴǿ ǾǴǿDZȊǸ ȇǯDz ǾǿǷ ǯǼǷǻǯȅǷǷ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ǽǾǿǴdzǴǺǴǼǷǴ ǹǽǺǺǴǹȅǷǷ ȁǿǷDzDzǴǿǽDZ DZȊDzǺȎdzǷȁ ȀǺǴdzȂȍȈǷǻ ǽǰǿǯǶǽǻ
ǓǯǺǴǴ ǼǴǽǰȄǽdzǷǻǽ ǽǾǿǴdzǴǺǷȁȋ EventTrigger ǹǽȁǽǿȊǸ ǰȂdzǴȁ dzǽǰǯDZǺǴǼ DZ ȌȁȂ ǹǽǺǺǴǹȅǷȍ Ǒ dzǯǼǼǽǻ EventTrigger Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ RoutedEvent ǝȁȀǺǴǵǷDZǯǴǻǽǴ ȀǽǰȊȁǷǴ ǶǯdzǯǴȁȀȎ ȀǽǰȊȁǷǴ DZ ǽȁDZǴȁ Ǽǯ DZǽǶǼǷǹǼǽDZǴǼǷǴ ǹǽȁǽǿǽDzǽ ǰȂdzǴȁ ǶǯǾȂȀǹǯȁȋȀȎ ǯǼǷǻǯȅǷȎ Ǒ ǒǺǯDZǴ ©ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰǿǯȂǶǴǿǯ Silver-
ǒǺǯDZǯ ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷǻǯȅǷȎ DZ ;$0/
109
lightª ǾǽdzǿǽǰǼǽ ǿǯȀȀǻǯȁǿǷDZǯȍȁȀȎ DZȀǴ ȀǽǰȊȁǷȎ ǾǽdzdzǴǿǵǷDZǯǴǻȊǴ ǹǯǵdzȊǻ ǷǶ ǽǰȉǴǹȁǽDZ DZ XAML Ǽǽ ǽǰ ǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ RoutedEvent ǾǽdzdzǴǿǵǷDZǯǴȁ ȁǽǺȋǹǽ ȀǽǰȊȁǷǴ Loaded ǖǯDzǿȂǵǴǼ ǦȁǽǰȊ ǿǴǯǺǷǶǽDZǯȁȋ ǯǼǷǻǯȅǷȍ ǹǽȁǽǿǯȎ ǰȂdzǴȁ ǶǯǾȂȀǹǯȁȋȀȎ ǾǽȀǺǴ ǶǯDzǿȂǶǹǷ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ EventTrigger ǼǴǽǰȄǽdzǷǻǽ ǽǾǷȀǯȁȋ ȀǺǴdzȂȍȈǷǻ ǽǰǿǯǶǽǻ
Ǒǽȁ ȃǿǯDzǻǴǼȁ XAML-ǹǽdzǯ, ǶǯǾȂȀǹǯȍȈǷǸ ȌȁȂ ǯǼǷǻǯȅǷȍ:
ǠǺǴdzȂȍȈǷǸ ȇǯDz ² ȀǽǶdzǯȁȋ ǯǼǷǻǯȅǷȍ ǹǽȁǽǿǯȎ ǰȂdzǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ǏǼǷǻǯȅǷǷ ǿǯǶǻǴȈǯȍȁȀȎ DZ ǿǯȀ ǹǯdzǿǽDZǹǯȄ ǹǽȁǽǿȊǻ ǾǽȀDZȎȈǴǼ ȀǺǴdzȂȍȈǷǸ ǿǯǶdzǴǺ.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ BeginStoryboard Ƿ Storyboard BeginStoryboard ǜǯȆǯȁȋ ǿǯȀǹǯdzǿǽDZǹȂ ² Ȍȁǽ ȁǿǷDzDzǴǿǼǽǴ dzǴǸȀȁDZǷǴ ȀǽdzǴǿǵǯȈǴǴ ǽǰȉǴǹȁ Storyboard Ǒ ǽǰȉ ǴǹȁǯȄ Storyboard ǼǯȄǽdzȎȁȀȎ ǽǾǷȀǯǼǷȎ ǯǼǷǻǯȅǷǷ ǞǿǷ ǽǾǷȀǯǼǷǷ ǯǼǷǻǯȅǷǷ ȌȁǷ ǽǰȉǴǹȁȊ ǾǿǽȀȁǽ DZȀȁǿǯǷ DZǯȍȁȀȎ DZ ǽǾǿǴdzǴǺǴǼǷǴ EventTrigger Ǒǽȁ ǹǯǹ Ȍȁǽ ǰȊǺǽ ǰȊ DZȊǾǽǺǼǴǼǽ dzǺȎ ǾǿǷǻǴǿǯ Ȁ ǾǿȎǻǽȂDzǽǺȋǼǷǹǽǻ Ȁ ǹǽȁǽǿȊǻ ǻȊ ǿǯǰǽȁǯǴǻ DZ ȌȁǽǸ DzǺǯDZǴ
ǝǾǿǴdzǴǺǴǼǷǴ ǾǯǿǯǻǴȁǿǽDZ ǯǼǷǻǯȅǷǷ ǡǴǾǴǿȋ ǹǽDzdzǯ ȀǿǴdzǯ ǯǼǷǻǯȅǷǷ ǶǯdzǯǼǯ ǻǽǵǼǽ ǾǿǷȀȁȂǾǯȁȋ ǹ ǽǾǷȀǯǼǷȍ ȀǯǻǽǸ ǯǼǷǻǯȅǷǷ Ǒ ǽȀǼǽDZǴ ǯǼǷ ǻǯȅǷǷ ǺǴǵǷȁ ǷǶǻǴǼǴǼǷǴ ȀDZǽǸȀȁDZǯ DZǽ DZǿǴǻǴǼǷ ǑǽǶǻǽǵǼǯ ǯǼǷǻǯȅǷȎ ȁǿǴȄ ǿǯǶǼȊȄ ȁǷǾǽDZ ȀDZǽǸȀȁDZ x
ǠDZǽǸȀȁDZǯ ȁǷǾǯ double ǯǼǷǻǷǿȂȍȁȀȎ Ȁ ǾǽǻǽȈȋȍ DoubleAnimation ǷǺǷ DoubleAnimationUsingKeyFrames (ǏǼǷǻǯȅǷȎ ȀDZǽǸȀȁDZ ȁǷǾǯ Double Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ). Ǭȁǽȁ ǻǴȁǽdz ǷȀǾǽǺȋǶȂ ǴȁȀȎ dzǺȎ ǯǼǷǻǯȅǷǷ ȀDZǽǸȀȁDZ Ȁǽ ǶǼǯȆǴǼǷǴǻ ȁǷǾǯ double ǼǯǾǿǷǻǴǿ ȁǯǹǷȄ ǿǯǶǻǴǿǽDZ ǹǯǹ Canvas.Left, ǷǺǷ ȁǯǹǷȄ DZǷǶȂǯǺȋǼȊȄ ǯȁǿǷǰȂȁǽDZ ǹǯǹ Opacity.
x
ǠDZǽǸȀȁDZǯ ȁǷǾǯ ȁǽȆǹǯ ǯǼǷǻǷǿȂȍȁȀȎ Ȁ ǾǽǻǽȈȋȍ PointAnimiation (ǏǼǷǻǯȅǷȎ ȁǽȆǹǷ) ǷǺǷ PointAnimationUsingKeyFrames (ǏǼǷǻǯȅǷȎ ȁǽȆǹǷ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ) Ǭȁǽȁ ǻǴȁǽdz ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǯǼǷǻǯȅǷǷ ȀDZǽǸȀȁDZ Ȁǽ ǶǼǯȆǴǼǷȎǻǷ ǽǾǿǴdzǴǺǴǼǼȊǻǷ ǹǯǹ ȁǽȆǹǯ ǜǯǾǿǷǻǴǿ ȀǴDzǻǴǼȁȊ ǾǿȎǻȊȄ ǷǺǷ ǹǿǷDZȊǴ ǽǾǷȀȊDZǯȍȁ Ȁ ǾǽǻǽȈȋȍ ȁǽȆǴǹ
x
ǠDZǽǸȀȁDZǯ ȁǷǾǯ ȅDZǴȁ ǯǼǷǻǷǿȂȍȁȀȎ Ȁ ǾǽǻǽȈȋȍ ColorAnimation ǷǺǷ ColorAnimationUsingKeyFrames (ǥDZǴȁǽDZǯȎ ǯǼǷǻǯȅǷȎ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ). Ǭȁǽȁ ǻǴȁǽdz ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǯǼǷǻǯȅǷǷ ȀDZǽǸȀȁDZ ȀǽdzǴǿǵǯȈǷȄ ǶǼǯȆǴǼǷȎ ȅDZǴȁǯ ǼǯǾǿǷǻǴǿ ȃǽǼǯ ǷǺǷ ǽǰDZǽdzǹǷ ȌǺǴǻǴǼȁǯ
ǏǼǷǻǯȅǷȎ ǹǯǵdzǽDzǽ ǷǶ ȌȁǷȄ ȁǷǾǽDZ ȀDZǽǸȀȁDZ DZȊǾǽǺǼȎǴȁȀȎ ǽȁ ǶǼǯȆǴǼǷȎ ǶǯdzǯǼǼǽDzǽ ǯȁǿǷǰȂȁǽǻ From ǝȁ ǷǺǷ ǴDzǽ ȁǴǹȂȈǴDzǽ ǶǼǯȆǴǼǷȎ ǴȀǺǷ Ȍȁǽȁ ǯȁǿǷǰȂȁ ǼǴ ǶǯdzǯǼ dzǽ ǶǼǯȆǴǼǷȎ ǶǯdzǯǼǼǽDzǽ ǯȁǿǷǰȂȁǽǻ To Ǔǽ ǷǺǷ Ǽǯ ǶǼǯȆǴǼǷǴ ǶǯdzǯǼǼǽǴ ǯȁǿǷǰȂȁǽǻ By ǜǯ
110
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǖǯdzǯǼǷǴ ǽǰȉǴǹȁǯ ǯǼǷǻǯȅǷǷ ǝǰȉǴǹȁ ǹ ǹǽȁǽǿǽǻȂ dzǽǺǵǼǯ ǾǿǷǻǴǼȎȁȋȀȎ ǯǼǷǻǯȅǷȎ ǶǯdzǯǴȁȀȎ ȀDZǽǸȀȁDZǽǻ Storyboard.TargetName ǗǻȎ ȅǴǺǷ dzǯǼǼǽDzǽ ȁǷǾǯ ǯǼǷǻǯȅǷǷ Ǒ Ȍȁǽ ȀDZǽǸȀȁDZǽ ǾǴǿǴdzǯǴȁȀȎ ǷǻȎ ǽǰȉǴǹȁǯ ǹǽȁǽǿǽǴ DZ ǽǾǷȀǯǼǷǷ ǽǰȉǴǹȁǯ Ƕǯ dzǯǼǽ ȀDZǽǸȀȁDZǽǻ x:Name ǗǻȎ ǙǿǽǻǴ ȁǽDzǽ Ȁ ǾǽǻǽȈȋȍ Storyboard.TargetProperty ǥǴǺǴDZǽǴ ȀDZǽǸȀȁDZǽ Ƕǯ dzǯǴȁȀȎ ǯǼǷǻǷǿȂǴǻǽǴ ȀDZǽǸȀȁDZǽ ǖǯǻǴȁȋȁǴ Ȇȁǽ ȀǽȀȁǯDZǼǽǴ ǷǺǷ ǾǿǷȀǽǴdzǷǼǴǼǼǽǴ ȀDZǽǸȀȁDZǽ ȁǯǹǽǴ ǹǯǹ Canvas.Left ǶǯǹǺȍȆǯǴȁȀȎ DZ ǹǿȂDzǺȊǴ ȀǹǽǰǹǷ Ǘȁǯǹ ǼǯǾǿǷǻǴǿ ȆȁǽǰȊ Ƕǯdzǯȁȋ ǯǼǷǻǯȅǷȍ ȀDZǽǸȀȁDZǯ ȁǷǾǯ Double dzǺȎ ȀDZǽǸȀȁDZǯ Canvas.Left ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ rect ǼǴǽǰȄǽdzǷǻǽ ǼǯǾǷȀǯȁȋ ȀǺǴdzȂȍȈǷǸ XAML:
ǖǯdzǯǼǷǴ ǾǿǽdzǽǺǵǷȁǴǺȋǼǽȀȁǷ ǓǺȎ ǽǾǿǴdzǴǺǴǼǷȎ DZǿǴǻǴǼǷ ǾǴǿǴȄǽdzǯ ǯǼǷǻǷǿȂǴǻȊȄ ȀDZǽǸȀȁDZ ǽȁ ǽdzǼǽDzǽ ǶǼǯȆǴǼǷȎ ǹ dzǿȂDzǽǻȂ ǷȀǾǽǺȋǶȂǴȁȀȎ ȀDZǽǸȀȁDZǽ Duration ǞǿǽdzǽǺǵǷȁǴǺȋǼǽȀȁȋ ǝǼǽ ǽǾǿǴdzǴǺȎǴȁȀȎ DZ ȃǽǿǻǯȁǴ ǦǦ:ǛǛ:ǠǠ DzdzǴ ǾǿǽdzǽǺǵǷȁǴǺȋ ǼǽȀȁȋ ȀǴǹȂǼdz ǶǯǾǷȀȊDZǯǴȁȀȎ 00:00:05, ǷǺǷ ȀǽǹǿǯȈǴǼǼǽ ² 0:0:5. ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ:
ǖǯdzǯǼǷǴ ǻǽǻǴǼȁǯ ǼǯȆǯǺǯ ǔȀǺǷ DZȊ ǼǴ ȄǽȁǷȁǴ ȆȁǽǰȊ ǯǼǷǻǯȅǷȎ ǼǯȆǷǼǯǺǯȀȋ ȀǿǯǶȂ ǾǽȀǺǴ ǶǯDzǿȂǶǹǷ ǻǽǵǼǽ DZDZǴȀȁǷ ǶǯdzǴǿǵǹȂ Ȁ Ǿǽǻǽ Ȉȋȍ ȀDZǽǸȀȁDZǯ BeginTime ǛǽǻǴǼȁ ǼǯȆǯǺǯ ǓǺȎ ǼǴDzǽ ǷȀǾǽǺȋǶȂǴȁȀȎ ȁǯǹǽǸ ǵǴ ȀǷǼȁǯǹȀǷȀ ǹǯǹ Ƿ dzǺȎ Duration.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀDZǽǸȀȁDZǯ SpeedRatio ǛǽǵǼǽ ǼǯȀȁǿǽǷȁȋ ǾǽDZǴdzǴǼǷǴ ǯǼǷǻǯȅǷǷ ȂǻǼǽǵǯȎ ǴǴ ǾǿǽdzǽǺǵǷȁǴǺȋǼǽȀȁȋ Ǽǯ ǹǽȌȃȃǷȅǷǴǼȁ ȀǹǽǿǽȀȁǷ ǓǺȎ ȌȁǽDzǽ ǷȀǾǽǺȋǶȂǴȁȀȎ ȀDZǽǸȀȁDZǽ SpeedRatio ǙǽȌȃȃǷȅǷǴǼȁ ȀǹǽǿǽȀȁǷ ǜǯǾǿǷǻǴǿ DZ ǾǿǴdzȊdzȂȈǴǻ ȀǺȂȆǯǴ ǰȊǺǯ ǶǯdzǯǼǯ ǾǿǽdzǽǺǵǷȁǴǺȋǼǽȀȁȋ ȀǴǹȂǼdz ǖǯdzǯDZ SpeedRatio ǿǯDZǼȊǻ ǻǽǵǼǽ ǷǶǻǴǼǷȁȋ ȀǹǽǿǽȀȁȋ DZǽȀ ǾǿǽǷǶDZǴdzǴǼǷȎ Ƿ ǯǼǷǻǯȅǷȎ ǰȂdzǴȁ dzǺǷȁȋȀȎ ȀǴǹȂǼdz ǗǺǷ ǻǽǵǼǽ ȂȀǹǽǿǷȁȋ ǯǼǷǻǯȅǷȍ dzǽ ȀǴǹȂǼdzȊ Ƕǯ dzǯDZǯȎ SpeedRatio ǿǯDZǼȊǻ
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀDZǽǸȀȁDZǯ AutoReverse ǏǼǷǻǯȅǷȎ Silverlight ǽǰǴȀǾǴȆǷDZǯǴȁ DZǽǶǻǽǵǼǽȀȁȋ DZǽǶDZǿǯȈǴǼǷȎ ȀDZǽǸȀȁDZ ǷǶǻǴǼǴǼǼȊȄ DZ ȄǽdzǴ ǯǼǷǻǯȅǷǷ ǹ ǷȀȄǽdzǼȊǻ ǶǼǯȆǴǼǷȎǻ ǜǯǾǿǷǻǴǿ ǴȀǺǷ ǶǼǯȆǴǼǷǴ ȁǷǾǯ double ǷǶǻǴǼȎǴȁȀȎ ǽȁ dzǽ Ƕǯ ǽǾǿǴdzǴǺǴǼǼȊǸ ǾǿǽǻǴǵȂȁǽǹ DZǿǴǻǴǼǷ ȀDZǽǸȀȁDZǽ AutoReverse ǏDZȁǽǻǯȁǷȆǴȀǹǯȎ ǾǴǿǴǻǽȁǹǯ ǶǯȀȁǯDZǷȁ ǯǼǷǻǯȅǷȍ DZȊǾǽǺ ǼǷȁȋȀȎ DZ ǽǰǿǯȁǼǽǻ ǼǯǾǿǯDZǺǴǼǷǷ ǽȁ ǹ 0. ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ ǴȀǺǷ ǶǯdzǯǼǯ ǾǿǽdzǽǺǵǷȁǴǺȋǼǽȀȁȋ ǯǼǷǻǯȅǷǷ ȀǴǹȂǼdz Ƿ ȀDZǽǸȀȁDZȂ AutoReverse ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ true ǾǿǽdzǽǺǵǷȁǴǺȋǼǽȀȁȋ DZȀǴǸ ǯǼǷǻǯȅǷǷ ǰȂdzǴȁ ȀǴǹȂǼdz ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ XAML Ȁǽ ȀDZǽǸȀȁDZǽǻ AutoReverse:
ǖǯdzǯǼǷǴ ȀDZǽǸȀȁDZǯ RepeatBehavior ǠȂȈǴȀȁDZȂǴȁ ǿȎdz ǽǾȅǷǸ ǾǽȀǿǴdzȀȁDZǽǻ ǹǽȁǽǿȊȄ ǻǽǵǼǽ ȂǾǿǯDZǺȎȁȋ ǾǽDZǴdzǴǼǷǴǻ ǯǼǷǻǯȅǷǷ Ǿǽ ǶǯDZǴǿȇǴǼǷǷ ǴǴ DZȊǾǽǺǼǴǼǷȎ ǖǯdzǯȍȁȀȎ ǽǼǷ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ RepeatBehavior ǞǽDZǴdzǴǼǷǴ ǾǽDZȁǽǿǯ Ǭȁǽ ȀDZǽǸȀȁDZǽ ǻǽǵǴȁ ǾǿǷǼǷǻǯȁȋ ȁǿǷ ȁǷǾǯ ǶǼǯȆǴǼǷǸ x
ǑǿǴǻȎ DZ ȀǴǹȂǼdzǯȄ ǞǽȀǺǴ ǾǿǽȄǽǵdzǴǼǷȎ ȌȁǽDzǽ ǾǿǽǻǴǵȂȁǹǯ DZǿǴǻǴǼǷ Ǽǯ DZǿǴǻǴǼǼǽǸ ȇǹǯǺǴ ǯǼǷǻǯȅǷȎ ǰȂdzǴȁ ǶǯǾȂȀǹǯȁȋȀȎ ǾǽDZȁǽǿǼǽ
ǒǺǯDZǯ ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷǻǯȅǷȎ DZ ;$0/
111
x
ǖǼǯȆǴǼǷǴ Forever (ǞǽȀȁǽȎǼǼǽ) ǽǾǿǴdzǴǺȎǴȁ ǾǽȀȁǽȎǼǼǽǴ ǾǽDZȁǽǿǴǼǷǴ.
x
ǝǾǿǴdzǴǺǴǼǼǽǴ ǹǽǺǷȆǴȀȁDZǽ ǾǽDZȁǽǿǴǼǷǸ ǓǺȎ ȌȁǽDzǽ ǶǯdzǯǴȁȀȎ ȆǷȀǺǽ ǽǾǿǴdzǴǺȎȍȈǴǴ ȆǷȀǺǽ ǾǽDZȁǽǿǴ ǼǷǸ Ƕǯ ǹǽȁǽǿȊǻ ȀǺǴdzȂǴȁ ȀǷǻDZǽǺ x ǜǯǾǿǷǻǴǿ ǴȀǺǷ ǼǴǽǰȄǽdzǷǻǽ ǾǽDZȁǽǿǷȁȋ ǯǼǷǻǯȅǷȍ ȁǿǷ ǿǯǶǯ Ƕǯ dzǯǴȁȀȎ ǶǼǯȆǴǼǷǴ 3x.
ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǽǺǼȊǸ XAML-ǹǽdz dzǺȎ ǯǼǷǻǯȅǷǷ ǾǴǿǴǻǴȈǴǼǷȎ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ǷǶ ȁǽȆǹǷ DZ ȁǽȆǹȂ Ƿ ǼǯǶǯdz DZ Ǿǽ ǽȀǷ Ȅ Ȁ ǾǽȀǺǴdzȂȍȈǷǻ ȁǿǽǴǹǿǯȁǼȊǻ ǾǽDZȁǽǿǴǼǷǴǻ
ǟǯȀȀǻǽȁǿǷǻ ǹǯǵdzȊǸ ǷǶ ȌȁǷȄ ȁǷǾǽDZ ǯǼǷǻǯȅǷǷ ǼǴǻǼǽDzǽ ǰǽǺǴǴ ǾǽdzǿǽǰǼǽ ǠǼǯȆǯǺǯ ǽǰǿǯȁǷǻȀȎ ǹ ǯȁǿǷǰȂ ȁǯǻ ǼǴǽǰȄǽdzǷǻȊǻ dzǺȎ ǯǼǷǻǯȅǷǷ ǹǯǵdzǽDzǽ ǷǶ ȁǷǾǽDZ ǯ ǶǯȁǴǻ ǾǴǿǴǸdzǴǻ ǹ ǷȀǾǽǺȋǶǽDZǯǼǷȍ ǯǼǷǻǯȅǷǷ Ǿǽ ǹǺȍȆǴDZȊǻ ǹǯdzǿǯǻ.
ǏǼǷǻǯȅǷȎ ǶǼǯȆǴǼǷȎ Ȁ ǾǽǻǽȈȋȍ DoubleAnimation ǝǰȉǴǹȁ DoubleAnimation ǾǽǶDZǽǺȎǴȁ ǶǯdzǯDZǯȁȋ ǹǯǹ ǶǼǯȆǴǼǷȎ ȁǷǾǯ double ǷǶǻǴǼȎǴȁȀȎ Ȁǽ DZǿǴǻǴǼǴǻ ǏǼǷ ǻǯȅǷȎ DZȊȆǷȀǺȎǴȁȀȎ ǹǯǹ ǺǷǼǴǸǼǯȎ ǷǼȁǴǿǾǽǺȎȅǷȎ ǻǴǵdzȂ ǶǼǯȆǴǼǷȎǻǷ ȀDZǽǸȀȁDZǯ DZ ǿǯǶǼȊǴ ǻǽǻǴǼȁȊ DZǿǴ ǻǴǼǷ ǞǿǷ ǯǼǷǻǯȅǷǷ ȀDZǽǸȀȁDZ ȁǷǾǯ double ǶǯdzǯǴȁȀȎ ǶǼǯȆǴǼǷǴ DZ ǼǯȆǯǺǴ ǯǼǷǻǯȅǷǷ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ From Ƿ ǴDzǽ ǯǰȀǽǺȍȁǼǽǴ ǹǽǼǴȆǼǽǴ ǶǼǯȆǴǼǷǴ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ To ǷǺǷ ǽȁǼǽȀǷȁǴǺȋǼǽǴ ǹǽǼǴȆǼǽǴ ǶǼǯȆǴǼǷǴ ǾǽȀǿǴdzȀȁDZǽǻ ȀDZǽǸȀȁDZǯ By. ǜǯǾǿǷǻǴǿ ȆȁǽǰȊ ǷǶǻǴǼǷȁȋ ȀDZǽǸȀȁDZǽ Canvas.Left ȌǺǴǻǴǼȁǯ ǽȁ ǿǯȀǾǽǺǽǵǴǼǷǴ ǿȎdzǽǻ Ȁ ǺǴDZȊǻ ǹǿǯǴǻ ȌǹǿǯǼǯ dzǽ ǻǽǵǼǽ Ƕǯdzǯȁȋ ȀDZǽǸȀȁDZȂ From ǶǼǯȆǴǼǷǴ Ƿ ȀDZǽǸȀȁDZȂ To ǷǺǷ ȀDZǽǸȀȁDZȂ By ǝǰ ǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ DZ ȀǺȂȆǯǴ ǶǯdzǯǼǷȎ ǽǰǽǷȄ ȀDZǽǸȀȁDZ To ǷǻǴǴȁ ǾǿǴǷǻȂȈǴȀȁDZǽ Ǽǯdz By ǡǯǹǵǴ ǴȀǺǷ ǾǿȎ ǻǽȂDzǽǺȋǼǷǹ ȂǵǴ ǼǯȄǽdzǷȁȀȎ DZ ǽǾǿǴdzǴǺȎǴǻǽǸ From ǾǽǶǷȅǷǷ Ȍȁǽ ȀDZǽǸȀȁDZǽ ǶǯdzǯDZǯȁȋ ǼǴ Ǽǯdzǽ ǞǿǴdzȊdzȂȈǷǸ ǾǿǷǻǴǿ XAML-ǹǽdzǯ ǿǴǯǺǷǶȂǴȁ Ȍȁǽ ǾǽDZǴdzǴǼǷǴ ǞǿȎǻǽȂDzǽǺȋǼǷǹ ǿǯȀǾǽǺǯDzǯǴȁȀȎ DZ ǾǽǶǷȅǷǷ Ȁ Canvas.Left ǿǯDZǼȊǻ DoubleAnimation ǽǾǿǴdzǴǺȎǴȁ dzǺȎ To ǶǼǯȆǴǼǷǴ ǠǺǴdzǽDZǯȁǴǺȋǼǽ ǯǼǷǻǯȅǷȎ ǽǰǴȀǾǴȆǷȁ ǷǶǻǴǼǴǼǷǴ ǶǼǯȆǴǼǷȎ ǽȁ dzǽ Ȇȁǽ ǽǰȂȀǺǽDZǷȁ ǾǴǿǴǻǴȈǴǼǷǴ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ Ǿǽ ȌǹǿǯǼȂ DZǾǿǯDZǽ
ǏǼǷǻǯȅǷȎ ȅDZǴȁǯ Ȁ ǾǽǻǽȈȋȍ ColorAnimation ǞǽDZǴdzǴǼǷǴ ColorAnimation ǽȆǴǼȋ ǰǺǷǶǹǽ ǾǽDZǴdzǴǼǷȍ DoubleAnimation. Ǭȁǽȁ ȁǷǾ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǷǶǻǴ ǼǴǼǷȎ ǶǼǯȆǴǼǷȎ color ȌǺǴǻǴǼȁǯ DZǽ DZǿǴǻǴǼǷ ǏǼǷǻǯȅǷȎ DZȊȆǷȀǺȎǴȁȀȎ ǹǯǹ ǺǷǼǴǸǼǯȎ ǷǼȁǴǿǾǽǺȎȅǷȎ ǻǴǵdzȂ ǶǼǯȆǴǼǷȎǻǷ color DZ ǶǯdzǯǼǼȊǸ ǾǿǽǻǴǵȂȁǽǹ DZǿǴǻǴǼǷ ǞǿǷ ǯǼǷǻǯȅǷǷ ȅDZǴȁǯ ǶǼǯȆǴǼǷǴ DZ ǼǯȆǯǺǴ ǯǼǷǻǯȅǷǷ ǶǯdzǯǴȁȀȎ ȀDZǽǸȀȁDZǽǻ From ǔȀǺǷ Ȍȁǽ ȀDZǽǸȀȁDZǽ ǼǴ Ƕǯ dzǯǼǽ Ƕǯ ǷȀȄǽdzǼȊǸ ǾǿǷǼǷǻǯǴȁȀȎ ȁǴǹȂȈǷǸ ȅDZǴȁ ǏȁǿǷǰȂȁ To ǽǾǿǴdzǴǺȎǴȁ ǹǽǼǴȆǼȊǸ ȅDZǴȁ ǡǯǹǵǴ ǻǽǵǼǽ Ƕǯdzǯȁȋ ǯȁǿǷǰȂȁ By ȁǽDzdzǯ ǹǽǼǴȆǼȊǸ ȅDZǴȁ ǰȂdzǴȁ ǾǽǺȂȆǴǼ ǾȂȁǴǻ ȀȂǻǻǷǿǽDZǯǼǷȎ ǶǼǯȆǴǼǷȎ ȅDZǴȁǯ ǶǯdzǯǼǼǽDzǽ DZ From ǷǺǷ ǷȀȄǽdzǼǽDzǽ ȅDZǴȁǯ Ƿ ȅDZǴȁǯ ǶǯdzǯǼǼǽDzǽ By. ǏǼǷǻǯȅǷȎ ȅDZǴȁǽDZȊȄ ȀDZǽǸȀȁDZ ǼǴ ǽǶǼǯȆǯǴȁ ǯǼǷǻǯȅǷȍ ȀǽdzǴǿǵǷǻǽDzǽ ȀDZǽǸȀȁDZǯ ǾǽȁǽǻȂ Ȇȁǽ ȀǽdzǴǿǵǷǻȊǻ ȀDZǽǸȀȁDZǯ ǽǰȊȆǼǽ ȎDZǺȎǴȁȀȎ ǹǷȀȁȋ ǯ ǼǴ ȅDZǴȁ ǞǽȌȁǽǻȂ ǼǯǾǿǷǻǴǿ ǴȀǺǷ ǼǴǽǰȄǽdzǷǻǽ ǯǼǷǻǷǿǽDZǯȁȋ ȅDZǴȁ
112
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǶǯǺǷDZǹǷ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ȅǴǺǴDZȊǻ ȀDZǽǸȀȁDZǽǻ ǯǼǷǻǯȅǷǷ ȎDZǺȎǴȁȀȎ ǼǴ ǴDzǽ ȀDZǽǸȀȁDZǽ Fill ǯ ȀDZǽǸȀȁDZǽ Color ǹǷȀȁǷ SolidBrush ǹǽȁǽǿǯȎ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ DZȊǾǽǺǼǴǼǷȎ ǶǯǺǷDZǹǷ ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ ǯǼǷǻǯȅǷǷ ȅDZǴȁǯ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ ǥDZǴȁ ǻǴǼȎǴȁȀȎ ǽȁ ȆǴǿǼǽDzǽ ǹ ǰǴǺǽǻȂ DZ ȁǴ ȆǴǼǷǴ ȀǴǹȂǼdz
Ǚǯǹ DZǷdzǷȁǴ, DZ Ȍȁǽǻ ȃǿǯDzǻǴǼȁǴ XAML ȅǴǺǴDZȊǻ ȀDZǽǸȀȁDZǽǻ ȎDZǺȎǴȁȀȎ ȀDZǽǸȀȁDZǽ Color ǹǷȀȁǷ SolidColorBrush, ǶǯǹǿǯȇǷDZǯȍȈǴǸ ȃǷDzȂǿȂ. Ǭȁǽ ȁǷǾǽDZǽǸ ȀǷǼȁǯǹȀǷȀ XAML ǷȀǾǽǺȋǶȂǴǻȊǸ ǾǿǷ ǿǯǰǽȁǴ Ȁ ȁǯǹǷǻǷ ȀǽȀȁǯDZǼȊǻǷ ȀDZǽǸȀȁDZǯǻǷ.
ǏǼǷǻǯȅǷȎ ȁǽȆǹǷ Ȁ ǾǽǻǽȈȋȍ PointAnimation ǓǺȎ ǷǶǻǴǼǴǼǷȎ DZǽ DZǿǴǻǴǼǷ ǶǼǯȆǴǼǷȎ ǽǾǿǴdzǴǺǴǼǼǽDzǽ ǹǯǹ ȁǽȆǹǯ ǷȀǾǽǺȋǶȂǴȁȀȎ ȁǷǾ PointAnimation ǏǼǷ ǻǯȅǷȎ DZȊȆǷȀǺȎǴȁȀȎ ǹǯǹ ǺǷǼǴǸǼǯȎ ǷǼȁǴǿǾǽǺȎȅǷȎ ǻǴǵdzȂ ǶǼǯȆǴǼǷȎǻǷ DZ ǶǯdzǯǼǼȊǸ ǾǿǽǻǴǵȂȁǽǹ DZǿǴǻǴǼǷ ǏǼǯǺǽDzǷȆǼǽ ȁǽǻȂ ǹǯǹ Ȍȁǽ dzǴǺǯǺǽȀȋ dzǺȎ ǯǼǷǻǯȅǷǷ ȅDZǴȁǯ Ƿ ǽǰȉǴǹȁǽDZ ȁǷǾǯ Double ǷȀȄǽdzǼǽǴ ǶǼǯȆǴǼǷǴ Ƕǯ dzǯǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ From Ƿ ǹǽǼǴȆǼǽǴ ǶǼǯȆǴǼǷǴ ǶǯdzǯǴȁȀȎ ǹǯǹ ǽȁǼǽȀǷȁǴǺȋǼǽǴ ǷȀǾǽǺȋǶȂȎ By ǷǺǷ ǹǯǹ ǯǰȀǽǺȍȁǼǽǴ ǷȀǾǽǺȋǶȂȎ To ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ ǯǼǷǻǯȅǷǷ ǹǽǼǴȆǼǽǸ ȁǽȆǹǷ ǹǿǷDZǽǸ ǐǴǶȋǴ:
Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ ǹǿǷDZǯȎ ǐǴǶȋǴ ǽǾǷȀȊDZǯǴȁȀȎ ǼǯȆǯǺȋǼǽǸ ȁǽȆǹǽǸ ǹǽǼǴȆǼǽǸ ȁǽȆǹǽǸ Ƿ ǽǾǽǿǼǽǸ ȁǽȆǹǽǸ ǖǯdzǯǼǽ Ȇȁǽ ǯǼǷǻǯȅǷȎ ǶǯǾȂȀǹǯǴȁȀȎ ǾǽȀǺǴ ǶǯDzǿȂǶǹǷ ǹǽǼȁȂǿǯ Ƿ ǽǰǴȀǾǴȆǷDZǯǴȁ ǾǴ ǿǴǻǴȈǴǼǷǴ ǹǽǼǴȆǼǽǸ ȁǽȆǹǷ ǹǿǷDZǽǸ Point2 ǽȁ ȁǽȆǹǷ 300,100 DZ ȁǽȆǹȂ 300,600 DZ ȁǴȆǴǼǷǴ ȀǴǹȂǼdz.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ ǑȀǴ ǿǯȀȀǻǯȁǿǷDZǯǴǻȊǴ dzǽ ȀǷȄ Ǿǽǿ ȁǷǾȊ ǯǼǷǻǯȅǷǷ ColorAnimation, DoubleAnimation Ƿ PointAnimation, ² DZȊǾǽǺǼȎǺǷȀȋ ǾȂȁǴǻ ǷǶǻǴǼǴǼǷȎ ǶǯdzǯǼǼǽDzǽ ȀDZǽǸȀȁDZǯ DZǽ DZǿǴǻǴǼǷ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǺǷǼǴǸǼǽǸ ǷǼȁǴǿǾǽ ǺȎȅǷǷ ǜǯǾǿǷǻǴǿ ǾǿǷ ǷǶǻǴǼǴǼǷǷ ǶǼǯȆǴǼǷȎ ȁǷǾǯ double ǽȁ dzǽ 500 Ƕǯ ȀǴǹȂǼdz ǴDzǽ ǾǿǷǿǯȈǴǼǷǴ Ȁǽ ȀȁǯDZǺȎǴȁ ǴdzǷǼǷȅ DZ ȀǴǹȂǼdzȂ
ǒǺǯDZǯ ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷǻǯȅǷȎ DZ ;$0/
113
ǙǯǵdzȊǸ ǷǶ ȌȁǷȄ ǾǴǿǴȄǽdzǽDZ ǻǽǵǴȁ ǰȊȁȋ ǽǾǿǴdzǴǺǴǼ ǿȎdzǽǻ ǾǿǽǻǴǵȂȁǽȆǼȊȄ ȌȁǯǾǽDZ ǼǯǶȊDZǯǴǻȊȄ ǹǺȍȆǴ DZȊǻǷ ǹǯdzǿǯǻǷ(key frames ǓǺȎ ǷǶǻǴǼǴǼǷȎ ǺǷǼǴǸǼǽDzǽ ǾǽDZǴdzǴǼǷȎ ǯǼǷǻǯȅǷǷ ǽȁ ǼǯȆǯǺȋǼǽDzǽ ȀDZǽǸȀȁDZǯ ǹ ǹǽǼǴȆǼǽǻȂ ǷȀǾǽǺȋǶȂǴȁȀȎ ǽdzǷǼ ǷǺǷ ǰǽǺǴǴ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ ǖǯȁǴǻ ǶǯdzǯǴȁȀȎ ǹǯǹǽǸ ȀȁǷǺȋ ǯǼǷǻǯȅǷǷ dzǽǺǵǴǼ ǰȊȁȋ ǾǿǷǻǴǼǴǼ ǻǴǵdzȂ ǿǯǶǺǷȆǼȊǻǷ ȁǽȆǹǯǻǷ ǙǺȍȆǴDZȊǴ ǹǯdzǿȊ ǽǾǿǴdzǴǺȎȍȁȀȎ Ȁ ǾǽǻǽȈȋȍ ǽǾǽǿǼȊȄ ǻǽǻǴǼȁǽDZ (key times Ǭȁǽ ǻǽǻǴǼȁȊ ǶǯdzǯDZǯǴǻȊǴ ǽȁǼǽȀǷȁǴǺȋǼǽ ǼǯȆǯǺǯ ǯǼǷǻǯȅǷǷ Ƿ ǽǾǿǴdzǴǺȎȍȈǷǴ DZǿǴǻȎ ǽǹǽǼȆǯǼǷȎ ǹǺȍȆǴDZǽDzǽ ǹǯdzǿǯ Ǘȁǯǹ ǾǿǴdzȀȁǯ DZǷǻ Ȇȁǽ ǼǴǽǰȄǽdzǷǻǽ ȀǽǶdzǯȁȋ ǯǼǷǻǯȅǷȍ ǾǿǽdzǽǺǵǷȁǴǺȋǼǽȀȁȋȍ ȀǴǹȂǼdz Ȁ ȁǿǴǻȎ ǹǺȍȆǴDZȊǻǷ ǹǯdzǿǯǻǷ ǿǯȀǾǽǺǽǵǴǼǼȊǻǷ ȆǴǿǴǶ ǿǯDZǼȊǴ ǾǿǽǻǴǵȂȁǹǷ DZǿǴǻǴǼǷ dzǿȂDz ǽȁ dzǿȂDzǯ ǞǴǿDZȊǸ ǹǺȍȆǴDZǽǸ ǹǯdzǿ ǻǽǵǼǽ Ƕǯdzǯȁȋ DZ ǹǽǼȅǴ ȁǿǴȁȋǴǸ ȀǴǹȂǼdzȊ DZȁǽǿǽǸ ² DZ ǹǽǼȅǴ ȇǴȀȁǽǸ Ƿ ȁǿǴȁǷǸ ² DZ ǹǽǼȅǴ dzǴDZȎȁǽǸ (0:0:9 ǑȊ ǼǴ ǶǯdzǯǴȁǴ ǾǿǽdzǽǺǵǷȁǴǺȋǼǽȀȁȋ ǽǾǽǿǼǽDzǽ ǻǽǻǴǼȁǯ DZȊ ǶǯdzǯǴȁǴ DZǿǴǻȎ ǽǹǽǼȆǯǼǷȎ ǹǯǵdzǽDzǽ ǹǺȍȆǴDZǽDzǽ ǹǯdzǿǯ Ǒ ǹǯȆǴȀȁDZǴ ǴȈǴ ǽdzǼǽDzǽ ǾǿǷǻǴǿǯ DZǽǶȋǻǴǻ ǯǼǷǻǯȅǷȍ ǽǰȉǴǹȁǽDZ ȁǷǾǯ Double Ȁ ǿǯǶdzǴǺǴǼǷǴǻ ǾǿǽǻǴǵȂȁǹǯ 100 ² Ǽǯ dzDZǴ ǿǯDZǼȊǴ ȆǯȀȁǷ ǏǼǷǻǯȅǷȎ dzǽǺǵǼǯ dzDZǷDzǯȁȋȀȎ ǽȆǴǼȋ ǰȊȀȁǿǽ ǾǴǿDZȂȍ ǾǽǺǽDZǷǼȂ ǾȂȁǷ Ƿ ǽȆǴǼȋ ǻǴdzǺǴǼǼǽ DZȁǽǿȂȍ ǾǽǺǽDZǷǼȂ ǑȀǴ ǾǴǿǴǻǴȈǴǼǷǴ dzǽǺǵǼǽ ǶǯǼȎȁȋ ȀǴǹȂǼdz ǞǽȀǹǽǺȋǹȂ ȀǿǴdzǼǴǸ ȁǽȆ ǹǽǸ ǻǴǵdzȂ Ƿ ȎDZǺȎǴȁȀȎ ǼǯȆǯǺǽ ǹǺȍȆǴDZǽDzǽ ǹǯdzǿǯ ǽǾǿǴdzǴǺȎǴǻ DZ ȁǽȆǹǴ ǢǹǯǶȊDZǯǴǻ Ȇȁǽ ǾǴǿǴǻǴȈǴǼǷǴ ǷǶ ǼǯȆǯǺȋǼǽǸ ȁǽȆǹǽǸ DZ ȀǿǴdzǼȍȍ ȁǽȆǹȂ dzǽǺǵǼǽ ǶǯǼȎȁȋ ȀǴǹȂǼdzȂ ǷȀǾǽǺȋǶȂȎ ǽǾǽǿǼȊǸ ǻǽǻǴǼȁ ǖǯȁǴǻ ǶǯdzǯǴǻ ǾǿǽdzǽǺǵǷȁǴǺȋǼǽȀȁȋ ǾǴǿǴǻǴȈǴǼǷȎ ǷǶ ȀǿǴdzǼǴǸ ȁǽȆǹǷ DZ ǹǽǼǴȆǼȂȍ ȁǽȆǹȂ ǿǯDZ ǼȊǻ ȀǴǹȂǼdzǯǻ ǷȀǾǽǺȋǶȂȎ DZȁǽǿǽǸ ǽǾǽǿǼȊǸ ǻǽǻǴǼȁ 0:0:6. ǡǴǾǴǿȋ ȌǺǴǻǴǼȁ ǰȂdzǴȁ ǻDzǼǽDZǴǼǼǽ ǾǴǿǴȀǹǯ ǹǷDZǯȁȋ ǷǶ ǼǯȆǯǺȋǼǽǸ DZ ȀǿǴdzǼȍȍ ȁǽȆǹȂ Ƿ ǶǯȁǴǻ ǻǴdzǺǴǼǼǽ ǾǿǽȄǽdzǷȁȋ ǽȀȁǯǺȋǼȂȍ ȆǯȀȁȋ ǾȂȁǷ Ǒ ǾǿǴdzȊdzȂȈǴǻ ǾǿǷǻǴǿǴ ǽǰǯ ȀǴDzǻǴǼȁǯ ǯǼǷǻǯȅǷǷ ǷȀǾǽǺȋǶȂȍȁ ǺǷǼǴǸǼȂȍ ǷǼȁǴǿǾǽǺȎȅǷȍ ǓǺȎ ǽǰǴȀǾǴȆǴ ǼǷȎ dzǽǾǽǺǼǷȁǴǺȋǼǽǸ DzǷǰǹǽȀȁǷ ȀȂȈǴȀȁDZȂǴȁ ǴȈǴ dzDZǯ ȁǷǾǯ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ ǹǺȍȆǴDZǽǸ ǹǯdzǿ dzǷȀǹǿǴȁǼǽǸ ǯǼǷǻǯȅǷǷ ǹǽȁǽǿȊǸ ǻDzǼǽDZǴǼǼǽ ©ǾǴǿǴǰǿǯȀȊDZǯǴȁª ǶǼǯȆǴǼǷǴ ǽȁ ǽdzǼǽDzǽ ǶǼǯȆǴǼǷȎ ǹ dzǿȂDzǽǻȂ Ƿ ǹǺȍȆǴDZǽǸ ǹǯdzǿ ȀDzǺǯǵǴǼǼǽǸ ǯǼǷǻǯȅǷǷ ǹǽȁǽǿȊǸ ǽǰǴȀǾǴȆǷDZǯǴȁ ǾǺǯDZǼǽǴ ǷǶǻǴǼǴǼǷǴ ǶǼǯȆǴǼǷȎ ǷȀǾǽǺȋǶȂȎ dzǺȎ ǽǾǿǴ dzǴǺǴǼǷȎ ǷǼȁǴǿǾǽǺȎȅǷǷ ǹǿǷDZȂȍ DZȁǽǿǽDzǽ ǾǽǿȎdzǹǯ Ǒ ȀǺǴdzȂȍȈǷȄ ǿǯǶdzǴǺǯȄ ǰȂdzǴȁ ǿǯȀȀǻǽȁǿǴǼǽ ǽǾǷȀǯǼǷǴ ǯǼǷǻǯȅǷǷ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ dzǺȎ ǽǰȉǴǹȁǽDZ ȁǷǾǯ Double ǏǼǯǺǽDzǷȆǼȊǴ ǾǿǷǼȅǷǾȊ ǾǿǷǻǴǼȎȍȁȀȎ dzǺȎ ǯǼǷǻǯȅǷǷ Point Ƿ Color.) Ǒ ǼǯǷǻǴǼǽDZǯǼǷȎȄ ȁǷǾǽDZ ǯǼǷǻǯȅǷǷ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ ǷȀǾǽǺȋǶȂǴȁȀȎ ǾǽȀȁȃǷǹȀ UsingKeyFrames Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ ǡǽ ǴȀȁȋ dzǺȎ ǽǾǷȀǯǼǷȎ ǯǼǷǻǯȅǷǷ ǽǰȉǴǹȁǽDZ ȁǷǾǯ Double Ȁ ǹǺȍȆǴDZȊǻǷ ǹǯdzǿǯǻǷ ǰȂdzǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ȁǷǾ DoubleAnimationUsingKeyFrames dzǺȎ ǹǽȁǽǿǽDzǽ ǰȂdzȂȁ ǶǯdzǯǼȊ ȅǴǺȋ Ƿ ȀDZǽǸȀȁDZǽ ȁǽȆǼǽ ȁǯǹ ǵǴ ǹǯǹ Ȍȁǽ dzǴǺǯǺǽȀȋ dzǺȎ DoubleAnimation). DoubleAnimationUsingKeyFrames DZǹǺȍȆǯǴȁ ǽǾǷȀǯǼǷȎ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ Ǘ ǹǯǹ Ȏ ȂǵǴ DzǽDZǽǿǷǺ ȁǽ ǵǴ ȀǯǻǽǴ ǹǯȀǯǴȁȀȎ PointAnimationUsingKeyFrames Ƿ ColorAnimationUsingKeyFrames.)
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǺǷǼǴǸǼȊȄ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ ǠȁǯǼdzǯǿȁǼȊǻ ǻǴȁǽdzǽǻ ǯǼǷǻǯȅǷǷ ǷǶǻǴǼǴǼǷȎ ǶǼǯȆǴǼǷǸ ȀDZǽǸȀȁDZǯ ȎDZǺȎǴȁȀȎ ǺǷǼǴǸǼǯȎ ǷǼȁǴǿǾǽǺȎȅǷȎ ǾǿǷ ǹǽȁǽǿǽǸ ǽǰȈǯȎ DZǴǺǷȆǷǼǯ ǷǶǻǴǼǴǼǷȎ ǿǯDZǼǽǻǴǿǼǽ ǿǯȀǾǿǴdzǴǺȎǴȁȀȎ Ǿǽ DZǿǴǻǴǼǷ ǽȁDZǴdzǴǼǼǽǻȂ Ǽǯ ǷǶǻǴ ǼǴǼǷǴ ǓǿȂDzǽǸ ȀǾǽȀǽǰ ² ǽǾǿǴdzǴǺǴǼǷǴ ǺǷǼǴǸǼȊȄ ȇǯDzǽDZ ǻǴǵdzȂ ǹǯdzǿǯǻǷ Ȁ ǾǽǻǽȈȋȍ LinearKeyFrame ǚǷ ǼǴǸǼȊǸ ǹǺȍȆǴDZǽǸ ǹǯdzǿ DZ ǹǽȁǽǿǽǻ ǷȀǾǽǺȋǶȂǴȁȀȎ DZȀǴ ȁǯ ǵǴ ǺǷǼǴǸǼǯȎ ǷǼȁǴǿǾǽǺȎȅǷȎ Ǽǽ ǻǴǵdzȂ ǹǺȍȆǴ DZȊǻǷ ǹǯdzǿǯǻǷ ǾǽȌȁǽǻȂ ǻǽǵǼǽ ȀǽǶdzǯDZǯȁȋ ȌȃȃǴǹȁȊ ȂȀǹǽǿǴǼǷȎǶǯǻǴdzǺǴǼǷȎ ǟǯȀȀǻǽȁǿǷǻ ȀǺǴdzȂȍȈǷǸ ǾǿǷǻǴǿ ǯǼǷǻǯȅǷǷ. Ǒ ǼǴǻ ǷȀǾǽǺȋǶȂǴȁȀȎ DoubleAnimationUsingKeyFrames. Ǒ Ȍȁǽǻ ȀǺȂȆǯǴ ǽǾǿǴdzǴǺȎȍȁȀȎ dzDZǯ ǹǺȍȆǴDZȊȄ ǹǯdzǿǯ. ǝdzǷǼ ǹǯdzǿ ǽǾǷȀȊDZǯǴȁ ǺǷǼǴǸǼȂȍ ǷǼȁǴǿǾǽǺȎȅǷȍ dzǺȎ ǷǶǻǴ ǼǴǼǷȎ Canvas.Left ǽȁ dzǽ Ƕǯ ȀǴǹȂǼdzȂ DZȁǽǿǽǸ ² ǺǷǼǴǸǼȂȍ ǷǼȁǴǿǾǽǺȎȅǷȍ dzǺȎ ǷǶǻǴǼǴǼǷȎ Canvas.Left ǽȁ dzǽ Ƕǯ ȀǴǹȂǼdz Ǒ ǿǴǶȂǺȋȁǯȁǴ ȀǽǶdzǯǴȁȀȎ ȌȃȃǴǹȁ ǰȊȀȁǿǽDzǽ ǾǴǿǴǻǴȈǴǼǷȎ ǾǿȎǻǽȂDzǽǺȋ ǼǷǹǯ DZ ǾǴǿDZǽǸ ǾǽǺǽDZǷǼǴ ǾȂȁǷ Ƿ ǻǴdzǺǴǼǼǽDzǽ dzDZǷǵǴǼǷȎ DZǽ DZȁǽǿǽǸ ǏǼǯǺǽDzǷȆǼȊǴ ǾǿǷǼȅǷǾȊ ǾǿǷǻǴǼȎȍȁ ȀȎ dzǺȎ LinearPointKeyFrame Ƿ LinearColorKeyFrame.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ dzǷȀǹǿǴȁǼǽǸ ǯǼǷǻǯȅǷǷ ǔȀǺǷ ǼǴǽǰȄǽdzǷǻǽ ǷǶǻǴǼǷȁȋ ȀDZǽǸȀȁDZǽ ǽȁ ǽdzǼǽDzǽ ǶǼǯȆǴǼǷȎ ǹ dzǿȂDzǽǻȂ Ǽǽ ǰǴǶ ǾǿǷǻǴǼǴǼǷȎ ǺǷǼǴǸǼǽǸ ǷǼ ȁǴǿǾǽǺȎȅǷǷ ǻǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ ǹǺȍȆǴDZǽǸ ǹǯdzǿ dzǷȀǹǿǴȁǼǽǸ ǯǼǷǻǯȅǷǷ ǝǼ ǶǯȀȁǯDZǷȁ ǽǰȉǴǹȁ ©ǾǴǿǴȀǹǽ ȆǷȁȋª Ǽǯ ǶǯdzǯǼǼǽǴ ǶǼǯȆǴǼǷǴ DZ ǶǯdzǯǼǼǽǴ DZǿǴǻȎ ǹǺȍȆǴDZǽDzǽ ǹǯdzǿǯ ǓǯǺǴǴ ǾǽǹǯǶǯǼ ȁǽȁ ǵǴ ǾǿǷǻǴǿ Ȇȁǽ ǰȊǺ ǾǿǴdzȀȁǯDZǺǴǼ DZȊȇǴ Ǽǽ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǹǺȍȆǴDZǽDzǽ ǹǯdzǿǯ dzǷȀǹǿǴȁǼǽǸ ǯǼǷǻǯȅǷǷ ǖǯ ȀǴǹȂǼdzȂ ǯǼǷǻǯȅǷǷ ǾǿȎǻǽȂDzǽǺȋǼǷǹ ǾǴǿǴǾǿȊDzǼǴȁ ǾǽǺǾȂȁǷ Ǽǯ ȌǹǿǯǼǴ ǝȀȁǯǺȋǼȊǴ ȀǴǹȂǼdz ǯǼǷǻǯȅǷǷ ǽǼ ǰȂdzǴȁ ǾǿǽȄǽdzǷȁȋ ǽȀȁǯDZȇǷǸȀȎ ǽȁǿǴǶǽǹ ǾȂȁǷ
ǏǼǯǺǽDzǷȆǼȊǴ ǾǿǷǼȅǷǾȊ ǾǿǷǻǴǼȎȍȁȀȎ dzǺȎ DiscretePointKeyFrame Ƿ DiscreteColorKeyFrame.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǹǺȍȆǴDZȊȄ ǹǯdzǿǽDZ ȀDzǺǯǵǴǼǼǽǸ ǯǼǷǻǯȅǷǷ ǓǺȎ ǷǶǻǴǼǴǼǷȎ ȀDZǽǸȀȁDZǯ ǽȁ ǽdzǼǽDzǽ ǶǼǯȆǴǼǷȎ ǹ dzǿȂDzǽǻȂ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǼǴǺǷǼǴǸǼǽ ǷǶǻǴǼȎǴǻǽDzǽ ǶǼǯȆǴǼǷȎ ǽǰǴȀǾǴȆǷDZǯȍȈǷǻ ȂȀǹǽǿǴǼǷǴ Ƿ ǶǯǻǴdzǺǴǼǷǴ ǾǿǷǻǴǼȎǴȁȀȎ ǹǺȍȆǴDZǽǸ ǹǯdzǿ ȀDzǺǯǵǴǼǼǽǸ ǯǼǷǻǯ ȅǷǷ ǓǺȎ ȌȁǽDzǽ ǶǯdzǯǴȁȀȎ ǹDZǯdzǿǯȁǷȆǴȀǹǯȎ ǹǿǷDZǯȎ ǐǴǶȋǴ ǡǽDzdzǯ ȀǹǽǿǽȀȁȋ ǷǶǻǴǼǴǼǷȎ ȀDZǽǸȀȁDZǯ ǽȁ ǽdzǼǽDzǽ ǶǼǯȆǴǼǷȎ ǹ dzǿȂDzǽǻȂ ǽǾǿǴdzǴǺȎǴȁȀȎ ǾǯǿǯǺǺǴǺȋǼǽǸ ǾǿǽǴǹȅǷǴǸ ȌȁǽǸ ǹǿǷDZǽǸ ǦȁǽǰȊ ǾǿǴdzȀȁǯDZǷȁȋ Ȍȁǽ DZǽǶȋǻǴǻ ǼǯDzǺȎdzǼȊǸ ǾǿǷǻǴǿ ȀǽǺǼȅǴ ȀȁǽǷȁ ǾǿȎǻǽ Ǽǯdz DzǽǺǽDZǽǸ DZȊ ǾǽȀȊǺǯǴȁǴ ȃȂȁǰǽǺȋǼȊǸ ǻȎȆ DZ dzǯǺȋǼȍȍ ȆǯȀȁȋ ǾǽǺȎ. ǞǿǽȀǺǴdzǷȁǴ Ƕǯ ȁǴǼȋȍ ǻȎȆǯ. Ǟǽǹǯ ǽǼ ǺǴȁǷȁ DZDZǴǿȄ ǹǯǵǴȁȀȎ Ȇȁǽ ȁǴǼȋ dzDZǷǵǴȁȀȎ Ȁ ȂȀǹǽǿǴǼǷǴǻ ǙǽDzdzǯ ǽǼ dzǽȀȁǷDzǯǴȁ DZǴǿȄǼǴǸ ȁǽȆǹǷ ȁǴǼȋ ǶǯǻǴdzǺȎǴȁ Ȅǽdz ǙǽDzdzǯ ǻȎȆ ǼǯȆǷǼǯ Ǵȁ Ǿǯdzǯȁȋ ȀǹǽǿǽȀȁȋ ȁǴǼǷ ǽǾȎȁȋ ǼǯȆǷǼǯǴȁ DZǽǶǿǯȀȁǯȁȋ dzǽ ȁǴȄ Ǿǽǿ Ǿǽǹǯ ǻȎȆ ǼǴ ȂǾǯdzǴȁ Ǽǯ ǶǴǻǺȍ ǡǴǾǴǿȋ ǾǿǴdzȀȁǯDZȋȁǴ Ȇȁǽ DZǯȇǯ ǯǼǷǻǯȅǷȎ ² Ȍȁǽ ȁǴǼȋ ǻȎȆǯ ǯ ǾǺǯDZǼǯȎ ǺǷǼǷȎ ² Ȍȁǽ ȁǿǯǴǹȁǽǿǷȎ ǻȎȆǯ ǡǿǯǴǹ ȁǽǿǷȎ, ǾǺǯDZǼǯȎ ǺǷǼǷȎ ǷǺǷ ȀǾǺǯǸǼ ǽǾǷȀȊDZǯǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ KeySpline (ǝǾǽǿǼǯȎ ȀDzǺǯǵǴǼǼǯȎ ǺǷǼǷȎ KeySpline ǽǾǿǴdzǴǺȎǴȁ ǽǾǽǿǼȊǴ ȁǽȆǹǷ ǹDZǯdzǿǯȁǷȆǴȀǹǽǸ ǹǿǷDZǽǸ ǐǴǶȋǴ ǙǿǷDZǯȎ ǼǽǿǻǯǺǷǶǽDZǯǼǯ, ȁǯǹ Ȇȁǽ ǾǴǿDZǯȎ ȁǽȆǹǯ ǹǿǷDZǽǸ ǼǯȄǽdzǷȁȀȎ DZ 0, DZȁǽǿǯȎ ² DZ 1. ǓǺȎ ǽǾǷȀǯǼǷȎ ǾǯǿǯǰǽǺǷȆǴȀǹǽǸ dzȂDzǷ ǷǻǴǼǼǽ Ǿǽ ȁǯǹǽǸ ȁǿǯǴǹȁǽǿǷǷ ǾǯdzǯǴȁ ǻȎȆ KeySpline ǰȂdzǴȁ DZǹǺȍȆǯȁȋ dzDZǯ ǼǽǿǻǯǺǷǶǽDZǯǼǼȊȄ ǶǼǯȆǴǼǷȎ ȆǴǿǴǶ ǶǯǾȎȁȂȍ ǝǾǷȀǯȁȋ ǹǿǷDZȂȍ Ǿǽ ǹǽȁǽǿǽǸ dzDZǷDzǯǴȁȀȎ ǻȎȆ ǻǽǵǼǽ Ȁ ǾǽǻǽȈȋȍ ȀDzǺǯǵǴǼǼǽǸ ǺǷǼǷǷ ǷȀǾǽǺȋǶȂȎ KeySpline, ǼǯǾǿǷǻǴǿ 0.3,0 0.6,1 ǖdzǴȀȋ ǶǯdzǯǴȁȀȎ ǾǴǿDZǯȎ (0.3,0 Ƿ DZȁǽǿǯȎ 0.6,1 ȁǽȆǹǷ ǹǿǷDZǽǸ Ǒ ǿǴǶȂǺȋȁǯȁǴ ǰȂdzǴȁ ȀǽǶdzǯǼ ȌȃȃǴǹȁ ǰȊȀȁǿǽDzǽ ȂȀǹǽǿǴǼǷȎ ǯǼǷǻǯȅǷǷ DZ ǾǴǿDZǽǸ ȁǿǴȁǷ ǾȂȁǷ ǶǯȁǴǻ ǾǴǿǴǻǴȈǴǼǷǴ ǰȂdzǴȁ ǾǿǽǷȀȄǽ dzǷȁȋ Ȁ ǾǽȀȁǽȎǼǼǽǸ ȀǹǽǿǽȀȁȋȍ dzǽ ǾǿǽȄǽǵdzǴǼǷȎ ǾǿǷǻǴǿǼǽ dzDZȂȄ ȁǿǴȁǴǸ ȁǿǯǴǹȁǽǿǷǷ ǻȎȆǯ Ƿ ǶǯȁǴǻ ǽȀȁǯDZ ȇȂȍȀȎ ȆǯȀȁȋ ǾȂȁǷ dzDZǷǵǴǼǷǴ ǰȂdzǴȁ ǶǯǻǴdzǺȎȁȋȀȎ ǷǻǷȁǷǿȂȎ ǾǯdzǴǼǷȎ ǻȎȆǯ Ǽǯ ǶǴǻǺȍ
ǒǺǯDZǯ ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷǻǯȅǷȎ DZ ;$0/
115
ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ ǷȀǾǽǺȋǶǽDZǯǼǷȎ KeySpline dzǺȎ ǽǾǷȀǯǼǷȎ ȀDzǺǯǵǴǼǼǽǸ ǹǿǷDZǽǸ ǾǿǷ ǻǽdzǴǺǷǿǽ DZǯǼǷǷ ȁǯǹǽDzǽ dzDZǷǵǴǼǷȎ Ȁ ǾǽǻǽȈȋȍ ǯǼǷǻǯȅǷǷ DoubleAnimationUsingKeyFrames:
Ǒ Ȍȁǽǻ ǾǿǷǻǴǿǴ DZȊǾǽǺǼȎǴȁȀȎ ǯǼǷǻǯȅǷȎ ȌǺǺǷǾȀǯ ǔDzǽ ǾǴǿǴǻǴȈǴǼǷǴ Ǿǽ ȌǹǿǯǼȂ ǻǽdzǴǺǷǿȂǴȁ dzDZǷǵǴǼǷǴ ȁǴǼǷ ǻȎȆǯ ǴȀǺǷ ȀǻǽȁǿǴȁȋ Ǽǯ ǼǴǴ ȀDZǴǿȄȂ.
ǏǼǷǻǯȅǷȎ Ƿ Expression Blend ǏǼǷǻǯȅǷȍ ǻǽǵǼǽ ȀǽǶdzǯDZǯȁȋ DzǿǯȃǷȆǴȀǹǷ DZ Expression Blend. ǝǼ ȃǽǿǻǷǿȂǴȁ Ƕǯ DZǯȀ XAML-ǹǽdz ǾǿǷǻǴǼȎȎ ǿǯǶǺǷȆǼȊǴ ȁǷǾȊ ǯǼǷǻǯȅǷǷ ǯDZȁǽǻǯȁǷȆǴȀǹǷ Ǒ Blend dzǺȎ ȀǯǸȁǯ ȀǽǶdzǯǼǼǽDzǽ dzǺȎ 6LOYHUOLJKW DZȊǰǴǿǷȁǴ DZ ǻǴǼȍ Window ǾȂǼǹȁ Animation Workspace ǟǯǰǽȆǯȎ ǽǰǺǯȀȁȋ ǯǼǷǻǯȅǷǷ ǞǿǷ Ȍȁǽǻ ǽȁǹǿǽȍȁȀȎ ǷǼȀȁǿȂǻǴǼȁȊ dzǺȎ DzǿǯȃǷȆǴȀǹǽDzǽ ǾǿǽǴǹȁǷǿǽDZǯǼǷȎ DZǿǴǻǴǼǼȊȄ ȇǹǯǺ ǞǿǷ ǿǴdzǯǹȁǷǿǽDZǯǼǷǷ ȀDZǽǸȀȁDZ ǹǽȁǽǿȊǴ dzǽǺǵǼȊ ǻǴǼȎȁȋȀȎ ǷȀǾǽǺȋǶȂȎ DZǷǶȂǯǺȋǼȊǸ ǿǴ dzǯǹȁǽǿ ǰȂdzǴȁ ȃǽǿǻǷǿǽDZǯȁȋȀȎ XAML-ǹǽdz ǯǼǷǻǯȅǷǷ Ǭȁǽ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 5-11. ǑǼǷǶȂ ȌǹǿǯǼǯ ǾǿǴdzȀȁǯDZǺǴǼǯ ǾǯǼǴǺȋ Objects And Timeline Ǒ ǼǴǸ ǻǽǵǼǽ dzǽǰǯDZǷȁȋ DZǿǴǻǴǼǼȂȍ ȇǹǯǺȂ Ƿ Ƕǯ ȁǴǻ DZǷǶȂǯǺȋǼǽ DZDZǽdzǷȁȋ ǹǺȍȆǴDZȊǴ ǹǯdzǿȊ ǦȁǽǰȊ dzǽǰǯDZǷȁȋ ǼǽDZȂȍ DZǿǴǻǴǼǼȂȍ ȇǹǯǺȂ ȈǴǺǹǼǷȁǴ ǹǼǽǾǹȂ Ǽǯ ǾǯǼǴǺǷ Objects And Timeline ǿǷȀ 5-12).
ǟǗǠ 5 11 Expression Blend DZ ǿǴǵǷǻǴ Animation Workspace.
116
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǟǗǠ 5 12 ǓǽǰǯDZǺǴǼǷǴ ǼǽDZǽǸ DZǿǴǻǴǼǼǽǸ ȇǹǯǺȊ.
ǔȀǺǷ ȈǴǺǹǼȂȁȋ ǹǼǽǾǹȂ ǽȁǹǿǽǴȁȀȎ dzǷǯǺǽDzǽDZǽǴ ǽǹǼǽ DZ ǹǽȁǽǿǽǻ ǰȂdzǴȁ ǾǿǴdzǺǽǵǴǼǽ DZDZǴȀȁǷ ǷǻȎ ȀǽǶdzǯ DZǯǴǻǽǸ ǿǯȀǹǯdzǿǽDZǹǷ ǓǷǯǺǽDz Create Storyboard ǠǽǶdzǯǼǷǴ ǿǯȀǹǯdzǿǽDZǹǷ ǾǽǹǯǶǯǼ Ǽǯ ǿǷȀ 5- Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ Ȏ ǷǶǻǴǼǷǺ ǾǿǴdzǺǯDzǯǴǻǽǴ Ǿǽ ȂǻǽǺȆǯǼǷȍ ǷǻȎ Storyboard1 Ǽǯ Timeline1 Ƿ ȂǰǿǯǺ ȃǺǯǵǽǹ Create As Resource ǠǽǶdzǯȁȋ ǹǯǹ ǿǴȀȂǿȀ
ǟǗǠ 5 13 ǠǽǶdzǯǼǷǴ ǿǯȀǹǯdzǿǽDZǹǷ.
ǞǿǷ ǷȀǾǽǺȋǶǽDZǯǼǷǷ Blend dzǺȎ ȀǯǸȁǯ dzǺȎ Silverlight 1 ǯǼǷǻǯȅǷȍ ǻǽǵǼǽ ȀǽǶdzǯDZǯȁȋ Ǽǯ ȂǿǽDZǼǴ Canvas ǷǺǷ ǹǯǹ Resource ǟǴȀȂǿȀ Ǒ ǾǴǿDZǽǻ ȀǺȂȆǯǴ ǯǼǷǻǯȅǷǷ ǶǯǾȂȀǹǯȍȁȀȎ DZ ǽȁDZǴȁ Ǽǯ ȁǿǷDzDzǴǿȊ ǿǯȀǾǽǺǯDzǯȍȈǷǴȀȎ Ǽǯ ȄǽǺȀȁǴ ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ XAML ȀǽǶdzǯǼǼǽDzǽ Blend ǷǶ dzǷǯǺǽDzǽDZǽDzǽ ǽǹǼǯ Create Storyboard DZ ǹǽȁǽǻ ǾǽǺȋǶǽDZǯȁǴǺȋ ǽǰǽǶǼǯȆǷǺ Ȇȁǽ ǼǴ ȄǽȆǴȁ ȀǽǶdzǯDZǯȁȋ ǯǼǷǻǯȅǷȍ ǹǯǹ Resource:
ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ ǴȀǺǷ ǰȊ ǾǽǺȋǶǽDZǯȁǴǺȋ ȂȀȁǯǼǽDZǷǺ ȃǺǯǵǽǹ Create As Resource ǿǷȀ 5-13), Storyboard ǰȊǺ ǰȊ ȀǽǶdzǯǼ DZ Ƿ ǴDzǽ ǾǿǷȇǺǽȀȋ ǰȊ ǶǯǾȂȀǹǯȁȋ ǷǶ JavaScript. Ǒ ǾǿǷǺǽǵǴǼǷǷ dzǺȎ 6LOYHUOLJKW ǯǼǷǻǯȅǷȎ ȀǿǯǶȂ ȀǽǶdzǯǴȁȀȎ ǹǯǹ ǿǴȀȂǿȀ ǐǽǺǴǴ ǾǽdzǿǽǰǼǽ ǽȀȁǯǼǽDZǷǻȀȎ Ǽǯ Ȍȁǽǻ DZ ǒǺǯDZǴ 6. ǞǿǴdzȀȁǯDZǺǴǼǷǴ Objects And Timeline ǷǶǻǴǼǷȁȀȎ, DZ ǼǴǻ ǰȂdzǴȁ ǽȁǽǰǿǯǵǴǼǯ ȁǽǺȋǹǽ Ȇȁǽ ȀǽǶdzǯǼǼǯȎ DZǿǴǻǴǼ ǼǯȎ ȇǹǯǺǯ. Ǭȁǽ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 5-14.
ǟǗǠ 5 14 ǞǯǼǴǺȋ Objects And Timeline Ȁ ǼǽDZǽǸ DZǿǴǻǴǼǼǽǸ ȇǹǯǺǽǸ.
ǜǯ ǿǷȀ 5- DZǴǿȁǷǹǯǺȋǼǯȎ ǺǷǼǷȎ Ǽǯ ǼȂǺǴDZǽǸ ǽȁǻǴȁǹǴ DZǿǴǻǴǼǷ ǽǰǽǶǼǯȆǯǴȁ ȁǴǹȂȈǴǴ DZǿǴǻȎ Ǒ Blend Ȍȁǯ ǺǷǼǷȎ ǰȂdzǴȁ ǵǴǺȁǽǸ ǦȁǽǰȊ dzǽǰǯDZǷȁȋ ǹǺȍȆǴDZǽǸ ǹǯdzǿ ǾǿǽȀȁǽ ǾǴǿǴȁǯȈǷȁǴ ȌȁȂ ǺǷǼǷȍ Ǽǯ ȁǽȁ ǻǽǻǴǼȁ ǹȂ dzǯ ǼǴǽǰȄǽdzǷǻǽ DZȀȁǯDZǷȁȋ ǹǺȍȆǴDZǽǸ ǹǯdzǿ Ƿ ȈǴǺǹǼǷȁǴ ǹǼǽǾǹȂ Record Keyframe ǖǯǾǷȀǯȁȋ ǹǺȍȆǴDZǽǸ ǹǯdzǿ Ǭȁǯ ǹǼǽǾǹǯ ǼǯȄǽdzǷȁȀȎ ȀǿǯǶȂ Ǽǯdz DZǿǴǻǴǼǼǽǸ ȇǹǯǺǽǸ ȀǺǴDZǯ ǽȁ 0:00:000 Ǽǯ ǿǷȀ 5-14.
ǒǺǯDZǯ ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷǻǯȅǷȎ DZ ;$0/
117
ǞǴǿǴȁǯȈǷȁǴ ǺǷǼǷȍ Ǽǯ -ȀǴǹȂǼdzǼȂȍ ǽȁǻǴȁǹȂ Ƿ dzǽǰǯDZȋȁǴ ǹǺȍȆǴDZǽǸ ǹǯdzǿ ǓǽǰǯDZǺǴǼǼȊǸ ǹǺȍȆǴDZǽǸ ǹǯdzǿ ǰȂdzǴȁ ǽȁǽǰǿǯǵǯȁȋȀȎ ǹǯǹ ǼǴǰǽǺȋȇǽǸ ǽDZǯǺ Ǽǯ DZǿǴǻǴǼǼǽǸ ȇǹǯǺǴ ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 5-15.
ǟǗǠ 5 15 ǓǽǰǯDZǺǴǼǷǴ ǹǺȍȆǴDZǽDzǽ ǹǯdzǿǯ.
ǢȀȁǯǼǽDZǷDZ DZǿǴǻǴǼǼȂȍ ȇǯǹǯǺȂ Ǽǯ ǽȁǻǴȁǹȂ ȀǴǹȂǼdzȊ Ƿ dzǽǰǯDZǷDZ ǹǺȍȆǴDZǽǸ ǹǯdzǿ ǻǽǵǼǽ ǾǴǿǴǸȁǷ ǹ ǿǴ dzǯǹȁǷǿǽDZǯǼǷȍ ȅDZǴȁǯ ǻǴȀȁǽǾǽǺǽǵǴǼǷȎ ǾǿǽǶǿǯȆǼǽȀȁǷ ǷǺǷ ȃǽǿǻȊ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ Blend Ȁǯǻ ǾǿǽDZǴdzǴȁ ȀǽǽȁDZǴȁȀȁDZȂȍȈǷǴ DZȊȆǷȀǺǴǼǷȎ dzǺȎ ǽǰǺǴDzȆǴǼǷȎ ȀǽǶdzǯǼǷȎ ǯǼǷǻǯȅǷǷ Ǒ ǹǯȆǴȀȁDZǴ ǾǿǷǻǴǿǯ Ǽǯ ǿǷȀ 5- Ǿǽ ǹǯǶǯǼ ȁǽȁ ǵǴ ǾǿȎǻǽȂDzǽǺȋǼǷǹ Ȇȁǽ ǻȊ DZǷdzǴǺǷ Ǽǯ ǿǷȀ 5- Ǽǽ Ȁ ǷǶǻǴǼǴǼǼȊǻǷ ǶǯǺǷDZǹǽǸ Ƿ ǿǯǶǻǴǿǯǻǷ
ǟǗǠ 5 16 ǖǯdzǯǼǷǴ ǷǶǻǴǼǴǼǷǸ DZ ǹǺȍȆǴDZǽǻ ǹǯdzǿǴ.
ǑǴǿǽȎȁǼǽ DZȊ ǶǯǻǴȁǷǺǷ Ȇȁǽ ǴȀǺǷ ǾǴǿǴǻǴȈǯȁȋ ǷǼdzǷǹǯȁǽǿ DZǿǴǻǴǼǼǽǸ ȇǹǯǺȊ ǻǽǵǼǽ ǾǿǴdzDZǯǿǷȁǴǺȋǼǽ ǾǿǽȀǻǽȁǿǴȁȋ ǾǽǺȂȆǴǼǼȂȍ ǯǼǷǻǯȅǷȍ Ƿ ȂDZǷdzǴȁȋ ǹǯǹ ǽǼǯ DZȊDzǺȎdzǷȁ DZ ǹǯǵdzȊǸ ǽȁdzǴǺȋǼǽ DZǶȎȁȊǸ ǻǽǻǴǼȁ DZǿǴǻǴǼǷ ǜǯ ǿǷȀ 5- ǾǽǹǯǶǯǼǽ ǹǯǹ Ǽǯȇ ǾǿȎǻǽȂDzǽǺȋǼǷǹ DZȊDzǺȎdzǷȁ Ǽǯ DZȁǽǿǽǸ ȀǴǹȂǼdzǴ ǽǾǽǿǼǽDzǽ DZǿǴǻǴ ǼǷ ǓǺȎ ȌȁǽDzǽ ǻȊ ǾǿǽȀȁǽ ǾǴǿǴȁǯȈǷǺǷ ǵǴǺȁȂȍ DZǴǿȁǷǹǯǺȋǼȂȍ ǺǷǼǷȍ Ǽǯ ǽȁǻǴȁǹȂ ȀǴǹȂǼdzȊ ǜǷǵǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǽǺǼȊǸ XAML-ǹǽdz ȀȃǽǿǻǷǿǽDZǯǼǼȊǸ Blend ǾǿǷ ȀǽǶdzǯǼǷǷ ǯǼǷǻǯȅǷǷ DzǿǯȃǷȆǴȀǹǷǻǷ ȀǿǴdzȀȁDZǯǻǷ dzǺȎ ȀǯǸȁǯ dzǺȎ 6Llverlight 1:
118
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǒǺǯDZǯ ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷǻǯȅǷȎ DZ ;$0/
119
ǟǗǠ 5 17 ǞǿǴdzDZǯǿǷȁǴǺȋǼȊǸ ǾǿǽȀǻǽȁǿ ǯǼǷǻǯȅǷǷ.
ǖǯǹǺȍȆǴǼǷǴ Ǒ dzǯǼǼǽǸ DzǺǯDZǴ DZȊ ȂǶǼǯǺǷ ǹǯǹ DZ Silverlight XAML ǽǾǷȀȊDZǯȍȁȀȎ ȁǿǯǼȀȃǽǿǻǯȅǷǷ Ƿ ǯǼǷǻǯȅǷǷ ǐȊǺǷ ǾǿǴdz ȀȁǯDZǺǴǼȊ ǿǯǶǺǷȆǼȊǴ ȁǷǾȊ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ǷȀǾǽǺȋǶȂǴǻȊǴ dzǺȎ DZǿǯȈǴǼǷȎ ǷǶǻǴǼǴǼǷȎ ǿǯǶǻǴǿǽDZ ǷǺǷ Ǽǯ ǹǺǽǼǴǼǷȎ ǽǰȉǴǹȁǯ ǯ ȁǯǹǵǴ ǾǿǽǷǶDZǽǺȋǼȊǴ ȁǿǯǼȀȃǽǿǻǯȅǷǷ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǯȃȃǷǼǼǽǸ ǻǯȁǿǷȅȊ ǖǯ ȁǴǻ ǰȊǺǷ ǿǯȀȀǻǽȁǿǴǼȊ ǯǼǷǻǯȅǷǷ Ƿ ǷȄ ǶǯǾȂȀǹ Ȁ ǾǽǻǽȈȋȍ ȁǿǷDzDzǴǿǯ XAML ǞǽǹǯǶǯǼǽ ǹǯǹ ǯǼǷǻǯȅǷȎ ǻǴ ǼȎǴȁ ǶǼǯȆǴǼǷȎ ȀDZǽǸȀȁDZ Ȁǽ DZǿǴǻǴǼǴǻ Ƿ ǾǿǴdzȀȁǯDZǺǴǼȊ ȁǷǾȊ XAML ǾǽdzdzǴǿǵǷDZǯȍȈǷǴ ǯǼǷǻǯȅǷȍ ǶǼǯȆǴ ǼǷǸ double, point Ƿ color ǡǯǹǵǴ ǻȊ ǼǯȂȆǷǺǷȀȋ ǷȀǾǽǺȋǶǽDZǯȁȋ ǹǺȍȆǴDZȊǴ ǹǯdzǿȊ dzǺȎ ǰǽǺǴǴ ȁǽǼǹǽǸ Ǽǯ ȀȁǿǽǸǹǷ ǯǼǷǻǯȅǷǷ ǜǯǹǽǼǴȅ DZȊ ǾǽǶǼǯǹǽǻǷǺǷȀȋ Ȁǽ ȀǿǴdzȀȁDZǽǻ DzǿǯȃǷȆǴȀǹǽDzǽ ȀǽǶdzǯǼǷȎ ǯǼǷǻǯȅǷǷ Expression Blend Ƿ ȂDZǷdzǴǺǷ ǹǯǹ ǾǿǽȀȁǽ DZ Blend ȀǽǶdzǯDZǯȁȋ ǯǼǷǻǯȅǷǷ DZǷǶȂǯǺȋǼǽ Ǒ ǒǺǯDZǴ ǰȂdzǴȁ ǿǯȀȀǻǽȁǿǴǼ Ȁǯǻ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight Ƿ ǰǽǺǴǴ ǾǽdzǿǽǰǼǽ ǽǾǷȀǯǼ ǾǽǺǼȊǸ Ǽǯ ǰǽǿ ǴDzǽ ȀDZǽǸȀȁDZ ǻǴȁǽdzǽDZ Ƿ ȀǽǰȊȁǷǸ
ǒǺǯDZǯ 6
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰǿǯȂǶǴǿǯ Silverlight Ǒ dzǯǼǼǽǸ DzǺǯDZǴ ǰȂdzǴȁ ǾǽdzǿǽǰǼǽ ǿǯȀȀǻǽȁǿǴǼȊ DZǽǾǿǽȀȊ ǿǯǶǿǯǰǽȁǹǷ ǿǴȇǴǼǷǸ dzǺȎ Silverlight Ȁ ǷȀǾǽǺȋǶǽ DZǯǼǷǴǻ XAML-ǹǽdzǯ Ƿ JavaScript ǛȊ ǷȀȀǺǴdzȂǴǻ ǹǯǹ ǽǰȉǴǹȁ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ Silverlight ǿǯǶǻǴȈǯ ǴȁȀȎ DZ ǰǿǯȂǶǴǿǴ ǯ ȁǯǹǵǴ ǾǽǺǼȂȍ ǻǽdzǴǺȋ ȀDZǽǸȀȁDZ ǻǴȁǽdzǽDZ Ƿ ȀǽǰȊȁǷǸ ǾǽdzdzǴǿǵǷDZǯǴǻȂȍ ȌȁǷǻ ȌǺǴǻǴǼ ȁǽǻ ȂǾǿǯDZǺǴǼǷȎ ǡǯǹǵǴ ǰȂdzȂȁ ǿǯȀȀǻǽȁǿǴǼȊ ǾǽdzdzǴǿǵǹǯ ȀǽǰȊȁǷǸ ǶǯDzǿȂǶǹǷ Ƿ ǽȇǷǰǽǹ ǯ ȁǯǹǵǴ ǽǰǿǯǰǽȁǹǯ ǾǯǿǯǻǴȁǿǷǶǯȅǷǷ Ƿ ǹǽǼȁǴǹȀȁǯ ǐȂdzǴȁ ǾǽǹǯǶǯǼ ȀȁǯǼdzǯǿȁǼȊǸ ǽǰǿǯǰǽȁȆǷǹ ǽȇǷǰǽǹ ǾǿǴdzǽȀȁǯDZǺȎǴǻȊǸ Silverlight Ƿ ȁǽ ǹǯǹ ǴDzǽ ǻǽǵǼǽ ǾǴǿǴǽǾǿǴdzǴǺǷȁȋ ȀǽǰȀȁDZǴǼǼȊǻǷ ǽǰǿǯǰǽȁȆǷǹǯǻǷ ǽȇǷǰǽǹ ǛȊ dzǴȁǯǺȋǼǽ ǽȀȁǯ ǼǽDZǷǻȀȎ Ǽǯ ǽǰȉǴǹȁǴ Downloader ǾǿǴdzǽȀȁǯDZǺȎǴǻǽǻ Silverlight Ƿ DZȊȎȀǼǷǻ ǹǯǹ ǽǼ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ dzǷǼǯǻǷȆǴȀǹǽDzǽ DZDZǴdzǴǼǷȎ ȀǽdzǴǿǵǷǻǽDzǽ DZ ǾǿǷǺǽǵǴǼǷǴ ǜǯǹǽǼǴȅ ǰȂdzǴȁ ǿǯȀȀǻǽȁǿǴǼǯ ǻǽdzǴǺȋ Ǿǿǽ DzǿǯǻǻǷǿǽDZǯǼǷȎ ȌǺǴǻǴǼȁǽDZ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǽDzǽ ǷǼȁǴǿȃǴǸȀǯ UI ȀǽȀȁǯDZǺȎȍȈǷȄ ǻǽdzǴǺȋ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ XAML Ƿ ǾǽǹǯǶǯǼǽ ǷȀǾǽǺȋǶǽDZǯǼǷǴ ǷȄ ǻǴȁǽdzǽDZ Ƿ ȀǽǰȊȁǷǸ DZ ǻǽdzǴǺǷ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ JavaScript.
ǟǯǶǻǴȈǴǼǷǴ Silverlight DZ ǰǿǯȂǶǴǿǴ ǓǺȎ ǷȀǾǽǺȋǶǽDZǯǼǷȎ Ƿ ȀǽǶdzǯǼǷȎ ǾǿǷǺǽǵǴǼǷǸ Silverlight ǼǴ ȁǿǴǰȂǴȁȀȎ ǼǷǹǯǹǽDzǽ ȀǾǴȅǷǯǺȋǼǽDzǽ ǾǿǽDzǿǯǻǻ ǼǽDzǽ ǽǰǴȀǾǴȆǴǼǷȎ ǹǿǽǻǴ ȀǯǻǽDzǽ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ Silverlight Ƿ ȃǯǸǺǯ Silverlight.js ǹǽȁǽǿȊǸ ǽǰǴȀ ǾǴȆǷDZǯǴȁ ǶǯDzǿȂǶǹȂ Ƿ ȂȀȁǯǼǽDZǹȂ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ dzǺȎ ǹǺǷǴǼȁǽDZ ǼǴ ǷǻǴȍȈǷȄ ǴDzǽ ǠǽǶdzǯDZǯȁȋ ȀǯǸȁȊ Ǽǯ Silverlight ǻǽǵǼǽ ǷȀǾǽǺȋǶȂȎ ǺȍǰǽǴ Ǟǝ dzǺȎ ǿǯǶǿǯǰǽȁǹǷ ǑǴǰ-ȀǯǸȁǽDZ ǼǯȆǷǼǯȎ ǽȁ Notepad dzǽ Eclipse, Expression Web ǷǺǷ Expression Blend, ² DZȊǰǽǿ Ƕǯ DZǯǻǷ ǓǯǼǼȊǸ ǿǯǶdzǴǺ ǾǿǴdzȀȁǯDZǺȎǴȁ ǰǯǶǽDZǽǴ ǿȂǹǽDZǽdzȀȁDZǽ Ǿǽ ȁǽǻȂ ǹǯǹ ǼǯȆǯȁȋ ǷȀǾǽǺȋǶǽDZǯȁȋ Silverlight. Ǔǽ ȀǷȄ Ǿǽǿ DZ ȌȁǽǸ ǹǼǷDzǴ DZȀȍ ȀǺǽǵǼȂȍ ǿǯǰǽȁȂ Ƕǯ DZǯȀ DZȊǾǽǺǼȎǺ ȇǯǰǺǽǼ Expression Blend ǷǺǷ Microsoft Visual Studio Ǽǽ ȁǴǾǴǿȋ ǾǿǷȇǺǽ DZǿǴǻȎ ȂǶǼǯȁȋ ǹǯǹ ȀǯǻǽȀȁǽȎȁǴǺȋǼǽ ȀǽǶdzǯȁȋ Ƿ ǶǯǾȂȀȁǷȁȋ ǾǿǽȀȁǽǴ ǾǿǷǺǽǵǴǼǷǴ Silverlight ǼǴ ǷȀǾǽǺȋǶȂȎ ǼǷǹǯǹǷȄ dzǿȂDzǷȄ ǷǼȀȁǿȂǻǴǼȁǽDZ ǹǿǽǻǴ Windows Explorer Ƿ Notepad. ǞǴǿDZȊǸ Ƿ ȀǯǻȊǸ DZǯǵǼȊǸ ȃǯǸǺ, ǹǽȁǽǿȊǸ Ǽǯǻ ǾǽǼǯdzǽǰǷȁȀȎ, ² ȀȁǯǼdzǯǿȁǼȊǸ ȃǯǸǺ Silverlight.js. ǝǼ dzǽȀȁȂ ǾǴǼ DZ Silverlight Software Development Kit (SDK), ǹǽȁǽǿȊǸ ǻǽǵǼǽ ȀǹǯȆǯȁȋ Ǽǯ ǑǴǰ-ȀǯǸȁǴ http://www.microsoft.com/silverlight. ǓǯǺǴǴ ǼǴǽǰȄǽdzǷǻǽ ȀǽǶdzǯȁȋ HTML-ȃǯǸǺ ǹǽȁǽǿȊǸ ǰȂdzǴȁ ȀȀȊǺǯȁȋȀȎ Ȍȁǽ Ȍȁǽȁ JavaScript-ȃǯǸǺ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǰȂdzǴȁ ǿǯǶǻǴȈǯȁȋȀȎ Ǽǯ ȌȁǽǸ ȀȁǿǯǼǷȅǴ Ǒǽȁ ǾǿǷǻǴǿ
ǣǯǸǺ Silverlight.js DZǹǺȍȆǯǴȁ ǻǴȁǽdzȊ createObject Ƿ createObjectEx, Ȁ ǾǽǻǽȈȋȍ ǹǽȁǽǿȊȄ ǻǽDzȂȁ ȀǽǶdzǯDZǯȁȋȀȎ ȌǹǶǴǻǾǺȎǿȊ Silverlight. ǟǯǶǼǷȅǯ ǻǴǵdzȂ ȌȁǷǻǷ ǻǴȁǽdzǯǻǷ DZ ȁǽǻ, Ȇȁǽ createObjectEx ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋ JavaScript Object Notation (JSON)1 dzǺȎ ȀǴǿǷǯǺǷǶǯȅǷǷ ǾǯǿǯǻǴȁǿǽDZ. ǬȁǷ ȃȂǼǹȅǷǷ ǾǿǷǼǷǻǯȍȁ Ǽǯǰǽǿ ǾǯǿǯǻǴȁǿǽDZ ǷȀǾǽǺȋǶȂǴǻȊȄ dzǺȎ ȀǽǶdzǯǼǷȎ ȌǹǶǴǻǾǺȎǿǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZ ǺǴǼǷȎ ǓǯǼǼȊǴ ǾǯǿǯǻǴȁǿȊ ǾǿǴdzȀȁǯDZǺǴǼȊ DZ ȁǯǰǺ 6-1. ǡǏǐǚǗǥǏ 6 1
1ǝǰȉǴǹȁǼǯȎ
ǞǯǿǯǻǴȁǿȊ ǻǴȁǽdzǽDZ createObject Ƿ createObjectEx
ǼǽȁǯȅǷȎ JavaScript (ǾǿǷǻ ǾǴǿǴDZǽdzȆǷǹǯ).
ǒǺǯDZǯ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰǿǯȂǶǴǿǯ 6LOYHUOLJKW
ǗǻȎ ǾǯǿǯǻǴȁǿǯ
ǝǾǷȀǯǼǷǴ
source
ǖǯdzǯǴȁ ǷȀȁǽȆǼǷǹ XAML-ǹǽdzǯ ǷǺǷ XAP-ǾǿǷǺǽǵǴǼǷȎ ǹǽȁǽǿȊǸ ȃǽǿǻǷǿȂǴȁȀȎ ȌǺǴǻǴǼȁǽǻ ȂǾǿǯDZǺǴǼǷȎ Ǭȁǽ ǻǽǵǴȁ ǰȊȁȋ ȀȀȊǺǹǯ Ǽǯ ȃǯǸǺ ȁǴ ´source.xapµ), URI (ȁǴ., http://server/generatexaml.aspx) ǷǺǷ ȀȀȊǺǹǯ Ǽǯ DZȀȁǿǽǴǼǼȊǸ XAML ȀǽdzǴǿǵǯȈǷǸȀȎ DZ DIV (ȁǴ., #xamlcontent dzǺȎ DIV Ǿǽdz ǷǻǴǼǴǻ xamlcontent).
parentElement
Ǭȁǽ ǷǻȎ DIV, DZ ǹǽȁǽǿǽǻ ǼǯȄǽdzǷȁȀȎ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight Ǽǯ DZǯȇǴǸ HTML-ȀȁǿǯǼǷȅǴ.
ID
Ǭȁǽ ȂǼǷǹǯǺȋǼȊǸ ID ǾǿǷȀDZǯǷDZǯǴǻȊǸ DZǯǻǷ ȌǹǶǴǻǾǺȎǿȂ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight.
width
ǧǷǿǷǼǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ DZ ǾǷǹȀǴǺǯȄ ǷǺǷ DZ ǾǿǽȅǴǼȁǼǽǻ ȀǽǽȁǼǽȇǴǼǷǷ.
height
ǑȊȀǽȁǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ DZ ǾǷǹȀǴǺǯȄ ǷǺǷ DZ ǾǿǽȅǴǼȁǼǽǻ ȀǽǽȁǼǽȇǴǼǷǷ.
background
ǝǾǿǴdzǴǺȎǴȁ ȅDZǴȁ ȃǽǼǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ. ǖǯdzǯǼǷǴ ȅDZǴȁǽDZ ǾǽdzǿǽǰǼǽ ǿǯȀȀǻǯȁǿǷDZǯǴȁȀȎ DZ ǿǯǶdzǴǺǴ ©SolidColorBrushª ǒǺǯDZȊ 4, ©ǝȀǼǽDZȊ XAMLª ǛǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ ARGB-ǶǼǯȆǴǼǷǴ ǼǯǾǿǷǻǴǿ #FFAA7700 ǷǺǷ ǷǻǴǼǽDZǯǼǼȊǸ ȅDZǴȁ ǼǯǾǿǷǻǴǿ Black.
framerate
ǖǯdzǯǴȁ ǻǯǹȀǷǻǯǺȋǼǽ dzǽǾȂȀȁǷǻȂȍ ȆǯȀȁǽȁȂ ǹǯdzǿǽDZ ǯǼǷǻǯȅǷǷ ǖǼǯȆǴǼǷǴ Ǿǽ ȂǻǽǺȆǯǼǷȍ ǿǯDZǼǽ
isWindowless
ǛǽǵǴȁ ǾǿǷǼǷǻǯȁȋ ǶǼǯȆǴǼǷȎ true ǷǺǷ false ǶǼǯȆǴǼǷǴ Ǿǽ ȂǻǽǺȆǯǼǷȍ ² false ǔȀǺǷ ǶǯdzǯǼǽ true DZǷǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ȀǽdzǴǿǵǷǻǽDzǽ Silverlight ȃǽǿǻǷǿȂǴȁȀȎ ǾǽǶǯdzǷ HTMLȀǽdzǴǿǵǷǻǽDzǽ ȁǯǹ Ȇȁǽ HTML-ȀǽdzǴǿǵǷǻǽǴ ǻǽǵǴȁ ǽȁǽǰǿǯǵǯȁȋȀȎ ǾǽDZǴǿȄ ǴDzǽ
enableHtmlAccess
ǝǾǿǴdzǴǺȎǴȁ DZǽǶǻǽǵǼǽȀȁȋ dzǽȀȁȂǾǯ ǹ ȀǽdzǴǿǵǷǻǽǻȂ ǿǯȀǾǽǺǯDzǯȍȈǴǻȂȀȎ DZ ȌǺǴǻǴǼȁǴ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǷǶ DOM1 ǰǿǯȂǶǴǿǯ ǖǼǯȆǴǼǷǴ Ǿǽ ȂǻǽǺȆǯǼǷȍ ² true.
inplaceInstallPrompt
Silverlight ǷǻǴǴȁ dzDZǯ ǿǴǵǷǻǯ ȂȀȁǯǼǽDZǹǷ. ǢȀȁǯǼǽDZǹǯ inplace Ǽǯ ǻǴȀȁǴ DZǹǺȍȆǯǴȁ ǾǿǷǼȎȁǷǴ ǺǷȅǴǼǶǷǷ Ǽǯ Ǟǝ Ƿ ǾǿȎǻȂȍ ǶǯDzǿȂǶǹȂ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǰǴǶ ǾǴǿǴȄǽdzǯ Ȁ ȀǯǸȁǯ Ǽǯ ǹǽȁǽǿǽǻ ǽǼ ǰȂdzǴȁ ǿǯǶǻǴȈǯȁȋȀȎ ǞǿǷ ȂȀȁǯǼǽDZǹǴ indirect ǼǴǾǿȎǻǯȎ ǾǽǺȋǶǽDZǯȁǴǺȍ ǾǿǷȄǽdzǷȁȀȎ ǾǴǿǴȄǽdzǷȁȋ Ǽǯ ȀǯǸȁ Microsoft dzǺȎ ǶǯDzǿȂǶǹǷ Silverlight Ƿ ȂǵǴ ȁǯǻ ǾǿǷǼǷǻǯȁȋ ǺǷȅǴǼǶǷǽǼǼǽǴ ȀǽDzǺǯȇǴǼǷǴ Ƿ ȀǹǯȆǷDZǯȁȋ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Ǡ ǾǽǻǽȈȋȍ ȌȁǽDzǽ ȀDZǽǸȀȁDZǯ ǶǯdzǯǴȁȀȎ ǹǯǹǽǸ ǷǶ ǻǴȁǽdzǽDZ ǰȂdzǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ǖǼǯȆǴǼǷǴ true ǽǰǴȀǾǴȆǷDZǯǴȁ ǾǽǺȋǶǽDZǯȁǴǺȍ ǾǿȎǻȂȍ inplace ȂȀȁǯǼǽDZǹȂ ǶǼǯȆǴǼǷǴ false ǾǿǷDZǽdzǷȁ ǹ ǷȀǾǽǺȋǶǽDZǯǼǷȍ ǼǴǾǿȎǻǽǸ ȂȀȁǯǼǽDZǹǷ
version
ǖǯdzǯǴȁ ǻǷǼǷǻǯǺȋǼǽ ǼǴǽǰȄǽdzǷǻȂȍ ǾǽdzdzǴǿǵǷDZǯǴǻȂȍ DZǴǿȀǷȍ Silverlight.
onLoad
ǖǯdzǯǴȁ ȃȂǼǹȅǷȍ, DZȊǶǽDZ ǹǽȁǽǿǽǸ ǰȂdzǴȁ ǾǿǽǷȀȄǽdzǷȁȋ ǾǿǷ ǶǯDzǿȂǶǹǴ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ.
onError
ǖǯdzǯǴȁ ȃȂǼǹȅǷȍ, DZȊǶǽDZ ǹǽȁǽǿǽǸ ǰȂdzǴȁ ǾǿǽǷȀȄǽdzǷȁȋ DZ ȀǺȂȆǯǴ DZǽǶǼǷǹǼǽDZǴǼǷȎ ǽȇǷǰǹǷ
onFullScreenChange
Ǭȁǽ ȀǽǰȊȁǷǴ ȃǽǿǻǷǿȂǴȁȀȎ ǾǿǷ ǷǶǻǴǼǴǼǷǷ ȀDZǽǸȀȁDZǯ FullScreen Ǒǽ DZǴȀȋ ȌǹǿǯǼ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight.
onResize
Ǭȁǽ ȀǽǰȊȁǷǴ ȃǽǿǻǷǿȂǴȁȀȎ ǾǿǷ ǷǶǻǴǼǴǼǷǷ ȀDZǽǸȀȁDZǯ ActualWidth ǷǺǷ ActualHeight ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight.
1ǝǰȉǴǹȁǼǯȎ
ǻǽdzǴǺȋ dzǽǹȂǻǴǼȁǯ ǾǿǷǻ ǾǴǿǴDZǽdzȆǷǹǯ).
121
122
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
initParams
ǖǯdzǯǴȁ ǽǾǿǴdzǴǺȎǴǻȊǸ ǾǽǺȋǶǽDZǯȁǴǺǴǻ Ǽǯǰǽǿ ǾǯǿǯǻǴȁǿǽDZ dzǺȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǐǽǺǴǴ ǾǽdzǿǽǰǼǽ Ȍȁǽ ǿǯȀȀǻǯȁǿǷDZǯǴȁȀȎ DZ ǿǯǶdzǴǺǴ ©ǝǰǿǯǰǽȁǹǯ ǾǯǿǯǻǴȁǿǽDZª dzǯǺǴǴ DZ dzǯǼǼǽǸ DzǺǯDZǴ
userContext
ǖǯdzǯǴȁ ȂǼǷǹǯǺȋǼȊǸ ǷdzǴǼȁǷȃǷǹǯȁǽǿ ǹǽȁǽǿȊǸ ǻǽǵǴȁ ǾǴǿǴdzǯDZǯȁȋȀȎ ǹǯǹ ǾǯǿǯǻǴȁǿ DZ ȃȂǼǹȅǷȍ ǽǰǿǯǰǽȁǹǷ ȀǽǰȊȁǷȎ onLoad ǐǽǺǴǴ ǾǽdzǿǽǰǼǽ Ȍȁǽ ǿǯȀȀǻǯȁǿǷDZǯǴȁȀȎ DZ ǿǯǶdzǴǺǴ ©ǝȁDZǴȁ Ǽǯ ȀǽǰȊȁǷȎ ǶǯDzǿȂǶǹǷ ȀȁǿǯǼǷȅȊª dzǯǺǴǴ DZ dzǯǼǼǽǸ DzǺǯDZǴ.
ǞǽǵǯǺȂǸȀȁǯ, ǽǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ, Ȇȁǽ ǾǿǷ ȀǽǶdzǯǼǷǷ ȌǹǶǴǻǾǺȎǿǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ȀDZǽǸȀȁDZǯ width, height, background, framerate, isWindowless, enableHtmlAccess, version Ƿ inplaceInstallPrompt ǶǯdzǯȍȁȀȎ DZ ǻǯȀȀǷDZǴ ȀDZǽǸȀȁDZ, Ƿ onLoad Ƿ onError ² DZ ǻǯȀȀǷDZǴ ȀǽǰȊȁǷǸ. ǜǷǵǴ ǾǿǷDZǴdzǴǼ ǽdzǷǼ ǷǶ ǾǿǷǻǴǿǽDZ ǻǴȁǽdzǯ createObject: Silverlight.createObject( "Scene.xaml", document.getElementById("SilverlightControlHost"), "mySilverlightControl", { width:'300', height:'300', inplaceInstallPrompt:false, background:'#D6D6D6', isWindowless:'false', framerate:'24', version:'2.0' }, { onError:null, onLoad:null },
null);ǡǴǾǴǿȋ DZǴǿǼǴǻȀȎ ǹ ǼǯȇǴǸ HTML-ȀȁǿǯǼǷȅǴ Ƿ ǼǯȀȁǿǽǷǻ ǴǴ ȆȁǽǰȊ ǽǼǯ ǻǽDzǺǯ ǽǰǿǯǰǯȁȊDZǯȁȋ Ȍȁǽȁ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight Ǚǯǹ DZǷdzǷȁǴ ǾǿǷ ǶǯdzǯǼǷǷ ǷǻǴǼǷ ǹǽǻǾǽǼǴǼȁǯ Silverlight ǼǴǽǰȄǽdzǷǻǽ ǰȊ Ǻǽ Ƕǯdzǯȁȋ ǿǽdzǷȁǴǺȋȀǹǷǸ DIV Ǿǽdz ǷǻǴǼǴǻ SilverlightControlHost DZ ǹǽȁǽǿǽǻ Ȍȁǽȁ ǹǽǻǾǽǼǴǼȁ ǰȂdzǴȁ ǿǯǶǻǴ ȈǯȁȋȀȎ DIV ǶǯdzǯǴȁȀȎ ȆǴǿǴǶ ǴDzǽ ȀDZǽǸȀȁDZǽ ID. Ǒǽȁ ǾǽǺǼȊǸ HTML-ǹǽdz function createSilverlight() { Silverlight.createObject( "Page.xaml", document.getElementById("SilverlightControlHost"), "mySilverlightControl", { width:'300', height:'300', inplaceInstallPrompt:false, background:'#D6D6D6', isWindowless:'false', framerate:'24', version:'2.0' }, { onError:null, onLoad:null }, null); }
ǒǺǯDZǯ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰǿǯȂǶǴǿǯ 6LOYHUOLJKW
123
createSilverlight();
ǜǯǹǽǼǴȅ ȌǺǴǻǴǼȁȂ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǼǴǽǰȄǽdzǷǻ ȃǯǸǺ Ȁ ǷȀȄǽdzǼȊǻ XAML-ǹǽdzǽǻ Ǒ dzǯǼǼǽǻ ǾǿǷǻǴǿǴ ǷȀǾǽǺȋǶȂǴȁȀȎ XAML-ȃǯǸǺ Scene.xaml. ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǽȀȁǽǸ XAML-ȃǯǸǺ ȀǽdzǴǿǵǯȈǷǸ Ȁ ǼǯdzǾǷȀȋȍ TextBlock ©Hello, Worldª ǖdzǿǯDZȀȁDZȂǸ, ǻǷǿ!):
Ǒǽȁ DZȀǴ Ȇȁǽ ǼǴǽǰȄǽdzǷǻǽ dzǺȎ ǼǯȀȁǿǽǸǹǷ Ƿ ǾǽdzDzǽȁǽDZǹǷ ǹ ǿǯǰǽȁǴ ǾǿǷǺǽǵǴǼǷȎ Silverlight Ǟǽ ǻǴǿǴ dzǽǰǯDZ ǺǴǼǷȎ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁǷ DZ ǾǿǷǺǽǵǴǼǷǴ ǹǽdz ǰȂdzǴȁ ȂȀǺǽǵǼȎȁȋȀȎ Ǽǽ ȌȁǷ ȁǿǷ ȃǯǸǺǯ ² HTML-ȀȁǿǯǼǷȅǯ dzǺȎ ǿǯǶǻǴȈǴǼǷȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ XAML-ȃǯǸǺ Ƿ Silverlight.js, ² ǹǯǹ ǾǿǯDZǷǺǽ ǾǿǷȀȂȁȀȁDZȂȍȁ DZ ǹǯǵdzǽǻ ǾǿǽǴǹȁǴ.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȁǴDzǯ Object ǼǯǾǿȎǻȂȍ Ǒ ǾǿǴdzȊdzȂȈǴǻ ǾǿǷǻǴǿǴ ȌǹǶǴǻǾǺȎǿ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight ȀǽǶdzǯDZǯǺȀȎ Ȁ ǾǽǻǽȈȋȍ ȃȂǼǹȅǷǷ Silverlight.createObject ǼǯȄǽdzȎȈǴǸȀȎ DZ Silverlight.js ǜǽ ȀȂȈǴȀȁDZȂǴȁ DZǽǶǻǽǵǼǽȀȁȋ ȀǽǶdzǯȁȋ ȌǹǶǴǻǾǺȎǿ Ǿǽdz ǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ Silverlight ǼǯǾǿȎǻȂȍ ǰǴǶ ǾǿǷǻǴǼǴǼǷȎ Ȍȁǽ ȃȂǼǹȅǷǷ ǠdzǴǺǯȁȋ Ȍȁǽ ǾǽǶDZǽǺȎǴȁ ȀȁǯǼ dzǯǿȁǼȊǸ ȁǴDz ǷǻǴȍȈǷǸ dzǽȆǴǿǼǷǸ ȌǺǴǻǴǼȁ dzǺȎ ǶǯdzǯǼǷȎ ǾǯǿǯǻǴȁǿǽDZ Ǒǽȁ ǾǿǷǻǴǿ ǿǴǯ ǺǷǶǯȅǷǷ:
ǞǿǷǻǴȆǯǼǷǴ ǞǽǵǯǺȂǸȀȁǯ, ǽǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ǽǯ ǿǯǶǺǷȆǷǴ ȁǷǾǽDZ MIME DZ Silverlight 2 RTW Ƿ ǿǯǼǴǴ ǷȀ ǾǽǺȋǶǽDZǯǼǼȊȄ ǰǴȁǯ-DZǴǿȀǷȎȄ, ȁǯǹ ǹǯǹ DZ Beta 2 ǷȀǾǽǺȋǶǽDZǯǺȀȎ ȁǷǾ MIME ©application/x-silverlight-2-b2ª. ǔȀǺǷ DZǽǶǼǷǹǯȍȁ ǾǿǽǰǺǴǻȊ Ȁ ǿǯȀǾǽǶǼǯǼǷǴǻ ǽǰȉǴǹȁǯ Silverlight ǰǿǯȂǶǴǿǽǻ, ȂǰǴdzǷȁǴȀȋ, Ȇȁǽ Ȍȁǽȁ ǾǯǿǯǻǴȁǿ ǶǯdzǯǼ Ǿǿǯ DZǷǺȋǼǽ, ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ ǷȀǾǽǺȋǶȂǴǻǽǸ DZǴǿȀǷǷ Silverlight. ǓǺȎ 6LOYHUOLJKW 57: ȁǷǾ 0,0( ©application/xsilverlight-2ª
ǖǯǻǴȆǯȁǴǺȋǼǯȎ ǽȀǽǰǴǼǼǽȀȁȋ ȁǴDzǯ DZ ȁǽǻ Ȇȁǽ ǽǼ ȎDZǺȎǴȁȀȎ ǼǯǿǯȈǷDZǯǴǻȊǻ DZ ȁǽǻ ȀǻȊȀǺǴ Ȇȁǽ ǴȀ ǺǷ ȀǽǶdzǯȁȋ ȌǹǶǴǻǾǺȎǿ ǷȀȄǽdzǼǽDzǽ ǼǴ ȂdzǯǺǽȀȋ ǰǿǯȂǶǴǿ Ǽǯ Ȍȁǽǻ ǻǴȀȁǴ ȀȃǽǿǻǷǿȂǴȁ DZǷǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ȀǺǴdzȂȍȈǴǸ ȆǯȀȁǷ HTML ǾǿǷ ȂȀǺǽDZǷǷ Ȇȁǽ HTML ǿǯȀǾǽǺǯDzǯǴȁȀȎ dzǽ ǶǯǹǿȊDZǯȍȈǴDzǽ ȁǴDzǯ ǞǽȌȁǽǻȂ ǴȀǺǷ Silverlight ǼǴ ȂȀȁǯǼǽDZǺǴǼ Ǽǯ ǴDzǽ ǻǴȀȁǽ Ǽǯ ȌǹǿǯǼǴ ǰǴǶ ȁǿȂdzǯ ǻǽǵǼǽ ǾǽȀȁǯDZǷȁȋ ǾǿǽȀȁǽǸ ǰǯǼǼǴǿ
124
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ: D KUHI « VW\OH WH[W-decoration: none;"> LPJ VUF « DOW *HW 0LFURVRIW Silverlight" style="border-style: none"/>
Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ DZ ǽǰȉǴǹȁ DZȀȁǿǽǴǼǯ DzǷǾǴǿȀȀȊǺǹǯ ȁǴDz ǾǽȌȁǽǻȂ ǴȀǺǷ Silverlight ǼǴ ȂȀȁǯǼǽDZǺǴǼ DZ ȀǷȀ ȁǴǻǴ Ȍȁǽȁ ȁǴDz ǽǰǴȀǾǴȆǷȁ ȀȀȊǺǹȂ Ǿǽ ǹǽȁǽǿǽǸ ǻǽǵǼǽ ǰȂdzǴȁ ǾǴǿǴǸȁǷ Ǽǯ ȀǯǸȁ ǶǯDzǿȂǶǹǷ Microsoft. ǓǯǼǼȊǸ ǾǽdzȄǽdz ǷȀǹǺȍȆǷȁǴǺȋǼǽ ǾǽǺǴǶǴǼ ǴȀǺǷ ȁǿǴǰȂǴȁȀȎ DZȀȁǿǽǷȁȋ Silverlight DZ ǑǴǰ-ȀǯǸȁ DzdzǴ JavaScript ǼǴdzǽȀȁȂǾǴǼ
ǟǴǯǹȅǷȎ Ǽǯ ȀǽǰȊȁǷȎ ǶǯDzǿȂǶǹǷ ȀȁǿǯǼǷȅȊ ǝǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷǸ JavaScript ǶǯdzǯǴȁȀȎ dzǺȎ ȂǾǿǯDZǺǴǼǷȎ ȀǽǰȊȁǷȎǻǷ ǶǯDzǿȂǶǹǷ ȀȁǿǯǼǷȅȊ Ȁ ǾǽǻǽȈȋȍ Ǿǯ ǿǯǻǴȁǿǯ onLoad ǾǽȀǺǴ ǶǯDzǿȂǶǹǷ ǾǿǴdzȀȁǯDZǺǴǼǼǽDzǽ DZ ȁǯǰǺ 6-1. ǝǼ ǶǯǾȂȀǹǯǴȁȀȎ ǾǽȀǺǴ ǾǽǺǼǽǸ ǶǯDzǿȂǶǹǷ XAML-ȀǽdzǴǿǵǷǻǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ ǴȀǺǷ dzǺȎ ǹǯǹǽDzǽ-ǺǷǰǽ XAML-ȌǺǴǻǴǼȁǯ UI ǰȂdzǴȁ ǽǾǿǴdzǴǺǴǼǽ ǯǼǯǺǽDzǷȆǼǽǴ ȀǽǰȊȁǷǴ ǽǼǽ ǰȂdzǴȁ ȀȃǽǿǻǷǿǽDZǯǼǽ dzǽ ȃǽǿǻǷǿǽDZǯ ǼǷȎ ȀǽǰȊȁǷȎ onLoad ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǙǿǽǻǴ ȁǽDzǽ Ȃ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǴȀȁȋ dzǽȀȁȂǾǼǽǴ ȁǽǺȋǹǽ dzǺȎ ȆȁǴǼǷȎ ȀDZǽǸȀȁDZǽ IsLoaded ǖǯDzǿȂǵǴǼ ǹǽȁǽǿǽǴ ȂȀȁǯǼǯDZǺǷDZǯǴȁȀȎ ǼǴǾǽȀǿǴdzȀȁDZǴǼǼǽ ǾǴǿǴdz ȃǽǿǻǷǿǽDZǯǼǷǴǻ ȀǽǰȊȁǷȎ onLoad. ǞǿǷ ǷȀǾǽǺȋǶǽDZǯǼǷǷ ǽǰǿǯǰǽȁȆǷǹǯ ȀǽǰȊȁǷȎ onLoad ȃȂǼǹȅǷȎ JavaScript dzǽǺǵǼǯ ǾǿǷǼǷǻǯȁȋ ȁǿǷ ǾǯǿǯǻǴȁ ǿǯ ǾǴǿDZȊǸ ² ȀȀȊǺǹǯ Ǽǯ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ DZȁǽǿǽǸ ² ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǷǸ ǹǽǼȁǴǹȀȁ Ƿ ȁǿǴȁǷǸ ² ȀȀȊǺǹǯ Ǽǯ ǹǽǿǼǴDZǽǸ ȌǺǴǻǴǼȁ XAML. ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ function handleLoad(control, userContext, rootElement) { ... }
ǝǰǿǯǰǽȁǹǯ ǾǯǿǯǻǴȁǿǽDZ ǞǿǷ DZȊǶǽDZǴ ȃȂǼǹȅǷǷ createObject dzǺȎ ȀǽǶdzǯǼǷȎ ȌǹǶǴǻǾǺȎǿǯ Silverlight DZ ǼǴǴ ǻǽǵǼǽ ǾǴǿǴdzǯDZǯȁȋ Ǿǯǿǯ ǻǴȁǿȊ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ initParams ǞǯǿǯǻǴȁǿȊ ǷǼǷȅǷǯǺǷǶǯȅǷǷ Ǭȁǽ ȀDZǽǸȀȁDZǽ ȀȁǿǽǹǽDZǽDzǽ ȁǷǾǯ Ǿǽ ȌȁǽǻȂ ǴȀǺǷ ǼǴǽǰȄǽdzǷǻǽ Ƕǯdzǯȁȋ ǼǴȀǹǽǺȋǹǽ ǶǼǯȆǴǼǷǸ ǽǼǷ ǻǽDzȂȁ ȂǹǯǶȊDZǯȁȋȀȎ ȆǴǿǴǶ ǶǯǾȎȁȂȍ DZ DZǷdzǴ Ȁȁǿǽ ǹǷ Ȁ ǿǯǶdzǴǺȎȍȈǷǻǷ ǶǯǾȎȁȊǻǷ ǠǷǼȁǯǹȀǷȆǴȀǹǷǸ ǿǯǶǰǽǿ ȁǯǹǽǸ ȀȁǿǽǹǷ DZ JavaScript ǼǴ ǾǿǴdzȀȁǯDZǺȎǴȁ ǰǽǺȋȇǽDzǽ ȁǿȂdzǯ. ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ ǽǾǷȀǯǼǷȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight Ȁ ȁǿǴǻȎ Ǿǯǿǯ ǻǴȁǿǯǻǷ function createSilverlight() { Silverlight.createObject( "Scene.xaml", document.getElementById("SilverlightControlHost"), "mySilverlightControl", { width:'300', height:'300', inplaceInstallPrompt:false, background:'#D6D6D6', isWindowless:'false', framerate:'24', version:'2.0'
ǒǺǯDZǯ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰǿǯȂǶǴǿǯ 6LOYHUOLJKW
125
}, { onError:null, onLoad:handleLoad }, "p1, p2, p3", // ǹȗȐșȖȒ ȗȈȘȈȔȍȚȘȖȊ null); }
Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ ǾǯǿǯǻǴȁǿȊ p1, p2 Ƿ p3 ǶǯdzǯǼȊ ǹǯǹ Ȁȁǿǽǹǯ Ȁ ǿǯǶdzǴǺȎȍȈǷǻǷ ǶǯǾȎȁȊǻǷ Ǒ JavaScript ǴȀȁȋ ȀȁǿǽǹǽDZȊǸ ǻǴȁǽdz split (ǿǯǶdzǴǺǷȁȋ) ǹǽȁǽǿȊǸ ǾǽǶDZǽǺȎǴȁ ǿǯǶǰǷDZǯȁȋ ȀȁǿǽǹǷ Ȁ ǿǯǶdzǴǺȎȍȈǷǻǷ ǶǯǾȎȁȊǻǷ DZ ǻǯȀȀǷDZ ǶǼǯȆǴǼǷǸ ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ ǽǰǿǯǰǽȁȆǷǹǯ ȀǽǰȊȁǷǸ onLoad ǹǽȁǽǿȊǸ ǷȀǾǽǺȋǶȂǴȁ Ȍȁǽȁ ǻǴȁǽdz dzǺȎ ǿǯǶdzǴǺǴ ǼǷȎ ȀǾǷȀǹǯ ǾǯǿǯǻǴȁǿǽDZ DZ ǻǯȀȀǷDZ Ȁȁǿǽǹ Ƿ dzǺȎ ǽȁǽǰǿǯǵǴǼǷȎ ǹǯǵdzǽDzǽ ǷǶ ǼǷȄ DZ ǽǹǼǴ ǾǿǴdzȂǾǿǴǵdzǴǼǷȎ: function handleLoad(control, userContext, rootElement) { var params = control.initParams.split(","); for (var i = 0; i< params.length; i++) { alert(params[i]); } }
ǞǽǺȋǶǽDZǯȁǴǺȋȀǹǷǸ ǹǽǼȁǴǹȀȁ Ǒ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǻǽǵǴȁ ǾǴǿǴdzǯDZǯȁȋȀȎ dzǽǾǽǺǼǷȁǴǺȋǼȊǸ ǾǯǿǯǻǴȁǿ ² ǾǯǿǯǻǴȁǿ ǹǽǼȁǴǹȀȁǯ ǝǼ DZǹǺȍȆǯǴȁȀȎ ǼǴǾǽȀǿǴdzȀȁDZǴǼǼǽ DZ ȀǽǰȊȁǷǴ onLoad ǹǯǹ DZȁǽǿǽǸ ǾǯǿǯǻǴȁǿ ǝǰȊȆǼǽ dzǺȎ ǼǴDzǽ ǷȀǾǽǺȋǶȂǴȁ ȀȎ ǷǻȎ userContext ǞǽǺȋǶǽDZǯȁǴǺȋȀǹǷǸ ǹǽǼȁǴǹȀȁ ǔDzǽ ǾǽDZǴdzǴǼǷǴ ǯǰȀǽǺȍȁǼǽ ǯǼǯǺǽDzǷȆǼǽ ǾǿǴdzȀȁǯDZǺǴǼ ǼȊǻ ǿǯǼǴǴ ǾǯǿǯǻǴȁǿǯǻ ǽǼ ǷǻǴǴȁ ǶǼǯȆǴǼǷǴ ǹǽȁǽǿǽǴ ǻǽǵǴȁ ǰȊȁȋ ǶǯǾǿǽȇǴǼǽ ǾǽȀǺǴ ȃǽǿǻǷǿǽDZǯǼǷȎ DZǷ ǶȂǯǺȋǼǽDzǽ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǝdzǼǯǹǽ ǹǯǹ ǾǿǯDZǷǺǽ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǷǸ ǹǽǼȁǴǹȀȁ ǷȀ ǾǽǺȋǶȂǴȁȀȎ ǼǴ ǹǯǹ ǾǯǿǯǻǴȁǿ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǯ ǹǯǹ ǾǴǿǴǻǴǼǼǯȎ ȀȀȊǺǽȆǼǽDzǽ ȁǷǾǯ dzǺȎ ǿǯǶǺǷȆǷȎ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ȄǽȁȎ ǼǷȆȁǽ ǼǴ ǻǴȇǯǴȁ ǶǯdzǯDZǯȁȋ ǴDzǽ dzǺȎ ǾǯǿǯǻǴȁǿǷǶǯȅǷǷ DZǯȇǴDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ ȀȁǿǯǼǷȅȊ Ǽǯ ǹǽȁǽǿǽǸ ǿǯǶǻǴȈǯȍȁȀȎ ȁǿǷ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight. ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ ǾǴǿǴǻǴǼǼȊǴ ǷǻǴǼǷ Ƿ ǹǽǼȁǴǹȀȁǯ ǶǯdzǯǼȊ DZ ȌȁǽǸ ȀȁǿǯǼǷȅǴ-ȄǽȀȁǴ Ƿ ǾǴǿǴdzǯȍȁȀȎ ǹǯǹ ǾǯǿǯǻǴȁǿȊ DZ JavaScript ȀǽǶdzǯȍȈǷǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight: function handleLoad(control, userContext, rootElement) { alert(userContext); } function createSilverlight(parentElement, cid, context) { Silverlight.createObject( "Page.xaml", document.getElementById(parentElement), cid, { width:'300', height:'300', inplaceInstallPrompt:false, background:'#D6D6D6', isWindowless:'false', framerate:'24', version:'2.0' }, { onError:null, onLoad:handleLoad
126
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
}, "p1,p2,p3", context, null); } createSilverlight("SilverlightControlHost1", "ctrl1","the first control"); createSilverlight("SilverlightControlHost2", "ctrl2","the second control"); createSilverlight("SilverlightControlHost3", "ctrl3","the third control");
HTML-ȀȁǿǯǼǷȅǯ ǷǻǴǴȁ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ onLoad, ǹǽȁǽǿȊǸ ǾǿǴdzȀȁǯDZǺǴǼ ǶdzǴȀȋ: function handleLoad(control, userContext, rootElement) { alert(userContext); }
ǝǼ ǾǿǷǼǷǻǯǴȁ ǾǯǿǯǻǴȁǿ userContext Ƿ ǽȁǽǰǿǯǵǯǴȁ ǶǼǯȆǴǼǷǴ ǹǽǼȁǴǹȀȁǯ DZ ǽǹǼǴ ǾǿǴdzȂǾǿǴǵdzǴǼǷȎ Ǚǯǹ Ȍȁǽ DZȊDzǺȎdzǷȁ Ǽǯ ȌǹǿǯǼǴ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 6- Ǽǯ ǹǽȁǽǿǽǻ HTML-ȀȁǿǯǼǷȅǯ ǾǿǴdzȀȁǯDZǺȎǴȁ ǹǽǼȁǴǹȀȁ ǾǴǿDZǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ
ǒǺǯDZǯ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰǿǯȂǶǴǿǯ 6LOYHUOLJKW
127
ǟǗǠ 6 1 ǑȊDZǽdz Ǽǯ ȌǹǿǯǼ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǽDzǽ ǹǽǼȁǴǹȀȁǯ.
ǟǴǯǹȅǷȎ Ǽǯ ȀǽǰȊȁǷȎ DZǽǶǼǷǹǯȍȈǷǴ DZ ȀǺȂȆǯǴ ǽȇǷǰǹǷ Ǽǯ ȀȁǿǯǼǷȅǴ Silverlight ǾǿǴdzǽȀȁǯDZǺȎǴȁ ǼǴȀǹǽǺȋǹǽ ǻǴȁǽdzǽDZ ǽǰǿǯǰǽȁǹǷ ǽȇǷǰǽǹ DZ ǶǯDZǷȀǷǻǽȀȁǷ ǽȁ ȁǷǾǯ ǽȇǷǰǹǷ ǝȇǷǰ ǹǷ DZǽǶǼǷǹǯȍȁ DZ ȀǺȂȆǯȎȄ ǹǽDzdzǯ ȀǷǼȁǯǹȀǷȆǴȀǹǷǸ ǯǼǯǺǷǶǯȁǽǿ XAML ȀȁǯǺǹǷDZǯǴȁȀȎ Ȁ ǾǿǽǰǺǴǻǽǸ ǶǯDzǿȂǶǹǯ ǼǴ ǶǯDZǴǿȇǯǴȁȀȎ ȀǽǽȁDZǴȁȀȁDZȂȍȈǷǻ ǽǰǿǯǶǽǻ DZǽǶǼǷǹǯǴȁ ǽȇǷǰǹǯ DZǿǴǻǴǼǷ DZȊǾǽǺǼǴǼǷȎ Ƿ ǴȀǺǷ ǽǾǷȀǯǼǼȊǻ DZ XAML-dzǽǹȂǻǴǼȁǴ ǽǰǿǯǰǽȁȆǷǹǯǻ ȀǽǰȊȁǷǸ ǼǴ ǾǽȀȁǯDZǺǴǼȊ DZ ȀǽǽȁDZǴȁȀȁDZǷǴ JavaScript-ȃȂǼǹȅǷǷ ǞǿǷ ǷǼǷȅǷǯǺǷǶǯȅǷǷ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Ȁ ǾǽǻǽȈȋȍ ǽǰǿǯǰǽȁȆǷǹǯ ȀǽǰȊȁǷǸ onError ǶǯdzǯǴȁȀȎ ȃȂǼǹȅǷȎ JavaScript ǹǽȁǽǿǯȎ ǰȂdzǴȁ DZȊǶȊDZǯȁȋȀȎ ǾǿǷ DZǽǶǼǷǹǼǽDZǴǼǷǷ ǽȇǷǰǹǷ ǝdzǼǯǹǽ ǴȀǺǷ ȁǯǹǯȎ ȃȂǼǹȅǷȎ ǼǴ ǰȂdzǴȁ ǶǯdzǯǼǯ ǷǺǷ ǴȀǺǷ ǽǼǯ ǶǯdzǯǼǯ ǹǯǹ null ȁǽ ǼǷǹǯǹǽDzǽ ȂDZǴdzǽǻǺǴǼǷȎ ǽǰ ǽȇǷǰǹǴ ǼǴ ǰȂdzǴȁ ǾǿǽǷȀȄǽdzǷȁȋ Ƿ ǰȂ dzǴȁ ǽȁǽǰǿǯǵǯȁȋȀȎ ǾȂȀȁǯȎ ȀǴǿǯȎ ǽǰǺǯȀȁȋ Ǽǯ ǻǴȀȁǴ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ 6LOYHUOLJKW ǜǽ DZ ǾǿǽǴǹȁǯȄ ȀǽǶ dzǯǼǼȊȄ ǷǶ ([SUHVVLRQ %OHQG ǽǾǷȀȊDZǯǴȁȀȎ ȀȁǯǼdzǯǿȁǼȊǸ ǽǰǿǯǰǽȁȆǷǹ ǽȇǷǰǽǹ
128
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǠȁǯǼdzǯǿȁǼȊǸ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷǸ ǠȁǯǼdzǯǿȁǼȊǸ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷǸ JavaScript ǽǰǴȀǾǴȆǷȁ DZȊDZǽdz Ǽǯ ȌǹǿǯǼ ȀǽǽǰȈǴǼǷȎ ǽǰ ǽȇǷǰǹǴ Ȁ ǽȀ ǼǽDZǼȊǻǷ dzǴȁǯǺȎǻǷ DZǽǶǼǷǹȇǴǸ ǽȇǷǰǹǷ Silverlight DZǹǺȍȆǯȎ ǹǽdz Ƿ ȁǷǾ ǽȇǷǰǹǷ ǯ ȁǯǹǵǴ ȀǽǽǰȈǴǼǷǴ Ȁ Ȃǹǯ ǶǯǼǷǴǻ ǹǽǼǹǿǴȁǼǽǸ ǾǿǽǰǺǴǻȊ Ƿ ǷǻǴǼǷ DZȊǶDZǯǼǼǽDzǽ ǻǴȁǽdzǯ ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ ǼǴǾǿǯDZǷǺȋǼǽ ȀȃǽǿǻǷǿǽDZǯǼǼǽDzǽ XAML-dzǽǹȂǻǴǼȁǯ, DZ ǹǽȁǽǿǽǻ ȀdzǴǺǯǼǯ ǽȇǷǰǹǯ DZ ǷǻǴǼǷ ǶǯǹǿȊDZǯȍȈǴDzǽ ȁǴDzǯ ȌǺǴǻǴǼȁǯ TextBlock ǽǼ ǽȇǷǰǽȆǼǽ ǼǯǶDZǯǼ : Hello, World!
ǔȀǺǷ ǷȀǾǽǺȋǶȂǴȁȀȎ ǽǰǿǯǰǽȁȆǷǹ ȀǽǶdzǯǼǼȊǸ ([SUHVVLRQ %OHQG Ǿǽ ȂǻǽǺȆǯǼǷȍ ǽǼ ǽǰǴȀǾǴȆǷȁ DZȊDZǽdz Ǽǯ Ȍǹ ǿǯǼ ȀǽǽǰȈǴǼǷȎ ǽǰ ǽȇǷǰǹǴ Silverlight ǹǯǹ ǾǽǹǯǶǯǼ Ǽǯ ǿǷȀ 6-2.
ǟǗǠ 6 2 ǠǽǽǰȈǴǼǷǴ ǽǰ ǽȇǷǰǹǴ.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀǽǰȀȁDZǴǼǼǽDzǽ ǽǰǿǯǰǽȁȆǷǹǯ ǽȇǷǰǽǹ ǛǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ ȀǽǰȀȁDZǴǼǼȊǸ ǽǰǿǯǰǽȁȆǷǹ ǽȇǷǰǽǹ ǓǺȎ ȌȁǽDzǽ ȀDZǽǸȀȁDZȂ onError ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴ ǼǷȎ Silverlight ǼǴǽǰȄǽdzǷǻǽ Ƕǯdzǯȁȋ ȀǾǴȅǷǯǺȋǼȂȍ ȃȂǼǹȅǷȍ ǽǰǿǯǰǽȁȆǷǹǯ ǽȇǷǰǽǹ ǝǼǯ dzǽǺǵǼǯ ǰȂdzǴȁ ǾǿǷ ǼǷǻǯȁȋ dzDZǯ ǾǯǿǯǻǴȁǿǯ ǽǰȉǴǹȁ ǽȁǾǿǯDZǷȁǴǺȎ ȀǽǰȊȁǷȎ Ƿ ǯǿDzȂǻǴǼȁȊ ȀǽǰȊȁǷȎ ǽǾǷȀȊDZǯȍȈǷǴ dzǴȁǯǺǷ DZǽǶ ǼǷǹȇǴǸ ǽȇǷǰǹǷ ǠȂȈǴȀȁDZȂǴȁ ȁǿǷ ȁǷǾǯ ǯǿDzȂǻǴǼȁǽDZ ȀǽǰȊȁǷȎ ǞǴǿDZȊǸ ȁǷǾ ² ǰǯǶǽDZȊǸ ǽǰȉǴǹȁ ErrorEventArgs ǏǿDzȂǻǴǼȁȊ ǽȇǷǰǹǷ ȀǽdzǴǿǵǯȈǷǸ ȁǷǾ ȀǽǽǰȈǴǼǷȎ ǽǰ ǽȇǷǰǹǴ Ƿ ǹǽdz ǠDZǽǸȀȁDZǽ errorType ǡǷǾ ǽȇǷǰǹǷ ǽǾǿǴdzǴǺȎǴȁ ȁǷǾ ǽȇǷǰǹǷ DZ DZǷdzǴ ȀȁǿǽǹǷ ȀǽdzǴǿǵǯȈǴǸ ǶǼǯȆǴǼǷȎ RuntimeError ǝȇǷǰǹǯ DZǿǴǻǴǼǷ DZȊǾǽǺǼǴǼǷȎ ǷǺǷ ParserError ǝȇǷǰǹǯ ȀǷǼȁǯǹȀǷȆǴȀǹǽDzǽ ǯǼǯǺǷǶǯȁǽǿǯ ǜǯ ǽȀǼǽDZǯǼǷǷ ȌȁǽǸ ǷǼȃǽǿǻǯȅǷǷ ǷȀǾǽǺȋǶȂǴȁȀȎ ǽdzǷǼ ǷǶ dzDZȂȄ ǾǿǽǷǶDZǽdzǼȊȄ ȁǷǾǽDZ ǽȇǷǰǽǹ ǞǿǷ ǽǰǿǯǰǽȁǹǴ DZ XAML ǽȇǷǰǹǷ ȀǷǼȁǯǹȀǷȆǴȀǹǽDzǽ ǿǯǶǰǽǿǯ ǷȀǾǽǺȋǶȂǴȁȀȎ ǽǰȉǴǹȁ ParserErrorEventArgs (Ǐǿ DzȂǻǴǼȁȊ ǽȇǷǰǹǷ ȀǷǼȁǯǹȀǷȆǴȀǹǽDzǽ ǯǼǯǺǷǶǯȁǽǿǯ). ǝǼǽ ȀǽdzǴǿǵǷȁ ǿȎdz ȀDZǽǸȀȁDZ x
ǠDZǽǸȀȁDZǽ charposition (ǾǽǶǷȅǷȎ ȀǷǻDZǽǺǯ) ȀǽdzǴǿǵǷȁ ǾǽǶǷȅǷȍ ȀǷǻDZǽǺǯ DZ ǹǽȁǽǿǽǻ DZǽǶǼǷǹǺǯ ǽȇǷǰǹǯ.
x
ǠDZǽǸȀȁDZǽ linenumber (ǼǽǻǴǿ ȀȁǿǽǹǷ) ȀǽdzǴǿǵǷȁ ǼǽǻǴǿ ȀȁǿǽǹǷ DZ ǹǽȁǽǿǽǸ DZǽǶǼǷǹǺǯ ǽȇǷǰǹǯ
x
ǠDZǽǸȀȁDZǽ xamlFile (xaml-ȃǯǸǺ ǽǾǿǴdzǴǺȎǴȁ ȃǯǸǺ DZ ǹǽȁǽǿǽǻ DZǽǶǼǷǹǺǯ ǽȇǷǰǹǯ.
x
ǠDZǽǸȀȁDZǽ xmlAttribute (xaml-ǯȁǿǷǰȂȁ) ǽǾǿǴdzǴǺȎǴȁ xml-ǯȁǿǷǰȂȁ, DZ ǹǽȁǽǿǽǻ DZǽǶǼǷǹǺǯ ǽȇǷǰǹǯ.
x
ǠDZǽǸȀȁDZǽ xmlElement (xaml-ȌǺǴǻǴǼȁ) ǽǾǿǴdzǴǺȎǴȁ xml-ȌǺǴǻǴǼȁ DZ ǹǽȁǽǿǽǻ DZǽǶǼǷǹǺǯ ǽȇǷǰǹǯ.
ǝȇǷǰǹǷ DZǿǴǻǴǼǷ DZȊǾǽǺǼǴǼǷȎ ǽǾǿǴdzǴǺȎȍȁȀȎ DZ ǽǰȉǴǹȁǴ RuntimeErrorEventArgs ǏǿDzȂǻǴǼȁȊ ǽȇǷǰǹǷ DZǿǴ ǻǴǼǷ DZȊǾǽǺǼǴǼǷȎ Ǭȁǽȁ ǽǰȉǴǹȁ ȁǯǹǵǴ DZǹǺȍȆǯǴȁ ǿȎdz ȀDZǽǸȀȁDZ x
ǠDZǽǸȀȁDZǽ charPosition ǽǾǿǴdzǴǺȎǴȁ ǾǽǶǷȅǷȍ ȀǷǻDZǽǺǯ DZ ǹǽȁǽǿǽǻ DZǽǶǼǷǹǺǯ ǽȇǷǰǹǯ.
x
ǠDZǽǸȀȁDZǽ lineNumber ǽǾǿǴdzǴǺȎǴȁ ȀȁǿǽǹȂ DZ ǹǽȁǽǿǽǸ DZǽǶǼǷǹǺǯ ǽȇǷǰǹǯ.
x
ǠDZǽǸȀȁDZǽ methodName (ǷǻȎ ǻǴȁǽdzǯ) ǽǾǿǴdzǴǺȎǴȁ ǻǴȁǽdz ȀDZȎǶǯǼǼȊǸ Ȁ ȌȁǽǸ ǽȇǷǰǹǽǸ.
ǟǯȀȀǻǽȁǿǷǻ ǹǯǹ ǽȇǷǰǹȂ ǻǽǵǼǽ ǾǴǿǴȄDZǯȁǷȁȋ ȀǽǰȀȁDZǴǼǼȊǻ ǽǰǿǯǰǽȁȆǷǹǽǻ ǽȇǷǰǽǹ ǞǿǴǵdzǴ DZȀǴDzǽ ȀǽǶ dzǯǴȁȀȎ ǻǴȁǽdz createSilverlight() DZȊǾǽǺǼȎȍȈǷǸ ǼǯȀȁǿǽǸǹȂ ǽǰǿǯǰǽȁȆǷǹǯ ǽȇǷǰǽǹ function createSilverlight() {
ǒǺǯDZǯ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰǿǯȂǶǴǿǯ 6LOYHUOLJKW
129
Silverlight.createObject( "Scene.xaml", document.getElementById("firstControl"), "agc1", { width:'300', height:'300', inplaceInstallPrompt:false, background:'#D6D6D6', isWindowless:'false', framerate:'24', version:'2.0' }, { onError:handleError, onLoad:null }, null); }
ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ HTML-ȃǯǸǺ ǹǽȁǽǿȊǸ DZȊǶȊDZǯǴȁ Ȍȁǽȁ ǷǶǻǴǼǴǼǼȊǸ ǻǴȁǽdz ȀǽǶdzǯǼǷȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZ ǺǴǼǷȎ Silverlight Ƿ ȀǽdzǴǿǵǷȁ ȃȂǼǹȅǷȍ handleError ǶǯdzǯǼǼȂȍ ǹǯǹ ǽǰǿǯǰǽȁȆǷǹ ǽȇǷǰǽǹ DZ ǯȁǿǷǰȂȁǴ onError: function handleError(sender, errorArguments) { var strError = "Error Details: \n"; strError+= "Type: " + errorArguments.errorType + "\n"; strError+= "Message: " + errorArguments.errorMessage + "\n"; strError+= "Code: " + errorArguments.errorCode + "\n"; // Ǵȣ ȏȕȈȍȔ (Ȋ ȌȈȕȕȖȔ șȓțȟȈȍ), ȟȚȖ ȥȚȖ ȖȠȐȉȒȈ șȐȕȚȈȒșȐȟȍșȒȖȋȖ ȈȕȈȓȐȏȈȚȖȘȈ. ǿȚȖȉȣ ȖȉȘȈȉȖȚȟȐȒ ȖȠȐȉȖȒ ȉȣȓ ȉȖȓȍȍ țȕȐȊȍȘșȈȓȤȕȣȔ ȚȐȗ ȖȠȐȉȒȐ ȌȖȓȎȍȕ ȖȗȘȍȌȍȓȧȚȤșȧ ȌȖ ȊȣȏȖȊȈ șȊȖȑșȚȊ ȈȘȋțȔȍȕȚȖȊ ȖȗȘȍȌȍȓȍȕȕȖȋȖ ȚȐȗȈ strError+= "Xaml File: " + errorArguments.xamlFile + "\n"; strError+= "Xaml Element: " + errorArguments.xmlElement + "\n"; strError+= "Xaml Attribute: " + errorArguments.xmlAttribute + "\n"; strError+= "Line: " + errorArguments.lineNumber + "\n"; strError+= "Position: " + errorArguments.charPosition + "\n"; alert(strError); } createSilverlight();
ǔȀǺǷ ǾǿǷ DZȊǾǽǺǼǴǼǷǷ ȌȁǽDzǽ ǹǽdzǯ DZǽǶǼǷǹǯǴȁ ǽȇǷǰǹǯ Ǽǯ ȌǹǿǯǼ ǰȂdzǴȁ DZȊDZǴdzǴǼǽ ǽǹǼǽ ǾǿǴdzȂǾǿǴǵdzǴǼǷȎ Ȁ ȀǽdzǴǿǵǷǻȊǻ ǽȇǷǰǹǷ ǜǯ ǿǷȀ 6- ǾǿǷDZǴdzǴǼ ǾǿǷǻǴǿ ȀǽǰȀȁDZǴǼǼǽDzǽ ǽǹǼǯ ǾǿǴdzȂǾǿǴǵdzǴǼǷȎ
130
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǟǗǠ 6 3 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀǽǰȀȁDZǴǼǼǽDzǽ ǽǰǿǯǰǽȁȆǷǹǯ ǽȇǷǰǽǹ.
ǠDZǽǸȀȁDZǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǷǻǴǴȁ ǿȎdz ȀDZǽǸȀȁDZ ǼǴǹǽȁǽǿȊǴ ǷǶ ǹǽȁǽǿȊȄ ȂǵǴ ǽǰȀȂǵdzǯǺǷȀȋ DZ ǿǯǶdzǴǺǴ ©ǟǯǶǻǴȈǴǼǷǴ Silverlight DZ ǰǿǯȂǶǴǿǴª ǠDZǽǸȀȁDZǯ ǻǽDzȂȁ ǶǯdzǯDZǯȁȋȀȎ ǼǴ ȁǽǺȋǹǽ ǾǿǷ ǷǼǷȅǷǯǺǷǶǯȅǷǷ ȌǺǴǻǴǼ ȁǯ ȂǾǿǯDZǺǴǼǷȎ Ǽǽ ȁǯǹǵǴ Ȁ ǾǽǻǽȈȋȍ ȀȅǴǼǯǿǷȎ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǿǯǶdzǴǺȎǴȁ ȀDZǽǸȀȁDZǯ Ǽǯ ȁǿǷ ȁǷǾǯ ǼǴǾǽȀǿǴdzȀȁDZǴǼǼȊǴ ȀDZǽǸȀȁDZǯ ȀDZǽǸȀȁDZǯ ȀǽdzǴǿǵǷǻǽDzǽ Ƿ ȀDZǽǸȀȁDZǯ ǼǯȀȁǿǽǴǹ ǜǴǾǽȀǿǴdzȀȁDZǴǼǼȊǴ ȀDZǽǸȀȁDZǯ ² Ȍȁǽ ȀDZǽǸȀȁDZǯ ȀǯǻǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǹǽȁǽǿȊǴ dzǽȀȁȂǾǼȊ ǾǽȀǿǴdzȀȁDZǽǻ ȀǷǼȁǯǹȀǷȀǯ controlǷǻȎȀDZǽǸȀȁDZǯ. ǓǽȀȁȂǾ ǹ ȀDZǽǸȀȁDZǯǻ ȀǽdzǴǿǵǷǻǽDzǽ Ƿ ǼǯȀȁǿǽǴǹ ǽȀȂȈǴȀȁDZǺȎǴȁȀȎ ǾǽȀǿǴdzȀȁDZǽǻ ȀǷǼȁǯǹ ȀǷȀǯ control.contentǷǻȎȀDZǽǸȀȁDZǯ Ƿ control.settingsǷǻȎȀDZǽǸȀȁDZǯ ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ1.
ǜǴǾǽȀǿǴdzȀȁDZǴǼǼȊǴ ȀDZǽǸȀȁDZǯ ǜǷǵǴ ǾǴǿǴȆǷȀǺǴǼȊ ǾǽdzdzǴǿǵǷDZǯǴǻȊǴ ǼǴǾǽȀǿǴdzȀȁDZǴǼǼȊǴ ȀDZǽǸȀȁDZǯ: x
initParams Ǒ Ȍȁǽǻ ȀDZǽǸȀȁDZǴ ȄǿǯǼȎȁȀȎ ǾǯǿǯǻǴȁǿȊ ǷǼǷȅǷǯǺǷǶǯȅǷǷ, ǾǴǿǴdzǯDZǯǴǻȊǴ DZ ȌǺǴǻǴǼȁ ȂǾǿǯDZ ǺǴǼǷȎ. ǝǼǽ ǻǽǵǴȁ ǰȊȁȋ ǶǯdzǯǼǽ ȁǽǺȋǹǽ ǹǯǹ ȆǯȀȁȋ ǷǼǷȅǷǯǺǷǶǯȅǷǷ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ.
x
isLoaded Ǭȁǽ ȀDZǽǸȀȁDZǽ ǾǿǷǼǷǻǯǴȁ ǶǼǯȆǴǼǷǴ true ǾǽȀǺǴ ǶǯDzǿȂǶǹǷ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ; DZ ǾǿǽȁǷDZ Ǽǽǻ ȀǺȂȆǯǴ, ǽǼǽ ǷǻǴǴȁ ǶǼǯȆǴǼǷǴ false. ǮDZǺȎǴȁȀȎ dzǽȀȁȂǾǼȊǻ ȁǽǺȋǹǽ dzǺȎ ȆȁǴǼǷȎ.
x
source Ǭȁǽ XAML-ȀǽdzǴǿǵǷǻǽǴ DZǷǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ǹǽȁǽǿǽDzǽ dzǽǺǵǼǽ ǰȊȁȋ ȀȃǽǿǻǷǿǽDZǯǼǽ. Ǭȁǽ ǻǽǵǴȁ ǰȊȁȋ ȀȀȊǺǹǯ Ǽǯ ȃǯǸǺ, URI ȀǺȂǵǰȊ, ȃǽǿǻǷǿȂȍȈǴǸ XAML, ǷǺǷ DZ ȀǺȂȆǯǴ ǾǿǷȀȂȁȀȁDZǷȎ ǾǿǴ ȃǷǹȀǯ #) DIV ȀǽdzǴǿǵǯȈǷǸ XAML-ǹǽdz DZ ǰǺǽǹǴ ȀȅǴǼǯǿǷȎ.
ǠDZǽǸȀȁDZǯ ȀǽdzǴǿǵǷǻǽDzǽ ǓǺȎ ǽǿDzǯǼǷǶǯȅǷǷ dzǽȀȁȂǾǯ ǹ ȀDZǽǸȀȁDZǯǻ ȀǽdzǴǿǵǷǻǽDzǽ ǷȀǾǽǺȋǶȂǴȁȀȎ ȀǷǼȁǯǹȀǷȀ control.content.ǷǻȎȀDZǽǸȀȁDZǯ. ǜǯǾǿǷǻǴǿ ǴȀǺǷ ǼǴǽǰȄǽdzǷǻǽ ǽǰǿǯȁǷȁȋȀȎ ǹ ȀDZǽǸȀȁDZȂ actualHeight ǷȀǾǽǺȋǶȂǴȁȀȎ ȀǷǼȁǯǹȀǷȀ control.content.actualHeight ǓǽȀȁȂǾǼȊ ȀǺǴdzȂȍȈǷǴ ȀDZǽǸȀȁDZǯ ȀǽdzǴǿǵǷǻǽDzǽ: x
actualHeight ǑǽǶDZǿǯȈǯǴȁ DZȊȀǽȁȂ ǽǰǺǯȀȁǷ ǽȁǽǰǿǯǵǴǼǷȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlightin DZ ǾǷǹȀǴ ǺǯȄ. ǑǽǶDZǿǯȈǯǴǻǽǴ ǶǼǯȆǴǼǷǴ ǶǯDZǷȀǷȁ ǽȁ ǿȎdzǯ ǹǿǷȁǴǿǷǴDZ. Ǒǽ-ǾǴǿDZȊȄ, ǽȁ ȁǽDzǽ, ǹǯǹ DZȊȀǽȁǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǰȊǺǯ ǶǯdzǯǼǯ ǷǶǼǯȆǯǺȋǼǽ. ǑȀǾǽǻǼǷǻ Ȇȁǽ Ȍȁǽ ǻǽǵǴȁ ǰȊȁȋ ǾǿǽȅǴǼȁǼǽǴ ȀǽǽȁǼǽȇǴǼǷǴ ǷǺǷ ǯǰȀǽǺȍȁǼǽǴ ǶǼǯȆǴǼǷǴ DZ ǾǷǹȀǴǺǯȄ. Ǒ ǾǴǿDZǽǻ ȀǺȂȆǯǴ, ȀDZǽǸȀȁDZǽ actualHeight DZǽǶDZǿǯȈǯǴȁ ȁǴǹȂȈȂȍ DZȊ ȀǽȁȂ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ, Ǽǽ ǴȀǺǷ ǾǽǺȋǶǽDZǯȁǴǺȋ ǷǶǻǴǼǷȁ ǿǯǶǻǴǿȊ ǰǿǯȂǶǴǿǯ ǴǴ ǶǼǯȆǴǼǷǴ ǷǶǻǴǼǷȁ ȀȎ. ǔȀǺǷ DZȊȀǽȁǯ ǶǯdzǯǼǯ ǯǰȀǽǺȍȁǼȊǻ ǶǼǯȆǴǼǷǴǻ, ǰȂdzǴȁ DZǽǶDZǿǯȈǴǼǽ Ȍȁǽ ǶǼǯȆǴǼǷǴ. ǞǿǷ ǷȀǾǽǺȋǶǽDZǯ ǼǷǷ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ DZ ǾǽǺǼǽȌǹǿǯǼǼǽǻ ǿǴǵǷǻǴ, Ȍȁǽ ȀDZǽǸȀȁDZǽ ǰȂdzǴȁ DZǽǶDZǿǯȈǯȁȋ ǿǯǶǿǴȇǯȍȈȂȍ ȀǾǽȀǽǰǼǽȀȁȋ ȌǹǿǯǼǯ Ǿǽ DZǴǿȁǷǹǯǺǷ.
x
actualWidth ǑǽǶDZǿǯȈǯǴȁ ȇǷǿǷǼȂ ȌǹǿǯǼǯ. ǑǽǶDZǿǯȈǯǴǻǽǴ ǶǼǯȆǴǼǷǴ ǶǯDZǷȀǷȁ ǽȁ ǿȎdzǯ ǹǿǷȁǴǿǷǴDZ Ƿ ǯǼǯǺǽDzǷȆǼǽ ǾǯǿǯǻǴȁǿȂ actualHeight.
x
fullScreen ǞǴǿǴǹǺȍȆǯǴȁ ǿǴǵǷǻ ǽȁǽǰǿǯǵǴǼǷȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǻǴǵdzȂ DZȀȁǿǽǴǼǼȊǻ Ƿ ǾǽǺǼǽȌǹǿǯǼǼȊǻ ǿǴǵǷǻǯǻǷ Ǟǽ ȂǻǽǺȆǯǼǷȍ ǷǻǴǴȁ ǶǼǯȆǴǼǷǴ false, Ȇȁǽ ǽǰǽǶǼǯȆǯǴȁ DZȀȁǿǽǴǼǼȊǸ ǿǴ ǵǷǻ. ǙǽDzdzǯ ȌȁǽǻȂ ȀDZǽǸȀȁDZȂ ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ true, ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǰȂdzǴȁ ǽȁǽǰǿǯǵǯȁȋȀȎ DZǽ DZǴȀȋ ȌǹǿǯǼ.
ǠDZǽǸȀȁDZǯ ǼǯȀȁǿǽǴǹ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ȁǯǹǵǴ ǷǻǴǴȁ ǿȎdz ȀDZǽǸȀȁDZ ǹǽȁǽǿȊǴ ǽǾǿǴdzǴǺǴǼȊ ǹǯǹ ȀDZǽǸȀȁDZǯ ǼǯȀȁǿǽǴǹ. ǓǽȀȁȂǾ ǹ ȌȁǷǻ ȀDZǽǸȀȁDZǯǻ ǽȀȂȈǴȀȁDZǺȎǴȁȀȎ ǾǽȀǿǴdzȀȁDZǽǻ ȀǷǼȁǯǹȀǷȀǯ control.settings.ǷǻȎȀDZǽǸȀȁDZǯ: x
background Ǭȁǽ ȀDZǽǸȀȁDZǽ ǶǯdzǯǴȁ ȅDZǴȁ ȃǽǼǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight. ǛǽǵǴȁ ǾǿǷǼǷǻǯȁȋ ǶǼǯȆǴǼǷȎ DZ ǼǴȀǹǽǺȋǹǷȄ ȃǽǿǻǯȁǯȄ, DZǹǺȍȆǯȎ ǷǻǴǼǽDZǯǼǼȊǸ ȅDZǴȁ (ǼǯǾǿǷǻǴǿ Black), 8-ǿǯǶǿȎdzǼȊǴ ǶǼǯ
1ǞǿǷ
ǷȀǾǽǺȋǶǽDZǯǼǷǷ ȃȂǼǹȅǷǷ CreateObject ǷǻǴǼǯ ǰǽǺȋȇǷǼȀȁDZǯ ȀDZǽǸȀȁDZ ǷȀǾǽǺȋǶȂȍȁȀȎ Ȁ ǻǯǺǴǼȋǹǽǸ ǰȂǹDZȊ Ǽǽ ǾǿǷ ǾǿǽDzǿǯǻǻǼǽǻ ǽǰǿǯȈǴǼǷǷ ǹ ǼǷǻ DZǽ DZǿǴǻȎ DZȊǾǽǺǼǴǼǷȎ ǾǴǿDZǯȎ ǰȂǹDZǯ DZ ǷǻǴǼǷ ȀDZǽǸȀȁDZǯ dzǽǺǵǼǯ ǰȊȁȋ ǰǽǺȋȇǽǸ Ǭȁǽ ǹǯȀǯǴȁȀȎ DZȀǴȄ ȁǿǴȄ ȁǷǾǽDZ ȀDZǽǸȀȁDZ ǾǿǷǻ ǼǯȂȆǼǽDzǽ ǿǴdzǯǹȁǽǿǯ).
ǒǺǯDZǯ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰǿǯȂǶǴǿǯ 6LOYerlight
131
ȆǴǼǷȎ Red/Green/Blue (RGB) Ȁ ǷǺǷ ǰǴǶ ǯǺȋȃǯ-ǹǯǼǯǺǯ Ƿ 16-ǿǯǶǿȎdzǼȊǴ RGB-ǶǼǯȆǴǼǷȎ Ȁ ǷǺǷ ǰǴǶ ǯǺȋȃǯǹǯǼǯǺǯ. x
enableFrameRateCounter ǠȆǴȁȆǷǹ ȆǯȀȁǽȁȊ ǹǯdzǿǽDZ DZǹǺȍȆǴǼ ǔȀǺǷ ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ true, Silverlight ǰȂdzǴȁ ǽȁǽǰǿǯǵǯȁȋ ȁǴǹȂȈȂȍ ȆǯȀȁǽȁȂ ǹǯdzǿǽDZ (DZ ǹǯdzǿǯȄ DZ ȀǴǹȂǼdzȂ) DZ ȀȁǿǽǹǴ ȀǽȀȁǽȎǼǷȎ ǰǿǯȂǶǴ ǿǯ. ǖǼǯȆǴǼǷǴ Ǿǽ ȂǻǽǺȆǯǼǷȍ ² false.
x
enableHtmlAccess (Html-dzǽȀȁȂǾ DZǹǺȍȆǴǼ ǔȀǺǷ ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ true, XAML-ȀǽdzǴǿǵǷǻǽǴ Ȁȁǯ ǼǽDZǷȁȀȎ dzǽȀȁȂǾǼȊǻ ǷǶ DOM ǰǿǯȂǶǴǿǯ. ǖǼǯȆǴǼǷǴ Ǿǽ ȂǻǽǺȆǯǼǷȍ ² true.
x
enableRedrawRegions ǞǴǿǴǿǷȀǽDZǹǯ ǽǰǺǯȀȁǴǸ DZǹǺȍȆǴǼǯ ǔȀǺǷ ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ true, ǽȁǽǰǿǯ ǵǯȍȁȀȎ ǽǰǺǯȀȁǷ ǽǰȉǴǹȁǯ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ ǾǴǿǴǿǷȀǽDZȊDZǯǴǻȊǴ DZ ǹǯǵdzǽǻ ǹǯdzǿǴ Ǭȁǽ ǾǽǺǴǶ ǼȊǸ ǷǼȀȁǿȂǻǴǼȁ ǽǾȁǷǻǷǶǯȅǷǷ ǾǿǷǺǽǵǴǼǷȎ. ǖǼǯȆǴǼǷǴ Ǿǽ ȂǻǽǺȆǯǼǷȍ ² false.
x
maxFrameRate ǛǯǹȀǷǻǯǺȋǼǯȎ ȆǯȀȁǽȁǯ ǹǯdzǿǽDZ ǝǾǿǴdzǴǺȎǴȁ ǻǯǹȀǷǻǯǺȋǼȂȍ DzǴǼǴǿǷǿȂǴǻȂȍ ȆǯȀȁǽȁȂ ǹǯdzǿǽDZ. Ǟǽ ȂǻǽǺȆǯǼǷȍ ǾǿǷǼǷǻǯǴȁ ǶǼǯȆǴǼǷǴ 24 Ƿ ǷǻǴǴȁ ǯǰȀǽǺȍȁǼȊǸ ǻǯǹȀǷǻȂǻ 64.
x
version DZǴǿȀǷȎ ǠǽǽǰȈǯǴȁ ǽǰ ǷȀǾǽǺȋǶȂǴǻǽǸ DZ ǼǯȀȁǽȎȈǷǸ ǻǽǻǴǼȁ DZǴǿȀǷǷ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight. Ǭȁǽ Ȁȁǿǽǹǯ, ȀǽdzǴǿǵǯȈǯȎ dzǽ ȆǴȁȊǿǴȄ ǿǯǶdzǴǺǴǼǼȊȄ ȁǽȆǹǯǻǷ ȅǴǺȊȄ ȆǷȀǴǺ ǽȀǼǽDZǼǽǸ, dzǽ ǾǽǺǼǷȁǴǺȋǼȊǸ ǼǽǻǴǿǯ DZǴǿȀǷǸ, ǼǽǻǴǿ ȀǰǽǿǹǷ Ƿ ǼǽǻǴǿ ǿǴdzǯǹȅǷǷ, ² ȄǽȁȎ ǽǰȎǶǯȁǴǺȋǼȊǻǷ ȎDZǺȎȍȁȀȎ ȁǽǺȋǹǽ ǾǴǿDZȊǴ dzDZǯ ǶǼǯȆǴǼǷȎ (ǽȀǼǽDZǼǽǸ Ƿ dzǽǾǽǺǼǷȁǴǺȋǼȊǸ ǼǽǻǴǿ DZǴǿȀǷǷ).
x
windowless Ǭȁǽ ȀDZǽǸȀȁDZǽ ǽǾǿǴdzǴǺȎǴȁ ǿǴǵǷǻ ǽȁǽǰǿǯǵǴǼǷȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ: ǰǴǶǽǹǽǼǼȊǸ ǷǺǷ ǽǹǽǼǼȊǸ. ǔȀǺǷ ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ true, ǷȀǾǽǺȋǶȂǴȁȀȎ ǰǴǶǽǹǽǼǼȊǸ ǿǴǵǷǻ, ȁ.Ǵ. ȀǽdzǴǿǵǷǻǽǴ Silverlight ǽȁǽǰǿǯǵǯǴȁȀȎ Ǽǯ ȀȁǿǯǼǷȅǴ ©Ƕǯª HTML-ȀǽdzǴǿǵǷǻȊǻ.
ǛǴȁǽdzȊ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǷǻǴǴȁ ǿȎdz ǻǴȁǽdzǽDZ ǹǽȁǽǿȊǴ ǻǽDzȂȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ȂǾǿǯDZǺǴǼǷȎ ǴDzǽ ǾǽDZǴdzǴǼǷǴǻ Ƿ ȃȂǼǹȅǷǽǼǷǿǽDZǯǼǷǴǻ ǏǼǯǺǽDzǷȆǼǽ DzǿȂǾǾǯǻ ȀDZǽǸȀȁDZ Silverlight ǻǴȁǽdzȊ Silverlight ȁǽǵǴ ȀDzǿȂǾǾǷǿǽDZǯǼȊ DZ ©ȀǴǻǴǸȀȁDZǯª ǻǴȁǽdzǽDZ Ǒ ǼǯȀȁǽȎȈǴǴ DZǿǴǻȎ ǾǽdzdzǴǿǵǷDZǯȍȁȀȎ ǽdzǷǼ ǼǴǾǽȀǿǴdzȀȁDZǴǼǼȊǸ ǻǴȁǽdz Ƿ ȁǿǷ ǻǴȁǽdzǯ ȀǽdzǴǿǵǷǻǽDzǽ Ǧȁǽ ǴȀȁȋ Ȇȁǽ ǰȂdzǴȁ ǾǿǴdzȀȁǯDZǺǴǼǽ DZ ȀǺǴdzȂȍȈǷȄ ǿǯǶdzǴǺǯȄ DZǹǺȍȆǯȎ ǾǿǷǻǴǿȊ dzǴǻǽǼȀȁǿǷǿȂȍȈǷǴ ȀǷǼȁǯǹȀǷȀ ȌȁǷȄ ǻǴȁǽdzǽDZ Ƿ ȀǾǽȀǽǰ dzǽȀȁȂǾǯ ǹ ǼǷǻ
ǛǴȁǽdz createFromXaml ǛǴȁǽdz createFromXaml ȀǽǶdzǯȁȋ ǷǶ ;DPO ȎDZǺȎǴȁȀȎ ǻǴȁǽdzǽǻ ȀǽdzǴǿǵǷǻǽDzǽ Silverlight ǾǽǶDZǽǺȎȍȈǷǸ Ƕǯdzǯ DZǯȁȋ XAML-ȀǽdzǴǿǵǷǻǽǴ ǹǽȁǽǿǽǴ dzǷǼǯǻǷȆǴȀǹǷ dzǽǰǯDZǺȎǴȁȀȎ DZ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight Ǭȁǽȁ ǻǴ ȁǽdz ǾǿǷǼǷǻǯǴȁ dzDZǯ ǾǯǿǯǻǴȁǿǯ ǞǴǿDZȊǸ ² Ȁȁǿǽǹǯ ȀǽdzǴǿǵǯȈǯȎ XAML ǹǽȁǽǿȊǸ ǰȂdzǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ Ƿ DZȁǽǿǽǸ ² ǾǯǿǯǻǴȁǿ namescope ǽǰǺǯȀȁȋ ǷǻǴǼ ǔȀǺǷ DZȁǽǿǽǸ ǾǯǿǯǻǴȁǿ ǷǻǴǴȁ ǶǼǯȆǴǼǷǴ true ǶǼǯȆǴǼǷǴǻ Ǿǽ ȂǻǽǺȆǯǼǷȍ ȎDZǺȎǴȁȀȎ false DZ ǾǿǴdzǽȀȁǯDZǺǴǼǼǽǻ XAML ǰȂdzȂȁ ȀǽǶdzǯǼȊ ȂǼǷǹǯǺȋǼȊǴ ȀȀȊǺǹǷ x:Name ǹǽ ȁǽǿȊǴ ǼǴ ǰȂdzȂȁ ǹǽǼȃǺǷǹȁǽDZǯȁȋ Ȁ ǷǻǴǼǯǻǷ ȀȂȈǴȀȁDZȂȍȈǷȄ XAML-ȌǺǴǻǴǼȁǽDZ ǓǺȎ createFromXaml ȀȂȈǴȀȁDZȂǴȁ ǽDzǿǯǼǷȆǴǼǷǴ DZ dzǽǰǯDZǺȎǴǻǽǻ XAML dzǽǺǵǴǼ ǰȊȁȋ DZȀǴDzǽ ǽdzǷǼ ǹǽǿǼǴDZǽǸ ȂǶǴǺ ǞǽȌȁǽǻȂ ǴȀǺǷ ǼǴǽǰȄǽdzǷǻǽ dzǽǰǯDZǷȁȋ ǼǴȀǹǽǺȋǹǽ ȌǺǴǻǴǼȁǽDZ ȂǰǴdzǷȁǴȀȋ Ȇȁǽ DZȀǴ ǽǼǷ ǿǯȀǾǽǺǯDzǯȍȁȀȎ DZ ǽdzǼǽǻ ȂǶǺǴ DZǹǺȍȆǯȍȈǴǻ ȌǺǴǻǴǼȁ Canvas. ǙǿǽǻǴ ȁǽDzǽ createFromXaml ǼǴ dzǽǰǯDZǺȎǴȁ XAML DZ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight dzǽ ȁǴȄ Ǿǽǿ Ǿǽǹǯ ǽǼ ǼǴ ǰȂdzǴȁ dzǽǰǯDZǺǴǼ DZ dzǽȆǴǿǼǷǸ ȌǺǴǻǴǼȁ ǽdzǼǽDzǽ ǷǶ ȌǺǴǻǴǼȁǽDZ Canvas ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Ǘȁǯǹ ǾǿǷ DZȊ ǶǽDZǴ createFromXaml DZȊ ǾǽǺȂȆǯǴȁǴ ȀȀȊǺǹȂ Ǽǯ ȂǶǴǺ Ƿ Ȍȁǯ ȀȀȊǺǹǯ ǶǯȁǴǻ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ dzǽǰǯDZǺǴǼǷȎ Ȍȁǽ Dzǽ ȂǶǺǯ DZ dzǴǿǴDZǽ DZǷǶȂǯǺȋǼǽDzǽ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ: function handleLoad(control, userContext, sender) { var xamlFragment = ''; textBlock = control.content.createFromXaml(xamlFragment); sender.children.add(textBlock); }
ǖdzǴȀȋ ȀǽǶdzǯǴȁȀȎ XAML-ǹǽdz dzǺȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ TextBlock Ȁ ȁǴǹȀȁǽǻ ©A new TextBlockª ǜǽDZȊǸ TextBlock). Ǭȁǽȁ XAML-ǹǽdz ǶǯȁǴǻ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ȀǽǶdzǯǼǷȎ XAML-ȂǶǺǯ DZ ȀǽdzǴǿǵǷǻǽǻ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZ
132
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǺǴǼǷȎ ǙǽDzdzǯ Ȍȁǽ ǰȂdzǴȁ DZȊǾǽǺǼǴǼǽ Silverlight DZǽǶDZǿǯȁǷȁ ȀȀȊǺǹȂ Ǽǯ TextBlock. Ǭȁǯ ȀȀȊǺǹǯ dzǽǰǯDZǺȎǴȁȀȎ DZ dzǴǿǴDZǽ DZǷǶȂǯǺȋǼǽDzǽ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight Ƿ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǾǿǽǿǷȀǽDZǹǷ TextBlock.
ǛǴȁǽdz createFromXamlDownloader ǛǴȁǽdz createFromXamlDownloader (ȀǽǶdzǯȁȋ ǷǶ ǶǯDzǿȂǶȆǷǹǯ Xaml) ȎDZǺȎǴȁȀȎ ǻǴȁǽdzǽǻ ȀǽdzǴǿǵǷǻǽDzǽ, ǷȀ ǾǽǺȋǶȂǴǻȊǻ DZ ǾǯǿǴ Ȁ ǽǰȉǴǹȁǽǻ Downloader (ǖǯDzǿȂǶȆǷǹ), ǹǽȁǽǿȊǸ ǰȂdzǴȁ ǿǯȀȀǻǽȁǿǴǼ DZ dzǯǼǼǽǸ DzǺǯDZǴ ǾǽǶǵǴ. Ǭȁǽȁ ǻǴȁǽdz ǾǿǷǼǷǻǯǴȁ dzDZǯ ǾǯǿǯǻǴȁǿǯ ǞǴǿDZȊǸ ǾǯǿǯǻǴȁǿ ² ȀȀȊǺǹǯ Ǽǯ ǽǰȉǴǹȁ Downloader ǹǽȁǽ ǿȊǸ ǶǯDzǿȂǵǯǴȁ XAML-ǹǽdz ǷǺǷ ǾǯǹǴȁ ȀǽdzǴǿǵǯȈǷǸ XAML-ǹǽdz ǑȁǽǿǽǸ ǾǯǿǯǻǴȁǿ ² ǷǻȎ ǾǯǹǴȁǯ ǶǯDzǿȂǵǯǴ ǻǽDzǽ ȀǽdzǴǿǵǷǻǽDzǽ, ǹǽȁǽǿȊǸ dzǽǺǵǴǼ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ǔȀǺǷ Ȍȁǽ .zip-ȃǯǸǺ ǶǯdzǯǴȁȀȎ ǷǻȎ ȃǯǸǺǯ ȀǽdzǴǿǵǯ ȈǴDzǽȀȎ DZ .zip-ǯǿȄǷDZǴ DZ ǹǽȁǽǿǽǻ ǼǯȄǽdzǷȁȀȎ XAML-ǹǽdz ǹǽȁǽǿȊǸ ǾǿǴdzǾǽǺǯDzǯǴȁȀȎ ǷȀǾǽǺȋǶǽDZǯȁȋ ǔȀǺǷ Ƕǯ DzǿȂǵǴǼǼǽǴ ȀǽdzǴǿǵǷǻǽǴ ǼǴ DZ ǾǯǹǴȁǴ .zip DZ ǹǯȆǴȀȁDZǴ ǶǼǯȆǴǼǷȎ ȌȁǽDzǽ ǾǯǿǯǻǴȁǿǯ dzǽǺǵǼǯ ǰȊȁȋ ǶǯdzǯǼǯ ǾȂȀ ȁǯȎ Ȁȁǿǽǹǯ
ǛǴȁǽdz createObject ǛǴȁǽdz createObject ȀǽǶdzǯȁȋ ǽǰȉǴǹȁ ȎDZǺȎǴȁȀȎ ǼǴǾǽȀǿǴdzȀȁDZǴǼǼȊǻ ǻǴȁǽdzǽǻ ǾǿǴdzǼǯǶǼǯȆǴǼǼȊǻ dzǺȎ ȀǽǶ dzǯǼǷȎ ǽdzǼǽǿǯǶǽDZǽDzǽ ǽǰȉǴǹȁǯ dzǺȎ ǽǾǿǴdzǴǺǴǼǼǽǸ ȃȂǼǹȅǷǷ Ǒ Silverlight ǴdzǷǼȀȁDZǴǼǼȊǻ ȁǯǹǷǻ ǾǽdzdzǴǿǵǷ DZǯǴǻȊǻ ǽǰȉǴǹȁǽǻ ȎDZǺȎǴȁȀȎ Downloader ǐǽǺǴǴ ǾǽdzǿǽǰǼǽ ǽȀȁǯǼǽDZǷǻȀȎ Ǽǯ Ȍȁǽǻ DZ dzǯǼǼǽǸ DzǺǯDZǴ ǾǽǶǵǴ
ǛǴȁǽdz findName Ǭȁǽȁ ǻǴȁǽdz ȀǽdzǴǿǵǷǻǽDzǽ ǾǽǶDZǽǺȎǴȁ DZȊǾǽǺǼȎȁȋ ǾǽǷȀǹ ȂǶǺǯ DZ XAML-ǹǽdzǴ Ǿǽ ǯȁǿǷǰȂȁȂ x:Name ǔȀǺǷ findName ǼǯǸȁǷ ǷǻȎ ǼǯȄǽdzǷȁ ȂǶǴǺ Ȁ ǶǯdzǯǼǼȊǻ ǷǻǴǼǴǻ ǽǼ DZǽǶDZǿǯȈǯǴȁ ȀȀȊǺǹȂ Ǽǯ ǼǴDzǽ DZ ǾǿǽȁǷDZǼǽǻ ȀǺȂ ȆǯǴ DZǽǶDZǿǯȈǯǴȁȀȎ null.
ǝǰȉǴǹȁ Downloader ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǾǿǴdzǽȀȁǯDZǺȎǴȁ ǽǰȉǴǹȁ ǹǽȁǽǿȊǸ ǽǰǴȀǾǴȆǷDZǯǴȁ DZǽǶǻǽǵǼǽȀȁȋ ǶǯDzǿȂǵǯȁȋ dzǽǾǽǺǼǷȁǴǺȋǼȊǴ ȌǺǴǻǴǼȁȊ ǷȀǾǽǺȋǶȂȎ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁȋ ǯȀǷǼȄǿǽǼǼǽǸ ǶǯDzǿȂǶǹǷ Ǭȁǽ ǾǽǶDZǽǺȎǴȁ ȀǹǯȆǷ DZǯȁȋ ǽȁdzǴǺȋǼȊǴ ǿǴȀȂǿȀȊ ǷǺǷ ǿǴȀȂǿȀȊ DZ DZǷdzǴ .zip-ǯǿȄǷDZǯ
ǠDZǽǸȀȁDZǯ ǽǰȉǴǹȁǯ Downloader ǝǰȉǴǹȁ Downloader ǾǽdzdzǴǿǵǷDZǯǴȁ ȀǺǴdzȂȍȈǷǴ ȀDZǽǸȀȁDZǯ: x
downloadProgress ǾǽǹǯǶǯȁǴǺȋ ǾǿǽȅǴȀȀǯ ǶǯDzǿȂǶǹǷ Ǭȁǽ ȀDZǽǸȀȁDZǽ ǽǰǴȀǾǴȆǷDZǯǴȁ ǼǽǿǻǯǺǷǶǽDZǯǼ ǼǽǴ ǶǼǯȆǴǼǷǴ (ǻǴǵdzȂ 0 Ƿ 1), ǹǽȁǽǿǽǴ ǾǿǴdzȀȁǯDZǺȎǴȁ ǽǰȉǴǻ ǶǯDzǿȂǵǴǼǼǽDzǽ ȀǽdzǴǿǵǷǻǽDzǽ DZ ǾǿǽȅǴǼȁ Ǽǽǻ ȀǽǽȁǼǽȇǴǼǷǷ ǹ ǴDzǽ ǽǰȈǴǻȂ ǿǯǶǻǴǿȂ DzdzǴ ǶǼǯȆǴǼǷǴ ȌǹDZǷDZǯǺǴǼȁǼǽ ǶǯDzǿȂǶǹǷ.
x
status ȀǽȀȁǽȎǼǷǴ Ǭȁǽ ȀDZǽǸȀȁDZǽ ǾǿǷǼǷǻǯǴȁ ǹǽdz ȀǽȀȁǽȎǼǷȎ HTTP dzǺȎ ȁǴǹȂȈǴDzǽ ȀǽȀȁǽȎǼǷȎ ǾǿǽȅǴȀ Ȁǯ ǶǯDzǿȂǶǹǷ. ǑǽǶDZǿǯȈǯǴȁ ȀȁǯǼdzǯǿȁǼȊǸ ǹǽdz ȀǽȀȁǽȎǼǷȎ HTTP, ǼǯǾǿǷǻǴǿ ©ª dzǺȎ ©Not Foundª ǼǴ ǼǯǸdzǴǼ) ǷǺǷ ©ª dzǺȎ ©OKª.
x
statusText (ȁǴǹȀȁ ȀǽȀȁǽȎǼǷȎ) Ǭȁǽ ȀDZǽǸȀȁDZǽ ǾǿǷǼǷǻǯǴȁ ȁǴǹȀȁ ȀǽȀȁǽȎǼǷȎ HTTP dzǺȎ ȁǴǹȂȈǴDzǽ Ȁǽ ȀȁǽȎǼǷȎ ǾǿǽȅǴȀȀǯ ǶǯDzǿȂǶǹǷ. ǝǼ ȀǽǽȁDZǴȁȀȁDZȂǴȁ ǹǽdzȂ ȀǽȀȁǽȎǼǷȎ dzǺȎ ȀDZǽǸȀȁDZǯ status. ǓǺȎ ȂȀǾǴȇǼǽDzǽ ǶǯǾǿǽȀǯ status ǰȂdzǴȁ ǿǯDZǴǼ ©ª Ƿ statusText ǰȂdzǴȁ ©OKª. ǓǺȎ ǾǽǺȂȆǴǼǷȎ dzǽǾǽǺǼǷȁǴǺȋǼǽǸ ǷǼȃǽǿ ǻǯȅǷǷ Ǿǽ ǹǽdzǯǻ ȀǽȀȁǽȎǼǷȎ HTTP ǾǽȀǻǽȁǿǷȁǴ ȀȁǯǼdzǯǿȁǼȊǴ ǹǽdzȊ HTTP ǽǾȂǰǺǷǹǽDZǯǼǼȊǴ W3C (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
x
uri Ǭȁǽ ȀDZǽǸȀȁDZǽ ȀǽdzǴǿǵǷȁ URI ǽǰȉǴǹȁǯ ǹ ǹǽȁǽǿǽǻȂ DZ ǼǯȀȁǽȎȈǷǸ ǻǽǻǴǼȁ ǽǰǿǯȈǯǴȁȀȎ ǶǯDzǿȂǶȆǷǹ.
ǛǴȁǽdzȊ ǽǰȉǴǹȁǯ Downloader ǝǰȉǴǹȁ Downloader ǾǽdzdzǴǿǵǷDZǯǴȁ ȀǺǴdzȂȍȈǷǴ ǻǴȁǽdzȊ: x
abort (ǽȁǻǴǼǷȁȋ)
ǝȁǻǴǼȎǴȁ ȁǴǹȂȈȂȍ ǶǯDzǿȂǶǹȂ Ƿ DZǽǶDZǿǯȈǯǴȁ DZȀǴ ȀDZǽǸȀȁDZǯ DZ ǷȀȄǽdzǼǽǴ ȀǽȀȁǽȎǼǷǴ.
ǒǺǯDZǯ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰǿǯȂǶǴǿǯ 6LOYHUOLJKW
133
x
getResponseText (ǾǽǺȂȆǷȁȋ ȁǴǹȀȁ ǽȁDZǴȁǯ) ǑǽǶDZǿǯȈǯǴȁ ȀȁǿǽǹǽDZǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ǶǯDzǿȂǵǴǼ ǼȊȄ dzǯǼǼȊȄ. ǞǿǷǼǷǻǯǴȁ ǽǰȎǶǯȁǴǺȋǼȊǸ ǾǯǿǯǻǴȁǿ ǹǽȁǽǿȊǸ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ȂǹǯǶǯǼǷȎ ǷǻǴǼǽDZǯǼǼǽ Dzǽ ǰǺǽǹǯ DZ ǶǯDzǿȂǵǯǴǻǽǻ ǾǯǹǴȁǴ.
x
open (ǽȁǹǿȊȁȋ) ǖǯǾȂȀǹǯǴȁ ȀǴǯǼȀ ǶǯDzǿȂǶǹǷ. ǞǿǷǼǷǻǯǴȁ ȁǿǷ ǾǯǿǯǻǴȁǿǯ. ǞǴǿDZȊǸ ² ǹǽǻǯǼdzȂ dzǴǸȀȁ DZǷȎ. ǜǯǰǽǿ ǹǽǻǯǼdz HTTP ǶǯdzǽǹȂǻǴǼȁǷǿǽDZǯǼ W3C; ǽdzǼǯǹǽ, Silverlight ǾǽdzdzǴǿǵǷDZǯǴȁ ȁǽǺȋǹǽ GET Ǟǽ ǺȂȆǷȁȋ . ǑȁǽǿǽǸ ǾǯǿǯǻǴȁǿ ² URI ǿǴȀȂǿȀǯ, ǹǽȁǽǿȊǸ dzǽǺǵǴǼ ǰȂdzǴȁ ǶǯDzǿȂǵǯȁȋȀȎ.
x
send (ǽȁǾǿǯDZǷȁȋ)
ǑȊǾǽǺǼȎǴȁ ǶǯǾǿǽȀ ǶǯDzǿȂǶǹǷ, ǹǽȁǽǿȊǸ ǰȊǺ ǶǯǾȂȈǴǼ ǹǽǻǯǼdzǽǸ open.
ǠǽǰȊȁǷȎ ǽǰȉǴǹȁǯ Downloader ǝǰȉǴǹȁ Downloader ǾǽdzdzǴǿǵǷDZǯǴȁ ȀǺǴdzȂȍȈǷǴ ȀǽǰȊȁǷȎ: x
completed (ǶǯDZǴǿȇǴǼ) Ǭȁǽ ȀǽǰȊȁǷǴ ȃǽǿǻǷǿȂǴȁȀȎ Ǿǽ ǶǯDZǴǿȇǴǼǷǷ ǶǯDzǿȂǶǹǷ. ǝǼǽ ǾǿǷǼǷǻǯǴȁ dzDZǯ ǾǯǿǯǻǴȁǿǯ. ǞǴǿDZȊǸ ² ǽǰȉǴǹȁ, ȀȃǽǿǻǷǿǽDZǯDZȇǷǸ Ȍȁǽ ȀǽǰȊȁǷǴ (DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ, Ȁǯǻ ȌǺǴǻǴǼȁ ȂǾǿǯDZ ǺǴǼǷȎ downloader), Ƿ DZȁǽǿǽǸ ² Ǽǯǰǽǿ ǯǿDzȂǻǴǼȁǽDZ ȀǽǰȊȁǷȎ (eventArgs).
x
downloadProgressChanged (ǾǽǹǯǶǯȁǴǺȋ ǾǿǽȅǴȀȀǯ ǶǯDzǿȂǶǹǷ ǷǶǻǴǼǷǺȀȎ) Ǭȁǽ ȀǽǰȊȁǷǴ ȃǽǿǻǷǿȂ ǴȁȀȎ DZ ȄǽdzǴ ǶǯDzǿȂǶǹǷ. ǝǼǽ ȃǽǿǻǷǿȂǴȁȀȎ ǾǿǷ ǹǯǵdzǽǻ ǷǶǻǴǼǴǼǷǷ ǾǽǹǯǶǯȁǴǺȎ ǾǿǽȅǴȀȀǯ ǶǯDzǿȂǶǹǷ (ǶǼǯ ȆǴǼǷǴ ǹǽȁǽǿǽDzǽ ǻǴǼȎǴȁȀȎ ǽȁ dzǽ ) Ǽǯ ǷǺǷ ǰǽǺǴǴ ǯ ȁǯǹǵǴ ǹǽDzdzǯ ǽǼ dzǽȀȁǷDzǯǴȁ ǶǼǯȆǴǼǷȎ (100%). Ǟǽ dzǽȀȁǷǵǴǼǷǷ 1,0 ȁǯǹǵǴ ȃǽǿǻǷǿȂǴȁȀȎ ȀǽǰȊȁǷǴ completed.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǽǰȉǴǹȁǯ Downloader ǝǰȉǴǹȁ Downloader ǾǽǶDZǽǺȎǴȁ DZȊǾǽǺǼȎȁȋ dzǽȀȁȂǾ ǹ ǿǴȀȂǿȀǯǻ ȀǴȁǷ ǷǶ JavaScript ǞǽǵǯǺȂǸȀȁǯ ǽǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ Ȍȁǽȁ ǽǰȉǴǹȁ ǰȂdzǴȁ ǿǯǰǽȁǯȁȋ ȁǽǺȋǹǽ ǴȀǺǷ ǾǿǷǺǽǵǴǼǷǴ Silverlight DZȊǾǽǺǼȎǴȁȀȎ Ȁ ǑǴǰȀǴǿDZǴǿǯ Ƿ ǰȂdzǴȁ ȃǽǿǻǷǿǽDZǯȁȋ ǽȇǷǰǹȂ DZ ȀǺȂȆǯǴ ǶǯDzǿȂǶǹǷ ȀȁǿǯǼǷȅȊ ǾǿǽȀȁǽ ǷǶ ȃǯǸǺǽDZǽǸ ȀǷȀȁǴǻȊ ǝǰȉǴǹȁ Downloader ȀǽǶdzǯǴȁȀȎ ǻǴȁǽdzǽǻ createObject ǾǿǴdzǽȀȁǯDZǺȎǴǻȊǻ ȌǺǴǻǴǼȁǽǻ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ: function handleLoad(control, userContext, sender) { var downloader = control.createObject("downloader"); }
ǠǺǴdzȂȍȈǷǸ ȇǯDz ² ǶǯǾȂȀȁǷȁȋ ȀǴǯǼȀ ǶǯDzǿȂǶǹǷ ǓǺȎ ȌȁǽDzǽ Ȁ ǾǽǻǽȈȋȍ ǻǴȁǽdzǯ open ǽǰȉǴǹȁǯ Downloader ǽǰȉȎDZǺȎǴȁȀȎ URI ȃǯǸǺǯ Ƿ DZȊǶȊDZǯǴȁȀȎ ǻǴȁǽdz send dzǺȎ ǼǯȆǯǺǯ ǶǯDzǿȂǶǹǷ ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ DZ ǹǽ ȁǽǿǽǻ DZȊǾǽǺǼȎǴȁȀȎ ǶǯDzǿȂǶǹǯ ȃǯǸǺǯ ȃǷǺȋǻǯ movie.wmv: function handleLoad(control, userContext, sender) { var downloader = control.createObject("downloader"); downloader.open("GET","movie.wmv"); downloader.send(); }
ǓǺȎ ǽȁȀǺǴǵǷDZǯǼǷȎ ǾǿǽȅǴȀȀǯ ǶǯDzǿȂǶǹǷ Ƿ ǻǽǻǴǼȁǯ ǴǴ ǶǯDZǴǿȇǴǼǷȎ ǾǽǼǯdzǽǰǷȁȀȎ ȀǽǶdzǯȁȋ ȀǽǽȁDZǴȁȀȁDZȂȍȈǷǴ ǽǰǿǯǰǽȁȆǷǹǷ ȀǽǰȊȁǷǸ ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼǯ ȁǯ ǵǴ ȃȂǼǹȅǷȎ Ǽǽ DZ ǼǴǴ ǰȊǺǷ DZǼǴȀǴǼȊ ǼǴǽǰȄǽdzǷǻȊǴ dzǽ ǾǽǺǼǴǼǷȎ function handleLoad(control, userContext, sender) { var downloader = control.createObject("downloader"); downloader.addEventListener("downloadProgressChanged","handleDLProgress"); downloader.addEventListener("completed","handleDLComplete"); downloader.open("GET","movie.wmv"); downloader.send(); }
134
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǡǴǾǴǿȋ ǻǽǵǼǽ ǾǿǷǻǴǼǷȁȋ ȌȁǷ ǽǰǿǯǰǽȁȆǷǹǷ ȀǽǰȊȁǷǸ Ǒ dzǯǼǼǽǻ ǾǿǷǻǴǿǴ ȀǽǰȊȁǷǴ downloadProgressChanged ȀDZȎǶǯǼǽ Ȁ ȃȂǼǹȅǷǴǸ JavaScript handleDLProgress Ƿ ȀǽǰȊȁǷǴ completed ² Ȁ ȃȂǼǹȅǷǴǸ JavaScript handleDLComplete ǬȁǷ ȃȂǼǹȅǷǷ ǾǿǴdzȀȁǯDZǺǴǼȊ DZ dzǯǼǼǽǻ ȃǿǯDzǻǴǼȁǴ ǹǽdzǯ function handleDLProgress(sender, args) { var ctrl = sender.getHost(); var t1 = ctrl.content.findName("txt1"); var v = sender.downloadProgress * 100; t1.Text = v + "%"; } function handleDLComplete(sender, args) { alert("Download complete"); }
ǞǿǷǻǴȆǯǼǷǴ ǝǰȉǴǹȁ Downloader ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ȁǽǺȋǹǽ dzǺȎ ǾǿǷǺǽǵǴǼǷǸ ǿǯǶǻǴȈǴǼǼȊȄ Ǽǯ ǑǴǰȀǴǿDZǴǿǴ. Ǒ ȀǺȂȆǯǴ ǾǽǾȊȁǹǷ ǴDzǽ ǷȀǾǽǺȋǶǽDZǯǼǷȎ Ȁǽ ȀȁǿǯǼǷȅȊ, ǶǯDzǿȂǵǯǴǻǽǸ ǷǶ ȃǯǸǺǽDZǽǸ ȀǷȀȁǴǻȊ, ǰȂdzǴȁ Ȁȃǽǿ ǻǷǿǽDZǯǼǯ ǽȇǷǰǹǯ.
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ ȌǺǴǻǴǼȁǽDZ UI XAML ǾǿǴdzǽȀȁǯDZǺȎǴȁ ǿȎdz DZǷǶȂǯǺȋǼȊȄ ȌǺǴǻǴǼȁǽDZ dzǺȎ ȀǽǶdzǯǼǷȎ UI ǑȀǴ ǽǼǷ ǰȊǺǷ ǾǴǿǴȆǷȀǺǴǼȊ Ƿ Ǿǽdz ǿǽǰǼǽ ǿǯȀȀǻǽȁǿǴǼȊ DZ ǒǺǯDZǯȄ Ƿ Ǚ ȌǺǴǻǴǼȁǯǻ UI ǽȁǼǽȀȎȁȀȎ Canvas, Ellipse, Glyphs, Image, Line, MediaElement, Path, Polygon, Polyline, Rectangle, Run, Shape, TextBlock Ƿ dzǿȂDzǷǴ. ǙǯǵdzȊǸ ǷǶ ȌȁǷȄ ȌǺǴǻǴǼȁǽDZ ǾǽdzdzǴǿǵǷDZǯǴȁ ǾǽǺǼǽȃȂǼǹȅǷǽǼǯǺȋǼȊǸ Ǽǯǰǽǿ ǻǴȁǽdzǽDZ Ƿ ȀǽǰȊȁǷǸ ǹǽȁǽǿȊǴ ǰȂdzȂȁ ǾǴǿǴȆǷȀǺǴǼȊ Ƿ ǿǯȀȀǻǽȁǿǴǼȊ DZ ȀǺǴdzȂȍȈǷȄ ǼǴȀǹǽǺȋǹǷȄ ǿǯǶdzǴǺǯȄ ǙǿǽǻǴ ȁǽDzǽ Silverlight 2 ǽǰǺǯdzǯǴȁ ǰǽDzǯȁȊǻ Ǽǯǰǽǿǽǻ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǝǼǷ ǷȀǾǽǺȋǶȂȍȁȀȎ ǷǶ .NETǹǽdzǯ dzǺȎ ȀǽǶdzǯǼǷȎ ǼǯȀȊȈǴǼǼȊȄ UI, ǹǽȁǽǿȊǴ ǾǽdzǿǽǰǼǽ ǽǰȀȂǵdzǯȍȁȀȎ DZ ǒǺǯDZǴ ©ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ ǹǽǻǾǽǼǽDZǹǷª
ǛǴȁǽdzȊ ȌǺǴǻǴǼȁǽDZ UI ǬǺǴǻǴǼȁȊ UI ǾǿǴdzǽȀȁǯDZǺȎȍȁ ȃȂǼǹȅǷǷ ǹǽȁǽǿȊǴ ǻǽDzȂȁ DZȊǶȊDZǯȁȋȀȎ ǷǶ JavaScript ǬȁǷ ȃȂǼǹȅǷǷ ǾǽǶDZǽǺȎȍȁ ǻǯǼǷǾȂǺǷǿǽDZǯȁȋ ȌǺǴǻǴǼȁǯǻǷ UI dzǺȎ ȀǽǶdzǯǼǷȎ ȀǺǽǵǼȊȄ ȀȅǴǼǯǿǷǴDZ DZǶǯǷǻǽdzǴǸȀȁDZǷȎ Ȁ ǾǿǷǺǽǵǴǼǷǴǻ Ƿ ȎDZ ǺȎȍȁȀȎ ǽǰȈǷǻǷ dzǺȎ DZȀǴȄ ȌǺǴǻǴǼȁǽDZ UI.
ǛǴȁǽdzȊ AddEventListener Ƿ RemoveEventListener ǛǴȁǽdz AddEventListener ǓǽǰǯDZǷȁȋ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǾǿǷDZȎǶǹǷ ǹ ȌǺǴǻǴǼȁȂ UI ǽǰǿǯ ǰǽȁȆǷǹǯ ȀǽǰȊȁǷȎ DZǽ DZǿǴǻȎ DZȊǾǽǺǼǴǼǷȎ Ǭȁǽ ǾǽǺǴǶǼǽ dzǺȎ ǿǯǶdzǴǺǴǼǷȎ dzǷǶǯǸǼǯ Ƿ ǿǯǶǿǯǰǽȁǹǷ ǿǯǶǿǯǰǽȁ ȆǷǹ ǼǷȆǴDzǽ ǼǴ dzǽǰǯDZǺȎǴȁ ǼǴǾǽȀǿǴdzȀȁDZǴǼǼǽ DZ XAML ȀǽǶdzǯDZǯǴǻȊǸ dzǷǶǯǸǼǴǿǽǻ ǯ DZDZǽdzǷȁ ǹǽdz ǽǰǿǯǰǽȁǹǷ ȀǽǰȊȁǷȎ DZ ȃǯǸǺ ǷǺǷ ǰǺǽǹ JavaScript ǠǽǰȊȁǷȎ ȌǺǴǻǴǼȁǽDZ UI ǹǽȁǽǿȊǴ ǻǽDzȂȁ ǽǰǿǯǰǯȁȊDZǯȁȋȀȎ ǽǰȀȂǵdzǯ ȍȁȀȎ DZ dzǯǼǼǽǸ DzǺǯDZǴ ǾǽǶǵǴ ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ ǾǿǷǻǴǿ ǾǿǷDZȎǶǹǷ ǽǰǿǯǰǽȁȆǷǹǯ ȀǽǰȊȁǷȎ DZǽ DZǿǴǻȎ DZȊǾǽǺǼǴǼǷȎ ǖdzǴȀȋ dzǽǰǯDZǺȎǴȁȀȎ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ ǹǽȁǽǿȊǸ ǽȁȀǺǴǵǷDZǯǴȁ ȈǴǺȆǽǹ ǻȊȇǷ Ƿ ǽǾǿǴdzǴǺȎǴȁ Ȇȁǽ ȀǽǰȊȁǷǴ dzǽǺǵǼǽ ǽǰǿǯǰǯ ȁȊDZǯȁȋȀȎ ȃȂǼǹȅǷǴǸ JavaScript handleMouse ǽǰǿǯǰǽȁǹǯ ǻȊȇǷ Ǭȁǯ ȃȂǼǹȅǷȎ ǹǯǹ ǰǽǺȋȇǷǼȀȁDZǽ ǽǰǿǯǰǽȁ ȆǷǹǽDZ ȀǽǰȊȁǷǸ ǾǿǷǼǷǻǯǴȁ dzDZǯ ǾǯǿǯǻǴȁǿǯ ǯǿDzȂǻǴǼȁȊ ǽȁǾǿǯDZǷȁǴǺȎ Ƿ ȀǽǰȊȁǷȎ ǞǽȀǹǽǺȋǹȂ ǽǰǿǯǰǯȁȊDZǯ ǴȁȀȎ ȀǽǰȊȁǷǴ ǻȊȇǷ dzǯǼǼǯȎ ȃȂǼǹȅǷȎ ǾǿǷǼǷǻǯǴȁ ȌǹǶǴǻǾǺȎǿ ǽǰȉǴǹȁǯ MouseEventArgs ǏǿDzȂǻǴǼȁȊ ȀǽǰȊ ȁǷȎ ǻȊȇǷ ǾǿǴdzǽȀȁǯDZǺȎȍȈǷǸ ǹǽǽǿdzǷǼǯȁȊ Ȅ Ƿ Ȃ ǾǽǺǽǵǴǼǷȎ ǻȊȇǷ DZ ǻǽǻǴǼȁ ȃǽǿǻǷǿǽDZǯǼǷȎ ȀǽǰȊȁǷȎ function handleLoad(control, userContext, sender) { sender.addEventListener("mouseLeftButtonDown",handleMouse); }
ǒǺǯDZǯ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰǿǯȂǶǴǿǯ 6LOYHUOLJKW
135
function handleMouse(sender, mouseEventArgs) { alert(mouseEventArgs.getPosition(null).x + ":" + mouseEventArgs.getPosition(null).y); }
ǑȊ ǻǽǵǴȁǴ ȂǼǷȆȁǽǵǷȁȋ ǾǽdzǹǺȍȆǴǼǷǴ DZǽ DZǿǴǻȎ DZȊǾǽǺǼǴǼǷȎ ǷȀǾǽǺȋǶȂȎ ǻǴȁǽdz RemoveEventListener ǢdzǯǺǷȁȋ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ Ǒ ǼǴDzǽ ǻǽǵǼǽ ǾǴǿǴdzǯȁȋ ǺǷǰǽ ȅǴǺǽȆǷȀǺǴǼǼȊǸ ǻǯǿǹǴǿ ǹǽȁǽǿȊǸ ǰȊǺ DZǽǶDZǿǯȈǴǼ addEventListener ǺǷǰǽ ǷǻȎ ȀǽǰȊȁǷȎ.
ǛǴȁǽdz findName Ǭȁǽȁ ǻǴȁǽdz ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ DZȊǾǽǺǼǴǼǷȎ ǾǽǷȀǹǯ ǷǻǴǼǽDZǯǼǼǽDzǽ ǽǰȉǴǹȁǯ DZ dzǴǿǴDZǴ ȌǺǴǻǴǼȁǽDZ XAML ǝǼ DZǽǶDZǿǯȈǯǴȁ ȀȀȊǺǹȂ Ǽǯ ǶǯdzǯǼǼȊǸ ǽǰȉǴǹȁ ǴȀǺǷ ǽǼ ȀȂȈǴȀȁDZȂǴȁ DZ ǾǿǽȁǷDZǼǽǻ ȀǺȂȆǯǴ ǽǼ DZǽǶDZǿǯȁǷȁ null. ǜǯǾǿǷǻǴǿ ǿǯȀȀǻǽȁǿǷǻ ǹǽdz XAML:
Ǒ Ȍȁǽǻ ǹǽdzǴ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ x:Name ǶǯdzǯǴȁȀȎ ȁǿǷ ȌǺǴǻǴǼȁǯ TextBlock: txt1, txt2 Ƿ txt3. ǡǴǾǴǿȋ Ȁ Ǿǽ ǻǽȈȋȍ ǻǴȁǽdzǯ findName ǻǽǵǼǽ ǼǯǸȁǷ ǷǻǴǼǽDZǯǼǼȊǸ ȂǶǴǺ ǾǽǺȂȆǷȁȋ ȀȀȊǺǹȂ Ǽǯ ǼǴDzǽ Ƿ ǷȀǾǽǺȋǶȂȎ ȌȁȂ ȀȀȊǺǹȂ ǿǴdzǯǹȁǷǿǽDZǯȁȋ ǴDzǽ. Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ, DZȀǴ Ȍȁǽ DZȊǾǽǺǼȎǴȁȀȎ DZ ǽǰǿǯǰǽȁȆǷǹǴ ȀǽǰȊȁǷȎ handleLoad ǽǰǿǯǰǽȁǹǯ ǶǯDzǿȂǶǹǷ . function handleLoad(control, userContext, sender) { var t1 = sender.findName("txt1"); t1.Text = "TextBlock1 has changed"; }
ǝǿDzǯǼǷǶǯȅǷȎ dzǽȀȁȂǾǯ ǹ ȌǺǴǻǴǼȁȂ ȂǾǿǯDZǺǴǼǷȎ Ȁ ǾǽǻǽȈȋȍ ǻǴȁǽdzǯ GetHost ǬǺǴǻǴǼȁȊ UI ǾǿǴdzǽȀȁǯDZǺȎȍȁ ǻǴȁǽdz GetHost ǞǽǺȂȆǷȁȋ ȄǽȀȁ ǝǼ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ dzǽȀȁȂǾǯ ǹ ȌǺǴǻǴǼȁȂ ȂǾǿǯDZǺǴǼǷȎ Silverlight DZ ǹǽȁǽǿǽǻ ǿǯȀǾǽǺǯDzǯǴȁȀȎ dzǯǼǼȊǸ ȌǺǴǻǴǼȁ. Ǭȁǽ ǽȀǽǰǴǼǼǽ ǾǽǺǴǶǼǽ, ǴȀǺǷ ȁǿǴǰȂǴȁȀȎ ǶǯǾǿǽȀǷȁȋ Ȃ ǽǰȉǴǹȁǯ ǼǴǹǽȁǽǿȊǴ ȀDZǴdzǴǼǷȎ ǼǯǾǿǷǻǴǿ ǼǽǻǴǿ DZǴǿȀǷǷ.
ǝǿDzǯǼǷǶǯȅǷȎ dzǽȀȁȂǾǯ ǹ ǿǽdzǷȁǴǺȋȀǹǽǻȂ ȌǺǴǻǴǼȁȂ Ȁ ǾǽǻǽȈȋȍ ǻǴȁǽdzǯ getParent ǑǽǶǻǽǵǼȊ ȀǺȂȆǯǷ ǹǽDzdzǯ ȁǿǴǰȂǴȁȀȎ ǽǰǿǯȁǷȁȋȀȎ ǹ ǿǽdzǷȁǴǺȍ ȌǺǴǻǴǼȁǯ UI ǞǽǺȂȆǴǼǷǴ ȀȀȊǺǹǷ Ǽǯ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight Ƿ ǶǯȁǴǻ ǷȀǾǽǺȋǶǽDZǯǼǷǴ findName dzǺȎ ǾǽǺȂȆǴǼǷȎ ǿǽdzǷȁǴǺȎ ȎDZǺȎǴȁȀȎ ǽȆǴǼȋ ǼǴ ȌȃȃǴǹȁǷDZǼȊǻ ȀǾǽȀǽǰǽǻ ǾǽȌȁǽǻȂ ǾǿǴdzǽȀȁǯDZǺȎǴȁȀȎ ǻǴȁǽdz getParent ǞǽǺȂȆǷȁȋ ǿǽdzǷȁǴǺȎ Ǒ ȀǺȂȆǯǴ ȂȀ ǾǴȇǼǽDzǽ DZȊǾǽǺǼǴǼǷȎ ǽǼ DZǽǶDZǿǯȈǯǴȁ ȀȀȊǺǹȂ Ǽǯ ǿǽdzǷȁǴǺȋȀǹǷǸ ȌǺǴǻǴǼȁ DZ ǾǿǽȁǷDZǼǽǻ ȀǺȂȆǯǴ DZǽǶDZǿ ǯ ȈǯǴȁȀȎ null.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǻǴȁǽdzǽDZ GetValue Ƿ SetValue ǓǽȀȁȂǾ ǹ ǽǰȊȆǼȊǻ ȀDZǽǸȀȁDZǯǻ DZȀǴDzdzǯ ǻǽǵǼǽ ǽǿDzǯǼǷǶǽDZǯȁȋ Ȁ ǾǽǻǽȈȋȍ ȁǿǯdzǷȅǷǽǼǼǽDzǽ ȀǷǼȁǯǹȀǷȀǯ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ȁǽȆǹǷ ǽǰȉǴǹȁ.ǷǻȎȀDZǽǸȀȁDZǯ Ǽǽ dzǺȎ ǾǽdzdzǴǿǵǹǷ ǾǿǷȀǽǴdzǷǼǴǼǼȊȄ ȀDZǽǸȀȁDZ ȀȂȈǴȀȁ DZȂǴȁ ǯǺȋȁǴǿǼǯȁǷDZǼǯȎ ǻǴȁǽdzǷǹǯ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǻǴȁǽdzǯ GetValue ǞǽǺȂȆǷȁȋ ǶǼǯȆǴǼǷǴ ǜǯǾǿǷǻǴǿ ǴȀǺǷ ǼǴǽǰȄǽdzǷǻǽ ǽǰǿǯȁǷȁȋȀȎ ǹ ȀDZǽǸȀȁDZȂ Canvas.Top DZȊ ǼǴ ǻǽǵǴȁǴ ȀdzǴǺǯȁȋ Ȍȁǽ ȆǴǿǴǶ ǽǰȉǴǹȁ.Canvas.Top Ǒ Ȍȁǽǻ ȀǺȂȆǯǴ dzǽǺǵǴǼ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ȀǷǼȁǯǹȀǷȀ ǽǰȉǴǹȁ.GetValue("Canvas.Top"). GetValue ȁǯǹǵǴ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ dzǽȀȁȂǾǯ ǹ ǼǴǾǿǷȀǽǴdzǷǼǴǼǼȊǻ ǾǿǽȀȁȊǻ ȀDZǽǸȀȁDZǯǻ ǹǯǹ Ȍǹ DZǷDZǯǺǴǼȁ ǼǽȁǯȅǷǷ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ȁǽȆǹǷ
136
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǏǼǯǺǽDzǷȆǼǽ ǻǽǵǼǽ ǾǿǷǻǴǼȎȁȋ ǻǴȁǽdz SetValue (ǖǯdzǯȁȋ ǶǼǯȆǴǼǷǴ dzǺȎ ǶǯdzǯǼǷȎ ǶǼǯȆǴǼǷȎ ǹǯǹ ǾǿǽȀȁǽDzǽ ȁǯǹ Ƿ ǾǿǷȀǽǴdzǷǼǴǼǼǽDzǽ ȀDZǽǸȀȁDZǯ Ǭȁǽȁ ǻǴȁǽdz ǾǿǷǼǷǻǯǴȁ dzDZǯ ǾǯǿǯǻǴȁǿǯ ǞǴǿDZȊǸ ² ǷǻȎ ȀDZǽǸȀȁDZǯ Ƿ DZȁǽ ǿǽǸ ² ǾǿǷȀDZǯǷDZǯǴǻǽǴ ǶǼǯȆǴǼǷǴ ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ var t1 = ctrl.content.findName("txt1"); t1.setValue("Canvas.Top",20);
ǞǿǷǻǴȆǯǼǷǴ ǓǺȎ dzǽȀȁȂǾǯ Ƿ ǶǯdzǯǼǷȎ ǶǼǯȆǴǼǷǸ ǾǿǷȀǽǴdzǷǼǴǼȊȄ ȀDZǽǸȀȁDZ ǻǽǵǼǽ ȁǯǹǵǴ ǾǿǷǻǴǼȎȁȋ ȀǷǼȁǯǹȀǷȀ Ȁ ǹDZǯdzǿǯȁǼȊǻǷ ȀǹǽǰǹǯǻǷ. ǜǯǾǿǷǻǴǿ t>´Canvas.Topµ@
ǗȀǾǽǺȋǶǽDZǯǼǷǴ SetFontSource ǬǺǴǻǴǼȁ TextBlock ǾǽdzdzǴǿǵǷDZǯǴȁ dzǽǾǽǺǼǷȁǴǺȋǼȊǸ ǻǴȁǽdz SetFontSource (ǖǯdzǯȁȋ ǷȀȁǽȆǼǷǹ ȇǿǷȃȁǯ ǹǽ ȁǽǿȊǸ ǾǽǶDZǽǺȎǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋ DZ TextBlock ǶǯDzǿȂǵǴǼǼȊǸ ȇǿǷȃȁ Ǘȁǯǹ ǴȀǺǷ dzǺȎ ǽȁǽǰǿǯǵǴǼǷȎ ȁǴǹȀȁǯ DZȊ ȄǽȁǷȁǴ ǷȀǾǽǺȋǶǽDZǯȁȋ ǼǽDZȊǸ ȇǿǷȃȁ ² ǼǯǾǿǷǻǴǿ ǴȀǺǷ ǼǴǽǰȄǽdzǷǻǽ ǾǽdzdzǴǿǵǷDZǯȁȋ Ǽǯǰǽǿ ǷǼǽȀȁǿǯǼǼȊȄ ȀǷǻDZǽǺǽDZ ȁǯǹǽǸ ǹǯǹ ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ȎǶȊǹǽDZ ǑǽȀȁǽȆǼǽǸ ǏǶǷǷ ² DZȊ ǻǽǵǴȁǴ ȀǹǯȆǯȁȋ Ȍȁǽȁ ȇǿǷȃȁ Ȁ Ǿǽ ǻǽȈȋȍ ǽǰȉǴǹȁǯ Downloader Ƿ ǾǴǿǴdzǯȁȋ Ȍȁǽȁ ǽǰȉǴǹȁ DZ ǻǴȁǽdz SetFontSource ǞǽȀǺǴ ȌȁǽDzǽ TextBlock ȀǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋ dzǯǼǼȊǸ ȇǿǷȃȁ ǓǺȎ ǾǿǷǻǴǼǴǼǷȎ ȌȁǽDzǽ ǻǴȁǽdzǯ ǼǴǽǰȄǽdzǷǻǽ ǽǰǺǯdzǯȁȋ ǾǿǯDZǯǻǷ Ǽǯ ǿǯȀǾǿǽ ȀȁǿǯǼǴǼǷǴ ȇǿǷȃȁǯ ǷǺǷ ǴDzǽ ǾǽdzǻǼǽǵǴȀȁDZǯ ǓǯǺǴǴ ǾǿǷDZǴdzǴǼ ǾǿǷǻǴǿ ǷȀǾǽǺȋǶǽDZǯǼǷȎ ǻǴȁǽdzǯ SetFontSource Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ ǷǻǴǴȁȀȎ XAMLdzǽǹȂǻǴǼȁ ǽǾǷȀǯǼǼȊǸ Ȁ ǾǽǻǽȈȋȍ Expression Blend DZ ǹǽȁǽǿǽǻ ǴȀȁȋ ǼǴǹǽȁǽǿȊǸ ȁǴǹȀȁ Ǽǯ ǹǷȁǯǸȀǹǽǻ ȎǶȊ ǹǴ
Ǒ Silverlight 2 ǷǻǴǴȁȀȎ ȀȁǯǼdzǯǿȁǼȊǸ ȇǿǷȃȁ dzǺȎ ȌȁǷȄ ȀǷǻDZǽǺǽDZ. ǔȀǺǷ ȁǿǴǰȂǴȁȀȎ ǽȁǽǰǿǯǵǯȁȋ ǷȄ ǽȀǽǰȊǻ ȇǿǷȃȁǽǻ ǹǽȁǽǿȊǸ DZǴǿǽȎȁǼǽ ǼǴ dzǽȀȁȂǾǴǼ Ǽǯ DZȀǴȄ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǷȄ ǹǽǻǾȋȍȁǴǿǯȄ ǻǽǵǼǽ ȀǹǯȆǯȁȋ Ȍȁǽȁ ȇǿǷȃȁ Ȁ ǾǽǻǽȈȋȍ ǽǰȉǴǹȁǯ Downloader Ǒ ǾǿǷDZǴdzǴǼǼǽǻ DZȊȇǴ XAML-ǹǽdzǴ ǰȊǺ ǽǾǷȀǯǼ ǽǰǿǯǰǽȁȆǷǹ Ȁǽ ǰȊȁǷȎ handleIt Ǒǽȁ Ȍȁǯ ȃȂǼǹȅǷȎ ǶȉȘȈȉȖȚȟȐȒ șȖȉȣȚȐȧ Ȍȓȧ ȐȕȐȞȐȈȓȐȏȈȞȐȐ Ȑ ȊȣȗȖȓȕȍȕȐȧ ȏȈȗȘȖșȈ ȕȈ șȒȈȟȐȊȈȕȐȍ ȜȈȑȓȈ ȠȘȐȜȚȈ function handleIt(sender, eventArgs) { ǰȏȊȓȍȒȈȍȔ șșȣȓȒț ȕȈ ȥȓȍȔȍȕȚ țȗȘȈȊȓȍȕȐȧ var control = sender.getHost(); ǹȖȏȌȈȍȔ ȖȉȢȍȒȚ Downloader. var downloader = control.createObject("downloader"); // ǬȖȉȈȊȓȧȍȔ șȖȉȣȚȐȍ Completed. downloader.addEventListener("Completed", "onCompleted"); // ǰȕȐȞȐȈȓȐȏȐȘțȍȔ ȏȈȗȘȖș Downloader. downloader.open("GET", "MyFontName.TTF"); // ǪȣȗȖȓȕȧȍȔ ȏȈȗȘȖș Downloader. downloader.send(); }
ǓǯǼǼȊǸ ǹǽdz ǽǰǴȀǾǴȆǷDZǯǴȁ ȀǽǶdzǯǼǷǴ ǽǰȉǴǹȁǯ ǶǯDzǿȂǶǹǷ Ǭȁǽȁ ǽǰȉǴǹȁ ȀǹǯȆǷDZǯǴȁ ȇǿǷȃȁ Ƿ ǽǾǷȀȊDZǯǴȁ ǽǰ ǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ onCompleted Ǿǽ ǶǯDZǴǿȇǴǼǷǷ ǹǽȁǽǿȊǸ ǰȂdzǴȁ ǽǰǿǯǰǯȁȊDZǯȁȋ ȀǽǰȊȁǷǴ Completed, ȃǽǿǻǷǿȂǴǻǽǴ Ǿǽ ǶǯDZǴǿȇǴǼǷǷ ǶǯDzǿȂǶǹǷ Ǭȁǽ ȀǽǰȊȁǷǴ ǰȂdzǴȁ ǶǯdzǯDZǯȁȋ DZ ǹǯȆǴȀȁDZǴ ǷȀȁǽȆǼǷǹǯ ȇǿǷȃȁǯ dzǺȎ TextBlock dzǽǾǽǺǼǷȁǴǺȋǼȊǸ ȇǿǷȃȁ Ƿ ȁǽDzdzǯ Silverlight ǰȂdzǴȁ ȃǽǿǻǷǿǽDZǯȁȋ DZǷǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ǹǷ ȁǯǸȀǹǷȄ ǷǴǿǽDzǺǷȃǽDZ ǷȀǾǽǺȋǶȂȎ Ȍȁǽȁ ǼǽDZȊǸ ǷȀȁǽȆǼǷǹ ȇǿǷȃȁǯ. // ǶȉȘȈȉȖȚȟȐȒ șȖȉȣȚȐȧ Completed. function onCompleted(sender, eventArgs) { // ǰȏȊȓȍȒȈȍȔ ȖȉȢȍȒȚ TextBlock.
ǒǺǯDZǯ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰǿǯȂǶǴǿǯ 6LOYHUOLJKW
137
var myTextBlock = sender.findName("myTextBlock"); // ǬȖȉȈȊȓȧȍȔ ȜȈȑȓȣ ȠȘȐȜȚȖȊ, șȖȌȍȘȎȈȡȐȍșȧ Ȋ ȏȈȋȘțȎȍȕȕȖȔ ȖȉȢȍȒȚȍ // Ȋ ȒȖȓȓȍȒȞȐȦ ȠȘȐȜȚȖȊ ȚȐȗȈ TextBlock. myTextBlock.setFontSource(sender); // ǯȈȌȈȍȔ șȊȖȑșȚȊț FontFamily țȌȖȉȕȖȍ Ȍȓȧ ȗȖȓȤȏȖȊȈȚȍȓȧ ȐȔȧ ȠȘȐȜȚȈ. myTextBlock.fontFamily = "Simhei"; }
ǠǽǰȊȁǷȎ ȌǺǴǻǴǼȁǽDZ UI ǬǺǴǻǴǼȁȊ UI ǾǽdzdzǴǿǵǷDZǯȍȁ ǿȎdz ȀǽǰȊȁǷǸ ǹǽȁǽǿȊǴ ǻǽDzȂȁ ǰȊȁȋ ǯȀȀǽȅǷǷǿǽDZǯǼȊ Ȁ ȃȂǼǹȅǷȎǻǷ JavaScript ǺǷǰǽ ȆǴǿǴǶ AddEventListener dzǺȎ dzǽǰǯDZǺǴǼǷȎ ǷȄ DZǽ DZǿǴǻȎ DZȊǾǽǺǼǴǼǷȎ ǺǷǰǽ ǾȂȁǴǻ ǷȀǾǽǺȋǶǽDZǯǼǷȎ Ȁǽǽȁ DZǴȁȀȁDZȂȍȈǴDzǽ ǯȁǿǷǰȂȁǯ XAML dzǺȎ dzǽǰǯDZǺǴǼǷȎ ǷȄ DZǽ DZǿǴǻȎ ǿǯǶǿǯǰǽȁǹǷ ǜǯǾǿǷǻǴǿ ȆȁǽǰȊ ǯȀȀǽȅǷǷǿǽ DZǯȁȋ ȀǽǰȊȁǷǴ MouseLeftButtonDown ǜǯǵǯȁǷǴ ǺǴDZǽǸ ǹǼǽǾǹǷ ǻȊȇǷ Ȁ ǾǽǻǽȈȋȍ JavaScript ǾǿǷǻǴǼȎǴȁȀȎ ǻǴȁǽdz AddEventListener: t1.addEventListener("MouseLeftButtonDown", handleMouseDown);
ǦȁǽǰȊ ǯȀȀǽȅǷǷǿǽDZǯȁȋ ȀǽǰȊȁǷǴ DZ XAML ǻǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ ǯȁǿǷǰȂȁ ǷǻȎ ǹǽȁǽǿǽDzǽ ǯǼǯǺǽDzǷȆǼǽ ǷǻǴǼǷ ǿǯȀȀǻǯȁǿǷDZǯǴǻǽDzǽ ȀǽǰȊȁǷȎ ǼǯǾǿǷǻǴǿ ©MouseLeftButtonDownª ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ:
ǬǺǴǻǴǼȁ UI ǾǽdzdzǴǿǵǷDZǯǴȁ ȀǺǴdzȂȍȈǷǴ ȀǽǰȊȁǷȎ: x
GotFocus (ǞǽǺȂȆǴǼǷǴ ȃǽǹȂȀǯ) Ǭȁǽ ȀǽǰȊȁǷǴ ȃǽǿǻǷǿȂǴȁȀȎ, ǹǽDzdzǯ ȌǺǴǻǴǼȁ ǾǽǺȂȆǯǴȁ ȃǽǹȂȀ ǻȊȇǷ.
x
KeyDown (ǜǯǵǯȁǷǴ ǹǺǯDZǷȇǷ) Ǭȁǽ ȀǽǰȊȁǷǴ DZǽǶǼǷǹǯǴȁ dzǺȎ ȌǺǴǻǴǼȁǯ ǼǯȄǽdzȎȈǴDzǽȀȎ DZ ȃǽǹȂȀǴ ǾǿǷ ǼǯǵǯȁǷǷ ǹǺǯDZǷȇǷ ǝǰǿǯǰǽȁȆǷǹ dzǯǼǼǽDzǽ ȀǽǰȊȁǷȎ ǾǿǷǼǷǻǯǴȁ dzDZǯ ǾǯǿǯǻǴȁǿǯ. ǞǴǿDZȊǸ ǾǯǿǯǻǴȁǿ, sender (ǽȁǾǿǯDZǷȁǴǺȋ), ǾǿǴdzȀȁǯDZǺȎǴȁ ȀȀȊǺǹȂ Ǽǯ ǽǰȉǴǹȁ, ȀȃǽǿǻǷǿǽDZǯDZȇǷǸ ȀǽǰȊȁǷǴ. ǑȁǽǿǽǸ ǾǯǿǯǻǴȁǿ ² ǽǰȉǴǹȁ KeyEventArgs, ǷǻǴȍȈǷǸ ǿȎdz ȀǽǰȀȁDZǴǼǼȊȄ ȀDZǽǸȀȁDZ. ǝdzǼǽ ǷǶ ǼǷȄ ²key (ǹǺǯDZǷȇǯ), ȎDZǺȎǴȁȀȎ ȅǴǺȊǻ ǶǼǯȆǴǼǷǴǻ, ǾǿǴdzȀȁǯDZǺȎȍȈǷǻ ǼǯǵǯȁȂȍ ǹǺǯDZǷȇȂ. Ǭȁǽ ǶǼǯȆǴǼǷǴ ǼǴ ȎDZǺȎǴȁȀȎ ȄǯǿǯǹȁǴǿǼȊǻ dzǺȎ ǽǾǴǿǯȅǷǽǼǼǽǸ ȀǷȀȁǴǻȊ, Ƿ ȀǽǽȁDZǴȁȀȁDZǷȎ ǻǴǵdzȂ ǼǷǻ Ƿ ǹǽǼǹǿǴȁǼȊǻǷ ǹǺǯDZǷȇǯǻǷ ǻǽǵǼǽ ǼǯǸȁǷ DZ Silverlight SDK. ǓǿȂDzǽǴ ȀDZǽǸȀȁDZǽ ² platformKeyCode (ǹǽdz ǹǺǯDZǷȇǷ dzǺȎ ǹǽǼǹǿǴȁǼǽǸ ǝǠ ǽȁǼǽȀǷȁȀȎ ǹ ǽǾǴǿǯȅǷǽǼǼǽǸ ȀǷȀȁǴǻǴ. ǙǿǽǻǴ ȃǯǹȁǷȆǴȀǹǽǸ ǹǺǯDZǷȇǷ, ǾǿǴdzǽȀȁǯDZǺȎȍȁȀȎ ǐȂǺǴDZȊ ȀDZǽǸȀȁDZǯ shift Ƿ ctrl. ǝǼǷ ǾǽǹǯǶȊDZǯȍȁ ǰȊǺǷ ǺǷ ǼǯǵǯȁȊ ǹǺǯDZǷȇǷ Shift Ƿ Ctrl. (ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ Ȍȁǽ ȀǽǰȊȁǷǴ ǼǴ ȃǽǿǻǷǿȂǴȁȀȎ ǹǽDzdzǯ Silverlight DZȊǾǽǺǼȎǴȁȀȎ DZ ǾǽǺǼǽȌǹǿǯǼǼǽǻ ǿǴǵǷǻǴ.)
x
KeyUp (ǢdzǴǿǵǷDZǯǴǻǯȎ ǹǺǯDZǷȇǯ ǽȁǾȂȈǴǼǯ) Ǭȁǽ ȀǽǰȊȁǷǴ DZǽǶǼǷǹǯǴȁ dzǺȎ ȌǺǴǻǴǼȁǯ ǼǯȄǽdzȎȈǴDzǽ ȀȎ DZ ȃǽǹȂȀǴ ǹǽDzdzǯ ȂdzǴǿǵǷDZǯǴǻǯȎ ǹǺǯDZǷȇǯ ǽȁǾȂȀǹǯǴȁȀȎ. ǝǼǽ ǾǿǴdzȂȀǻǯȁǿǷDZǯǴȁ DZȀǴ ȁǴ ǵǴ dzDZǯ Ǿǯǿǯ ǻǴȁǿǯ Ȇȁǽ Ƿ ȀǽǰȊȁǷǴ KeyDown. (ǖǯǻǴȁȋȁǴ, Ȇȁǽ Ȍȁǽ ȀǽǰȊȁǷǴ ǼǴ ȃǽǿǻǷǿȂǴȁȀȎ ǹǽDzdzǯ Silverlight DZȊǾǽǺ ǼȎǴȁȀȎ DZ ǾǽǺǼǽȌǹǿǯǼǼǽǻ ǿǴǵǷǻǴ.)
x
Loaded Ǭȁǽ ȀǽǰȊȁǷǴ ȃǽǿǻǷǿȂǴȁȀȎ, ǹǽDzdzǯ ȀǽdzǴǿǵǷǻǽǴ Silverlight ǶǯDzǿȂǵǴǼǽ DZ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight Ƿ ǾǿǽDZǴdzǴǼ ǴDzǽ ȀǷǼȁǯǹȀǷȆǴȀǹǷǸ ǿǯǶǰǽǿ, Ǽǽ ǾǴǿǴdz ȃǽǿǻǷǿǽDZǯǼǷǴǻ ǴDzǽ DZǷǶȂǯǺȋǼǽDzǽ ǾǿǴdz ȀȁǯDZǺǴǼǷȎ.
x
LostFocus (ǞǽȁǴǿȎ ȃǽǹȂȀǯ) Ǭȁǽ ȀǽǰȊȁǷǴ, ǾǿǽȁǷDZǽǾǽǺǽǵǼǽǴ GotFocus ǽǼǽ ȃǽǿǻǷǿȂǴȁȀȎ ǹǽDzdzǯ ǽǰȉǴǹȁ ȁǴǿȎǴȁ ȃǽǹȂȀ.
x
MouseEnter (ǑȄǽdz ǹȂǿȀǽǿǯ ǻȊȇǷ) Ǭȁǽ ȀǽǰȊȁǷǴ ȃǽǿǻǷǿȂǴȁȀȎ, ǹǽDzdzǯ ǹȂǿȀǽǿ ǻȊȇǷ DZȄǽdzǷȁ DZ Dzǿǯ ǼǷȅȊ ǽǰȉǴǹȁǯ.
x
MouseLeave (ǑȊȄǽdz ǹȂǿȀǽǿǯ ǻȊȇǷ) Ǭȁǽ ȀǽǰȊȁǷǴ, ǾǿǽȁǷDZǽǾǽǺǽǵǼǽǴ MouseEnter: ǽǼǽ ȃǽǿǻǷǿȂ ǴȁȀȎ ǹǽDzdzǯ ǹȂǿȀǽǿ ǻȊȇǷ ǾǽǹǷdzǯǴȁ ǽǰǺǯȀȁȋ ǽDzǿǯǼǷȆǷDZǯȍȈȂȍ ǽǰȉǴǹȁ.
x
MouseLeftButtonDown Ǭȁǽ ȀǽǰȊȁǷǴ DZǽǶǼǷǹǯǴȁ ǾǿǷ ǼǯǵǯȁǷǷ ǾǽǺȋǶǽDZǯȁǴǺǴǻ ǺǴDZǽǸ ǹǼǽǾǹǷ ǻȊȇǷ ǹǽDzdzǯ ǹȂǿȀǽǿ ǼǯȄǽdzǷȁȀȎ Ǽǯdz ȌǺǴǻǴǼȁǽǻ UI.
x
MouseLeftButtonUp ǢdzǴǿǵǷDZǯǴǻǯȎ ǺǴDZǯȎ ǹǼǽǾǹǯ ǻȊȇǷ ǽȁǾȂȈǴǼǯ ǾǿǷ ǽȁǾȂȀǹǯǼǷǷ ȂdzǴǿǵǷDZǯǴǻǽǸ ǺǴDZǽǸ ǹǼǽǾǹǷ ǻȊȇǷ.
Ǭȁǽ ȀǽǰȊȁǷǴ DZǽǶǼǷǹǯǴȁ
138
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
x
MouseMove (ǞǴǿǴǻǴȈǴǼǷǴ ǻȊȇǷ) ȌǺǴǻǴǼȁȂ UI.
Ǭȁǽ ȀǽǰȊȁǷǴ ȃǽǿǻǷǿȂǴȁȀȎ ǾǿǷ ǾǴǿǴǻǴȈǴǼǷǷ ǹȂǿȀǽǿǯ Ǿǽ
ǟǴǯǺǷǶǯȅǷȎ ǾǴǿǴǻǴȈǴǼǷȎ ȌǺǴǻǴǼȁǽDZ ǻǴȁǽdzǽǻ ©Drag-and-Dropª Ǡ ǾǽǻǽȈȋȍ ǽǰǿǯǰǽȁȆǷǹǽDZ ȀǽǰȊȁǷǸ ǻȊȇǷ Ƿ ǻǴȁǽdzǽDZ Silverlight CaptureMouse ǞǴǿǴȄDZǯȁȊDZǯȁȋ ȀǽǰȊȁǷȎ ǻȊȇǷ Ƿ ReleaseMouseCapture ǞǿǷǽȀȁǯǼǽDZǷȁȋ ǾǴǿǴȄDZǯȁ ȀǽǰȊȁǷǸ ǻȊȇǷ ǻǽǵǼǽ ǿǴǯǺǷǶǽDZǯȁȋ ǾǴǿǴ ǻǴȈǴǼǷǴ ȌǺǴǻǴǼȁǽDZ ǻǴȁǽdzǽǻ ©drag-and-dropª ǷǺǷ ǾǴǿǴȁǯȀǹǷDZǯǼǷǴǻ DZ Silverlight. ǞǿǴǵdzǴ DZȀǴDzǽ dzǯDZǯǸȁǴ ǿǯȀȀǻǽȁǿǷǻ XAML-dzǽǹȂǻǴǼȁ ȀǽdzǴǿǵǯȈǷǸ ǼǴȀǹǽǺȋǹǽ ȃǷDzȂǿ ǹǽȁǽǿȊǴ ǻǽDzȂȁ ǾǴ ǿǴǻǴȈǯȁȋȀȎ Ǿǽ ȄǽǺȀȁȂ ǻǴȁǽdzǽǻ ©drag-and-dropª ǝǰǿǯǰǽȁȆǷǹǷ ȀǽǰȊȁǷǸ ǻȊȇǷ MouseLeftButtonDown, MouseLeftButtonUp Ƿ MouseMove DZ ȌȁǷȄ ȃǷDzȂǿǯȄ ȀDZȎǶǯǼȊ Ȁ ȃȂǼǹȅǷȎǻǷ onMouseDown, onMouseUp Ƿ onMouseMove ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ
ǡǴǾǴǿȋ ǿǯȀȀǻǽȁǿǷǻ ǹǯǵdzȂȍ ȃȂǼǹȅǷȍ-ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ DZ ǽȁdzǴǺȋǼǽȀȁǷ ǠǼǯȆǯǺǯ ǽǰǿǯȁǷǻȀȎ ǹ ǽǰǿǯ ǰǽȁȆǷǹȂ ȀǽǰȊȁǷȎ MouseDown ǜǯǵǯȁǷǴ ǹǼǽǾǹǷ ǻȊȇǷ ǞǿǷ ǾǴǿǴȁȎDzǷDZǯǼǷǷ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ dzǽǺǵǴǼ ©DZǺǯdzǴȁȋª ȀǽǰȊȁǷȎǻǷ ǻȊȇǷ ȁǯǹǷǻ ǽǰǿǯǶǽǻ ǷȀǾǽǺȋǶȂǴȁȀȎ ǻǴȁǽdz captureMouse ǡǯǹǵǴ ǼǴǽǰȄǽdzǷǻǽ Ƕǯ ǾǽǻǷǼǯȁȋ ǷȀȄǽdzǼȊǴ ȁǽȆǹǷ ǾǴǿǴdz ǾǴǿǴȁȎDzǷDZǯǼǷǴǻ Ȍȁǯ ǷǼȃǽǿǻǯȅǷȎ ȁǯǹǵǴ ǰȂdzǴȁ ȀǽȄǿǯǼȎȁȋȀȎ ǽǰǿǯǰǽȁ ȆǷǹǽǻ ȀǽǰȊȁǷȎ ǜǯǹǽǼǴȅ Ȁ ǾǽǻǽȈȋȍ ǰȂǺǴDZǽǸ ǾǴǿǴǻǴǼǼǽǸ isMouseDown ǹǼǽǾǹǯ ǻȊȇǷ Ǽǯǵǯȁǯ ǻȊ ǽǰǽǶǼǯȆǯǴǻ Ȇȁǽ ǹǼǽǾǹǯ ǻȊȇǷ Ǽǯǵǯȁǯ var beginX; var beginY; var isMouseDown = false; function onMouseDown(sender, mouseEventArgs) { beginX = mouseEventArgs.getPosition(null).x; beginY = mouseEventArgs.getPosition(null).y; isMouseDown = true; sender.captureMouse(); }
ǝǾǴǿǯȅǷȎ ©drag-and-dropª ǶǯǹǺȍȆǯǴȁȀȎ DZ ǾǴǿǴǻǴȈǴǼǷǷ ȌǺǴǻǴǼȁǯ Ȁ ǾǽǻǽȈȋȍ ǻȊȇǷ ǞǽȌȁǽǻȂ ǹǽDzdzǯ DZǽǶǼǷǹǯǴȁ ȀǽǰȊȁǷǴ MouseMove ȁǴǹȂȈǷǴ ǹǽǽǿdzǷǼǯȁȊ ǹȂǿȀǽǿǯ ǻȊȇǷ ǶǯǾǽǻǷǼǯȍȁȀȎ ȆȁǽǰȊ ǶǯȁǴǻ ǷȀ ǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ ȁǽDzǽ ǹȂdzǯ dzǽǺǵǴǼ ǰȊȁȋ ǾǴǿǴǻǴȈǴǼ ȌǺǴǻǴǼȁ ǡǴǹȂȈǷǴ Ȅ- Ƿ Ȃ-ǹǽǽǿdzǷǼǯȁȊ ǹȂǿȀǽǿǯ ǻȊȇǷ ǾǽǺȂȆǯǴǻ ǷǶ ǽǰȉǴǹȁǯ mouseEventArgs Ǒ ǾǿǷǻǴǿǴ DZȊǾǽǺǼȎ ǴȁȀȎ ǾǴǿǴȁȎDzǷDZǯǼǷǴ ǽǰȉǴǹȁǯ Ellipse, ȁ.Ǵ ǽǼ ȎDZǺȎǴȁȀȎ sender ǖǯdzǯȁȋ ǴDzǽ ȀDZǽǸȀȁDZǯ Top Ƿ Left ǻǽǵǼǽ dzǽǰǯDZ ǺȎȎ ǾǿǷǿǯȈǴǼǷǴ ǹǽǽǿdzǷǼǯȁ ǹ ǷȀȄǽdzǼȊǻ Ȅ- Ƿ Ȃ-ǹǽǽǿdzǷǼǯȁǯǻ
ǒǺǯDZǯ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰǿǯȂǶǴǿǯ 6LOYHUOLJKW
139
ǡǯǹǵǴ ǶǯǻǴȁȋȁǴ Ȇȁǽ ȀǽǰȊȁǷǴ onMouseMove ǰȂdzǴȁ ȀȃǽǿǻǷǿǽDZǯǼǽ ǼǴǶǯDZǷȀǷǻǽ ǽȁ ȁǽDzǽ DZȊǾǽǺǼȎǴȁȀȎ ǺǷ ǾǴǿǴȁȎDzǷDZǯǼǷǴ ǷǺǷ ǼǴȁ ǾǽȌȁǽǻȂ dzǺȎ ǾǿǽDZǴǿǹǷ ǷȀǾǽǺȋǶȂǴȁȀȎ ȀǽǰȊȁǷǴ isMouseDown ǞǽǻǼǷȁǴ ǽǼǽ ǰȊ Ǻǽ ǶǯdzǯǼǽ DZ ǾǿǴdzȊdzȂȈǴǻ ǽǰǿǯǰǽȁȆǷǹǴ ȀǽǰȊȁǷȎ MouseDown.) function onMouseMove(sender, mouseEventArgs) { if (isMouseDown == true) { var currX = mouseEventArgs.getPosition(null).x; var currY = mouseEventArgs.getPosition(null).y; sender["Canvas.Left"] += currX - beginX; sender["Canvas.Top"] += currY - beginY; beginX = currX; beginY = currY; } }
ǜǯǹǽǼǴȅ ǹǽDzdzǯ ǹǼǽǾǹǯ ǻȊȇǷ ǽȁǾȂȈǴǼǯ ǰȂdzǴȁ ǾǿǷǽȀȁǯǼǽDZǺǴǼǽ ǽȁȀǺǴǵǷDZǯǼǷǴ ȀǽǰȊȁǷǸ ǻȊȇǷ Ƿ ǾǴǿǴ ǻǴǼǼǯȎ isMouseDown DZǽǶDZǿǯȈǴǼǯ DZ ǷȀȄǽdzǼǽǴ ȀǽȀȁǽȎǼǷǴ ǬǺǺǷǾȀ ǽȀȁǯǼǴȁȀȎ Ǽǯ ǼǽDZǽǻ ǻǴȀȁǴ. function onMouseUp(sender, mouseEventArgs) { isMouseDown = false; sender.releaseMouseCapture(); }
ǜǯ ǿǷȀ 6- ǾǽǹǯǶǯǼǽ ȌǺǺǷǾȀǯ dzǺȎ ǹǽȁǽǿȊȄ ǯǹȁǷDZǷǿǽDZǯǼǯ DZǽǶǻǽǵǼǽȀȁȋ ǾǴǿǴǻǴȈǴǼǷȎ ǻǴȁǽdzǽǻ ©dragand-dropª ǜǯ ǿǷȀ 6- ǾǽǹǯǶǯǼǽ ǿǯǶǻǴȈǴǼǷǴ ȌȁǷȄ ȌǺǺǷǾȀǽDZ ǾǽȀǺǴ ǾǴǿǴȁȎDzǷDZǯǼǷȎ.
ǟǗǠ 6 4 ǦǴȁȊǿǴ ȌǺǺǷǾȀǯ dzǺȎ ǹǽȁǽǿȊȄ ǯǹȁǷDZǷǿǽDZǯǼǯ DZǽǶǻǽǵǼǽȀȁȋ ǾǴǿǴǻǴȈǴǼǷȎ ǻǴȁǽdzǽǻ ©drag and dropª.
140
ǑDZǴdzǴǼǷǴ DZ Silverlight 2
ǟǗǠ 6 5 ǞǴǿǴǻǴȈǴǼǷǴ ȌǺǺǷǾȀǽDZ ǻǴȁǽdzǽǻ ©drag and dropª.
ǖǯǹǺȍȆǴǼǷǴ Ǒ dzǯǼǼǽǸ DzǺǯDZǴ ǿǯȀȀǻǽȁǿǴǼǯ ǽǰȉǴǹȁǼǯȎ ǻǽdzǴǺȋ Silverlight Ƿ DZǽǶǻǽǵǼǽȀȁȋ ǴǴ ǷȀǾǽǺȋǶǽDZǯǼǷȎ ǾǿǷ Ǿǿǽ DzǿǯǻǻǷǿǽDZǯǼǷǷ Ǽǯ JavaScript. ǑȊ ȂǶǼǯǺǷ ǹǯǹ ǿǯǶǻǴȀȁǷȁȋ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight DZ ǰǿǯȂǶǴǿǴ DZǹǺȍȆǯȎ ȁǽ ǹǯǹ ǷǼǷȅǷǯǺǷǶǷǿǽDZǯȁȋ ǴDzǽ Ƿ Ƕǯdzǯȁȋ ǷȀȄǽdzǼǽǴ ȀǽȀȁǽȎǼǷǴ Ȁ ǾǽǻǽȈȋȍ ǴDzǽ ǻǽdzǴǺǷ ȀDZǽǸȀȁDZ ǐȊǺǽ ǾǽǹǯǶǯǼǽ ǹǯǹ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǻǽǵǴȁ ǰȊȁȋ ǼǯȀȁǿǽǴǼ Ȁ ǾǽǻǽȈȋȍ ǹǽǼȁǴǹȀȁǯ Ƿ ȀǾǴȅǷǯǺȋǼȊȄ ǾǯǿǯǻǴȁǿǽDZ ǡǯǹǵǴ ǾǿǴdzȀȁǯDZǺǴǼǯ ǾǽǺǼǯȎ ǾǽdzdzǴǿǵǷDZǯǴǻǯȎ Ƿǻ ǻǽdzǴǺȋ ȀDZǽǸȀȁDZ ǻǴȁǽdzǽDZ Ƿ ȀǽǰȊȁǷǸ. ǙǿǽǻǴ ȁǽDzǽ DZȊ ǼǯȂȆǷǺǷȀȋ ǿǴǯǺǷǶǽDZȊDZǯȁȋ ȀǽǰȀȁDZǴǼǼȊǸ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷǸ Ƿ ǷȀǾǽǺȋǶǽDZǯȁȋ ǽȀǼǽDZǼǽǸ ȀȁǯǼdzǯǿȁǼȊǸ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷǸ ǛȊ ǿǯȀȀǻǽȁǿǴǺǷ ǹǯǹ dzǽǰǯDZǺȎȁȋ DZ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ DZǼǴȇǼǴǴ ȀǽdzǴǿǵǷǻǽǴ Ȁ ǾǽǻǽȈȋȍ ǽǰȉǴǹȁǯ Downloader Ƿ ǹǯǹ ǾǴǿǴȄDZǯȁȊDZǯȁȋ ȀǽǰȊȁǷȎ ǹǽȁǽǿȊǴ ǽǼ ȃǽǿǻǷǿȂǴȁ dzǺȎ ǽǰǴȀǾǴȆǴǼǷȎ ǽǰǿǯȁǼǽǸ ȀDZȎǶǷ ǽ ǾǿǽȅǴȀȀǴ ǶǯDzǿȂǶǹǷ ǑȊ ǾǽǶǼǯǹǽǻǷǺǷȀȋ Ȁ ǾǿǴdzǺǯDzǯǴǻȊǻǷ XAML ȌǺǴǻǴǼȁǯǻǷ UI Ȁ ǾǿǴdzǽȀȁǯDZǺȎǴǻȊǻǷ ǷǻǷ ǻǴȁǽdzǯǻǷ ȀǽǰȊȁǷȎǻǷ Ƿ ȀDZǽǸȀȁDZǯǻǷ Ƿ DZǽǶǻǽǵǼǽȀȁȎǻǷ ǷȄ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ ǡǴǾǴǿȋ ǹǽDzdzǯ DZȊ ǾǽǶǼǯǹǽǻǷǺǷȀȋ Ȁ Silverlight Ƿ ǴDzǽ DZǽǶǻǽǵǼǽȀȁȎǻǷ ǾǿǷȇǺǽ DZǿǴǻȎ ǾǴǿǴȄǽdzǷȁȋ Ǽǯ ȀǺǴ dzȂȍȈǷǸ ȂǿǽDZǴǼȋ Ƿ ǷǶȂȆǷȁȋ ǰǽDzǯȁȊǸ Ƿ ǻǽȈǼȊǸ Ǽǯǰǽǿ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ Ƿ ǻǽdzǴǺȋ ǾǿǽDzǿǯǻǻǷǿǽ DZǯǼǷȎ ǾǿǴdzǺǯDzǯǴǻȊǴ Silverlight 2. Ǘ ǼǯȆǼǴǻ ǻȊ Ȍȁǽ DZ ȀǺǴdzȂȍȈǴǸ DzǺǯDZǴ Ȁ ǰǯǶǽDZǽDzǽ Ǽǯǰǽǿǯ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ Silverlight.
ǒǺǯDZǯ 7
ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight: ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ ǹǽǻǾǽǼǽDZǹǷ Silverlight 2 ǾǽȀȁǯDZǺȎǴȁȀȎ Ȁ dzDZȂǻȎ ǽȀǼǽDZǼȊǻǷ ȀǰǽǿǹǯǻǷ DZ ǹǽȁǽǿȊȄ ȀǽdzǴǿǵǯȁȀȎ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ dzǺȎ ǷȀǾǽǺȋǶǽDZǯǼǷȎ DZ DZǯȇǷȄ ǾǿǷǺǽǵǴǼǷȎȄ Ǭȁǽ core controls (ǽȀǼǽDZǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Ƿ extended controls (dzǽǾǽǺǼǷȁǴǺȋǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ǝǼǷ ȎDZǺȎȍȁȀȎ dzǽǾǽǺǼǴǼǷǴǻ ǹ ǾǿǽȀȁǿǯǼȀȁDZȂ ǷǻǴǼ System.Windows.Forms ȀǽdzǴǿǵǯȈǴǻȂ ǰǯǶǽDZȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Ǒ dzǯǼǼǽǸ DzǺǯDZǴ ǰȂdzȂȁ ǾǿǴdzȀȁǯDZǺǴǼȊ ȀǺǴdzȂȍȈǷǴ ǽȀǼǽDZǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Ƿ ǽǾǷȀǯǼȊ DZǽǶǻǽǵǼǽ ȀȁǷ ǷȄ ǷȀǾǽǺȋǶǽDZǯǼǷȎ DZ Silverlight: x
Button
x
CheckBox
x
HyperlinkButton
x
Image
x
ListBox
x
RadioButton
x
TextBlock
x
TextBox
ǛȊ ǿǯȀȀǻǽȁǿǷǻ ȀǾǴȅǷǯǺȋǼȊǴ ȀDZǽǸȀȁDZǯ ǻǴȁǽdzȊ Ƿ ȀǽǰȊȁǷȎ ǾǿǴdzǽȀȁǯDZǺȎǴǻȊǴ ǹǯǵdzȊǻ ǷǶ ȌȁǷȄ ȌǺǴǻǴǼ ȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǯ ȁǯǹǵǴ ȀDZǽǸȀȁDZǯ ǻǴȁǽdzȊ Ƿ ȀǽǰȊȁǷȎ ǽǰȈǷǴ dzǺȎ DZȀǴȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǗǶǺǽǵǴǼ ǼǯȎ DZ dzǯǼǼǽǸ DzǺǯDZǴ ǷǼȃǽǿǻǯȅǷȎ ǼǴ dzǽǺǵǼǯ ǰȊȁȋ ǴdzǷǼȀȁDZǴǼǼȊǻ ǷȀȁǽȆǼǷǹǽǻ ǾǿǷ ǿǯǰǽȁǴ Ȁ ǺȍǰȊǻ ǷǶ dzǯǼǼȊȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ Ǽǽ ǶdzǴȀȋ ǾǿǷDZǽdzǷȁȀȎ dzǽȀȁǯȁǽȆǼǽ ǰǯǶǽDZȊȄ ȀDZǴdzǴǼǷǸ ȆȁǽǰȊ ǾǽdzȁǽǺǹǼȂȁȋ DZǯȀ Ƿ ǾǽǻǽȆȋ ǼǯȆǯȁȋ ȀǯǻǽȀȁǽȎȁǴǺȋǼȊǴ ȌǹȀǾǴǿǷǻǴǼȁȊ Ȁ ǼǷǻǷ
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Button Ǒ Silverlight ǹǼǽǾǹǯ ǿǴǯǺǷǶȂǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Button ǙǼǽǾǹǯ ǿǴǯDzǷǿȂǴȁ Ǽǯ DZDZǽdz ǾǽǺȋǶǽDZǯȁǴǺȎ Ȁ ȁǯǹǷȄ ȂȀȁǿǽǸȀȁDZ DZDZǽdzǯ ǹǯǹ ǻȊȇȋ ǹǺǯDZǷǯȁȂǿǯ ǷǺǷ ȀȁǷǺȂȀ ȃǽǿǻǷǿȂȎ ȀǽǰȊȁǷǴ Click ǨǴǺ Ȇǽǹ ǢȀǺǽDZǷȎ ȃǽǿǻǷǿǽDZǯǼǷȎ ǹǼǽǾǹǽǸ ȀǽǰȊȁǷȎ Click ǻǽDzȂȁ ǰȊȁȋ ǼǯȀȁǿǽǴǼȊ ǼǴȀǹǽǺȋǹǷǻǷ ȀǾǽȀǽǰǯǻǷ ǝǼǷ ǶǯdzǯȍȁȀȎ ȀDZǽǸȀȁDZǽǻ ClickMode ǟǴǵǷǻ ȈǴǺȆǹǯ ǹǽȁǽǿǽǴ ǻǽǵǴȁ ǾǿǷǼǷǻǯȁȋ ǶǼǯȆǴǼǷȎ Hover ǜǯDZǴ dzǴǼǷǴ Press ǜǯǵǯȁǷǴ Ƿ Release ǝȁǾȂȀȁǷȁȋ ǬȁǷ ǶǼǯȆǴǼǷȎ ǽǾǿǴdzǴǺȎȍȁ ǻǽǻǴǼȁ ȃǽǿǻǷǿǽDZǯǼǷȎ ȀǽǰȊ ȁǷȎ Click Ǒ ǾǴǿDZǽǻ ȀǺȂȆǯǴ Hover ǽǼǽ ȃǽǿǻǷǿȂǴȁȀȎ ǾǿǷ ǼǯDZǴdzǴǼǷǷ ǹȂǿȀǽǿǯ ǻȊȇǷ Ǽǯ ǹǼǽǾǹȂ Ǒǽ DZȁǽ ǿǽǻ ȀǺȂȆǯǴ Press, ǽǼǽ ȃǽǿǻǷǿȂǴȁȀȎ ǾǿǷ ǼǯǵǯȁǷǷ ǹǼǽǾǹǷ ǻȊȇǷ DZ ǻǽǻǴǼȁ ǹǽDzdzǯ ǹȂǿȀǽǿ ǼǯȄǽdzǷȁȀȎ Ǽǯ Button Ǒ ȁǿǴȁȋǴǻ ȀǺȂȆǯǴ Release, Ȍȁǽ ȀǽǰȊȁǷǴ DZǽǶǼǷǹǯǴȁ ǹǽDzdzǯ ǾǽǺȋǶǽDZǯȁǴǺȋ ǼǯǵǯǺ Ƿ ǽȁǾȂȀȁǷǺ ǹǼǽǾǹȂ ǻȊȇǷ ǾǿǷ ǼǯDZǴdzǴǼǼǽǻ Ǽǯ Button ǹȂǿȀǽǿǴ
Ǚǯǹ DZǷdzǷȁǴ dzǺȎ DZȀǴȄ ȌȁǷȄ ǹǼǽǾǽǹ ǽǾǿǴdzǴǺǴǼ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ Click Ƿ ǽdzǼǯ Ƿ ȁǯ ǵǴ ȃȂǼǹȅǷȎ Button Click, dzǺȎ ǹǯǵdzǽǸ ǷǶ ǼǷȄ Ǒǽȁ ǹǽdz ǽǰǿǯǰǽȁǹǷ ȌȁǽDzǽ ȀǽǰȊȁǷȎ Ǽǯ ȎǶȊǹǴ &:
142
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2 private void Button Click(object sender, RoutedEventArgs e) { Button b = (Button)sender; string strTest = b.Name; }
Ǭȁǽȁ ǹǽdz ǾǽȀȁǿǽǴǼ Ǿǽ ȁǷǾǷȆǼǽǻȂ ȇǯǰǺǽǼȂ ǽǰǿǯǰǽȁȆǷǹǯ ȀǽǰȊȁǷȎ ǝǼ ǾǿǷǼǷǻǯǴȁ ǽǰȉǴǹȁ ǽȁǾǿǯDZǷȁǴǺȎ ȀǽdzǴǿǵǯȈǷǸ ȀȀȊǺǹȂ Ǽǯ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǹǽȁǽǿȊǸ ȀȃǽǿǻǷǿǽDZǯǺ ȀǽǰȊȁǷǴ DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ ǽdzǼȂ ǷǶ ǹǼǽǾǽǹ Ƿ Ǽǯǰǽǿ ǯǿDzȂǻǴǼȁǽDZ ȀDZȎǶǯǼǼȊȄ Ȁ ȌȁǷǻ ȀǽǰȊȁǷǴǻ RoutedEventArgs ǹǽȁǽǿȊǸ DZǹǺȍȆǯǴȁ ǻǴȁǯ dzǯǼǼȊǴ ǽ ȀǽǰȊȁǷǷ ǑȊ ǶǯǻǴȁǷȁǴ Ȇȁǽ DZ dzǯǼǼǽǻ ȌǹǶǴǻǾǺȎǿǴ ǽǰȉȎDZǺǴǼ ȁǽǺȋǹǽ ǽdzǷǼ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ Ǭȁǽ dzǴǺǯǴȁ ǹǽdz ǯǹ ǹȂǿǯȁǼȊǻ Ƿ ǾǽǼȎȁǼȊǻ ǙǽǼǴȆǼǽ DZȊ ǶǯȄǽȁǷȁǴ DZȊȎȀǼǷȁȋ ǹǯǹǽǸ ǷǶ ȌǺǴǻǴǼȁǽDZ ȀȃǽǿǻǷǿǽDZǯǺ ȀǽǰȊȁǷǴ dzǺȎ ȌȁǽDzǽ ǾǿǷDzǽdzǷȁȀȎ ǽȁǾǿǯDZǷȁǴǺȋ ǝȁǾǿǯDZǷȁǴǺȋ ² Ȍȁǽ ǽǰȉǴǹȁ ȁǷǾǯ Object ǾǽȌȁǽǻȂ ȆȁǽǰȊ ǷǶDZǺǴȆȋ ǷǶ ǼǴDzǽ ȄǯǿǯǹȁǴǿǼȊǴ dzǺȎ ǹǼǽǾǽǹ ȀDZǽǸȀȁ DZǯ ǴDzǽ ǾǿǽȀȁǽ ǾǿǷDZǽdzȎȁ ǹ ȁǷǾȂ Button Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ ǾǽȀǺǴ ǾǿǷDZǴdzǴǼǷȎ ȌȁǽDzǽ ǽǰȉǴǹȁǯ ǹ ȁǷǾȂ Button ǻȊ ǻǽǵǴǻ ǾǽǺȂȆǷȁȋ ǴDzǽ ǷǻȎ ǔȀǺǷ ǶǯǾȂȀȁǷȁȋ ǾǿǷǺǽǵǴǼǷǴ ȀǴǸȆǯȀ ǻǽǵǼǽ ǰȂdzǴȁ ȂDZǷdzǴȁȋ ȁǿǷ ǹǼǽǾǹǷ Ƿ ȁǽ ǹǯǹ ȀDZǽǸȀȁDZǽ ClickMode ǯȀȀǽȅǷǷǿǽDZǯǼǼǽǴ Ȁ ǹǯǵdzǽǸ ǷǶ ȌȁǷȄ ǹǼǽǾǽǹ ǽǰȂȀǺǽDZǺǷDZǯǴȁ ǷȄ ǿǯǶǼǽǴ ǾǽDZǴ dzǴǼǷǴ ǓǽǾǽǺǼǷȁǴǺȋǼȊǻ ǽȆǴǼȋ ǾǽǺǴǶǼȊǻ ȀDZǽǸȀȁDZǽǻ ȎDZǺȎǴȁȀȎ IsEnabled ǏǹȁǷDZǷǿǽDZǯǼ ǔȀǺǷ ǴǻȂ ǶǯdzǯǼǽ ǶǼǯ ȆǴǼǷǴ false ǹǼǽǾǹǯ ǽȁǽǰǿǯǵǯǴȁȀȎ Ǽǯ ȌǹǿǯǼǴ Ǽǽ DZȊDzǺȎdzǷȁ ǼǴǯǹȁǷDZǼǽǸ Ƿ ǼǴ ȃǽǿǻǷǿȂǴȁ ȀǽǰȊȁǷȎ ǜǯdzǾǷȀȋ Ǽǯ ǹǼǽǾǹǴ ǶǯdzǯǴȁȀȎ ȀDZǽǸȀȁDZǽǻ Content ǠǽdzǴǿǵǷǻǽǴ Ǒ ǹǯȆǴȀȁDZǴ ǴDzǽ ǶǼǯȆǴǼǷȎ ǻǽǵǴȁ ǰȊȁȋ Ƕǯ dzǯǼ ǾǿǽȀȁǽǸ ȁǴǹȀȁ ǹǽȁǽǿȊǸ ǰȂdzǴȁ ǽȁǽǰǿǯǵǯȁȋȀȎ ǹǯǹ ǼǯǶDZǯǼǷǴ ǹǼǽǾǹǷ ǝdzǼǯǹǽ Button ȁǯǹǵǴ ȎDZǺȎǴȁȀȎ ǹǽǼȁǴǸǼǴǿǽǻ ǾǽȌȁǽǻȂ ǴǴ ȀǽdzǴǿǵǷǻǽǴ ǻǽǵǼǽ ǼǯȀȁǿǽǷȁȋ Ȁ ǾǽǻǽȈȋȍ XAML. Ǒǽȁ ǾǿǷǻǴǿ ǹǼǽǾǹǷ (ȂǵǯȀǼǽ ǼǴǹǿǯȀǷDZǽǸ), ȀǽdzǴǿǵǷǻǽǴ ǹǽȁǽǿǽǸ ǽǾǷȀǯǼǽ Ȁ ǾǽǻǽȈȋȍ XAML:
Ǚǯǹ DZǷdzǷȁǴ Ȍȁǽ ǽǰǴȀǾǴȆǷDZǯǴȁ ȆǿǴǶDZȊȆǯǸǼȂȍ DzǷǰǹǽȀȁȋ DZ ǾǿǴdzȀȁǯDZǺǴǼǷǷ ǹǼǽǾǽǹ Ȇȁǽ ǾǽǶDZǽǺȎǴȁ ȀǽǶdzǯ DZǯȁȋ ǿǯǶǼǽǽǰǿǯǶǼȊǴ ǹǼǽǾǹǷ DZ ǑǴǰ-ǾǿǷǺǽǵǴǼǷȎȄ ǼǯǾǿǷǻǴǿ ȁǯǹǷǴ ǹǯǹ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǾǯǼǴǺǷ ǷǼȀȁ ǿȂǻǴǼȁǽDZ Microsoft Office 2007.
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ CheckBox CheckBox ² Ȍȁǽ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǾǿǴdzǽȀȁǯDZǺȎȍȈǷǸ ǾǽǺȋǶǽDZǯȁǴǺȍ ǽǾȅǷȍ dzǺȎ DZȊǰǽǿǯ ǝǰȊȆǼǽ ǽǼ ǾǿǴdzȀȁǯDZǺȎǴȁȀȎ DZ DZǷdzǴ ǾǿȎǻǽȂDzǽǺȋǼǷǹǯ DZ ǹǽȁǽǿǽǻ ǾǽǺȋǶǽDZǯȁǴǺȋ ǻǽǵǴȁ ȂȀȁǯǼǽDZǷȁȋ ǷǺǷ Ȃǰǿǯȁȋ ȃǺǯǵǽǹ ǝǼ ǷȀǾǽǺȋǶȂǴȁȀȎ ǹǽDzdzǯ ǷǻǴǴȁȀȎ ǿȎdz ǽǾȅǷǸ Ǽǯ DZȊǰǽǿ Ƿ ǻǽǵǼǽ DZȊǰǿǯȁȋ ǼǴȀǹǽǺȋǹǽ ǷǶ ǼǷȄ ǞǿǷ ȂȀȁǯǼǽDZǺǴǼǷǷ ȃǺǯǵǹǯ CheckBox ȃǽǿǻǷǿȂǴȁ ȀǽǰȊȁǷǴ Checked ǢȀȁǯǼǽDZǺǴǼ ǾǿǷ ȀǼȎȁǷǷ ȃǺǯǵǹǯ ȃǽǿǻǷǿȂǴȁȀȎ ȀǽǰȊȁǷǴ Unchecked ǠǼȎȁ ǡǯǹǵǴ CheckBox ȃǽǿǻǷǿȂǴȁ ȀǽǰȊȁǷǴ Click ǾǿǷ ǹǯǵdzǽǻ ȈǴǺȆǹǴ Ǿǽ ǼǴǻȂ ǏǼǯǺǽDzǷȆǼǽ ȌǺǴǻǴǼȁȂ ȂǾǿǯDZǺǴǼǷȎ Button, CheckBox ǷǻǴǴȁ ȀDZǽǸȀȁDZǽ ClickMode ǹǽȁǽǿǽǻȂ ǻǽ ǵǴȁ ǰȊȁȋ ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ Hover, Press ǷǺǷ Release, ǽǾǿǴdzǴǺȎȍȈǴǴ ȂȀǺǽDZǷȎ ȃǽǿǻǷǿǽDZǯǼǷȎ ȀǽǰȊȁǷȎ CheckBox ǻǽǵǴȁ ǰȊȁȋ ȃǺǯǵǹǽǻ Ȁ ȁǿǴǻȎ ȀǽȀȁǽȎǼǷȎǻǷ ǾǽdzdzǴǿǵǷDZǯǴȁȀȎ ǼǴǽǾǿǴdzǴǺǴǼǼǽǴ ȀǽȀȁǽȎǼǷǴ Ǭȁǽ ǽǾǿǴdzǴǺȎǴȁȀȎ ȀDZǽǸȀȁDZǽǻ IsThreeState ǡǿǷ ȀǽȀȁǽȎǼǷȎ ǔȀǺǷ Ȍȁǽ ȀǽȀȁǽȎǼǷǴ DZǹǺȍȆǴǼǽ Ƿ ǾǽǺȋǶǽDZǯȁǴǺȋ ǾǴ ǿǴDZǽdzǷȁ CheckBox DZ ǼǴǽǾǿǴdzǴǺǴǼǼǽǴ ȀǽȀȁǽȎǼǷǴ ȀDZǽǸȀȁDZȂ IsChecked ǾǿǷȀDZǯǷDZǯǴȁȀȎ ǶǼǯȆǴǼǷǴ null. ǖǼǯȆǴǼǷǴ CheckBox ǻǽǵǼǽ ǾǽǺȂȆǷȁȋ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ IsChecked ǜǴǽǰȄǽdzǷǻǽ ǰȊȁȋ ǽȀȁǽǿǽǵǼȊǻ Ȁ ȁǴǻ ǹǽDzdzǯ CheckBox ǼǯȄǽdzǷȁȀȎ DZ ǿǴǵǷǻǴ Ȁ ȁǿǴǻȎ ȀǽȀȁǽȎǼǷȎǻǷ ǾǽȀǹǽǺȋǹȂ ǴȀǺǷ CheckBox DZ ǼǴǽǾǿǴdzǴ ǺǴǼǼǽǻ ȀǽȀȁǽȎǼǷǷ ȀDZǽǸȀȁDZǽ IsChecked DZǽǶDZǿǯȈǯǴȁ ǶǼǯȆǴǼǷǴ null. ǏǼǯǺǽDzǷȆǼǽ ȌǺǴǻǴǼȁȂ ȂǾǿǯDZǺǴǼǷȎ Button, CheckBox ȎDZǺȎǴȁȀȎ ǹǽǼȁǴǸǼǴǿǽǻ ǝǼ ǷǻǴǴȁ ȀDZǽǸȀȁDZǽ Content Ȁ ǾǽǻǽȈȋȍ ǹǽȁǽǿǽDzǽ ǻǽǵǼǽ ǶǯdzǯDZǯȁȋ ǾǿǽȀȁȂȍ ȀȁǿǽǹȂ ȁǴǹȀȁǯ ǹǽȁǽǿǯȎ ǰȂdzǴȁ ǽȁǽǰǿǯǵǯȁȋȀȎ ǹǯǹ ǼǯdzǾǷȀȋ
ǒǺǯDZǯ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight: ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ ǹǽǻǾǽǼǽDZǹǷ
143
ǿȎdzǽǻ Ȁ ȃǺǯǵǹǽǻ ǷǺǷ ǻǽǵǼǽ ǿǯǶǻǴȀȁǷȁȋ XAML-ǹǽdz DZ dzǽȆǴǿǼǴǻ ȁǴDzǴ dzǺȎ ǾǽǺȂȆǴǼǷȎ ǰǽǺǴǴ ǼǯȀȊȈǴǼǼǽDzǽ ȌȃȃǴǹȁǯ Ǒǽȁ ǾǿǷǻǴǿ ǹǯǵdzǽDzǽ ǷǶ DZǯǿǷǯǼȁǽDZ:
ǞǿǷ ǽǰǿǯǰǽȁǹǴ ȀǽǰȊȁǷǸ Clicked, Checked Ƿ Unchecked, DZ ǹǯȆǴȀȁDZǴ sender ǰȂdzǴȁ DZȊȀȁȂǾǯȁȋ ǽǰȉǴǹȁ, ǹǽȁǽ ǿȊǸ ǼǴǽǰȄǽdzǷǻǽ ǾǿǷDZǴȀȁǷ ǹ ȁǷǾȂ CheckBox, ȆȁǽǰȊ ǾǽǺȂȆǷȁȋ dzǽȀȁȂǾ ǹ ȀDZǽǸȀȁDZǯǻ ȃǺǯǵǹǯ. ǜǷǵǴ ǾǿǷDZǴdzǴǼ ǾǿǷǻǴǿ: private void CheckBox Checked(object sender, RoutedEventArgs e) { CheckBox c = (CheckBox)sender; bool b = (bool)c.IsChecked; } private void CheckBox Unchecked(object sender, RoutedEventArgs e) { CheckBox c = (CheckBox)sender; bool b = (bool)c.IsChecked; }
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ HyperlinkButton HyperlinkButton ǒǷǾǴǿȀȀȊǺǹǯ ǽǰǴȀǾǴȆǷDZǯǴȁ Ǽǯ ȀȁǿǯǼǷȅǴ ȌǺǴǻǴǼȁ Ȁ DZǽǶǻǽǵǼǽȀȁȋȍ ȈǴǺȆǹǯ Ǿǽ ǼǴǻȂ dzǺȎ ǾǴǿǴȄǽdzǯ Ǿǽ URI ǶǯdzǯǼǼǽǻȂ ȀDZǽǸȀȁDZǽǻ NavigateUri (Uri ǾǴǿǴȄǽdzǯ). ǜǯǾǿǷǻǴǿ:
HyperlinkButton ² Ȍȁǽ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Ȁ ȀǽdzǴǿǵǷǻȊǻ ȁǴ ǽǼ ǻǽǵǴȁ ǷǻǴȁȋ ǾǿǽȀȁǽǴ ȀDZǽǸȀȁDZǽ Content ȀǽdzǴǿǵǯȈǴǴ ȁǴǹȀȁ ǹǽȁǽǿȊǸ ǰȂdzǴȁ ǽȁǽǰǿǯǵǯȁȋȀȎ dzǺȎ DzǷǾǴǿȀȀȊǺǹǷ ǷǺǷ ǴDzǽ ȀǽdzǴǿǵǷǻǽǴ ǻǽǵǴȁ ǰȊȁȋ ǼǯǻǼǽDzǽ ǰǽǺǴǴ ǼǯȀȊȈǴǼǼȊǻ Ƿ ǰǽǺǴǴ ǾǿǷDZǺǴǹǯȁǴǺȋǼȊǻ ǜǯǾǿǷǻǴǿ ǴȀǺǷ DZȊ ȄǽȁǷȁǴ ȆȁǽǰȊ DzǷǾǴǿȀȀȊǺǹǯ DZȊDzǺȎdzǴǺǯ ǹǯǹ ǿǷȀȂǼǽǹ Ȍȁǽ ǽȆǴǼȋ ǾǿǽȀȁǽ ǿǴǯǺǷǶǽDZǯȁȋ ǷȀǾǽǺȋǶȂȎ dzǽȆǴǿǼǷǸ ȌǺǴǻǴǼȁ DZ ǹǽȁǽǿǽǻ ǻǽǵǴȁ ǿǯȀǾǽǺǯDzǯȁȋȀȎ ǷǶǽǰǿǯǵǴǼǷǴ ǜǯ ǾǿǷǻǴǿ:
ǡǴǾǴǿȋ ǹǽDzdzǯ ǾǿǷǺǽǵǴǼǷǴ ǰȂdzǴȁ ǶǯǾȂȈǴǼǽ DZȊ ǾǽǺȂȆǷȁǴ ǷǶǽǰǿǯǵǴǼǷǴ ȈǴǺȆǽǹ Ǿǽ ǹǽȁǽǿǽǻȂ ǽǰǴȀǾǴȆǷȁ ǾǴǿǴȄǽdz Ǿǽ ǶǯdzǯǼǼǽǻȂ URL. ǠDZǽǸȀȁDZǽ TargetName ǽǾǿǴdzǴǺȎǴȁ DzdzǴ ǰȂdzǴȁ ǽȁǹǿȊDZǯȁȋȀȎ ȀǽdzǴǿǵǷǻǽǴ ǿǯȀǾǽǺǯDzǯȍȈǴǴȀȎ Ǿǽ ǶǯdzǯǼǼǽǻȂ URL ǓǺȎ DZȊDZǽdzǯ Ǽǯ ȌǹǿǯǼ ȀǽdzǴǿǵǷǻǽDzǽ URL dzǽȀȁȂǾǼȊ ȀǺǴdzȂȍȈǷǴ ǽǾȅǷǷ
144
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
x
blank
ǝȁǹǿȊDZǯǴȁ ǼǽDZǽǴ ǽǹǼǽ ǰǿǯȂǶǴǿǯ ǰǴǶ ǷǻǴǼǷ.
x
self ǖǯǻǴȈǯǴȁ ȁǴǹȂȈȂȍ HTML-ȀȁǯǼǷȅȂ ǼǽDZȊǻ ȀǽdzǴǿǵǷǻȊǻ. ǔȀǺǷ HTML-ȀȁǯǼǷȅǯ ǽȁǽǰǿǯǵǯǴȁȀȎ DZǽ ȃǿǴǸǻǴ, ǶǯǻǴȈǯǴȁȀȎ ȁǽǺȋǹǽ ȀǽdzǴǿǵǷǻǽǴ ǿǯǻǹǷ.
x
top ǖǯǻǴȈǯǴȁ ȁǴǹȂȈȂȍ HTML-ȀȁǯǼǷȅȂ ǼǽDZȊǻ ȀǽdzǴǿǵǷǻȊǻ. ǓǯǵǴ ǴȀǺǷ HTML-ȀȁǯǼǷȅǯ ǽȁǽǰǿǯǵǯ ǴȁȀȎ DZǽ ȃǿǴǸǻǴ, ǻǴǼȎǴȁȀȎ ȀǽdzǴǿǵǷǻǽǴ DZȀǴDzǽ ǽǹǼǯ ǰǿǯȂǶǴǿǯ.
x
parent
ǖǯǻǴȈǯǴȁ DZȀȍ HTML-ȀȁǯǼǷȅȂ.
ǔȀǺǷ ǷȀǾǽǺȋǶȂǴȁȀȎ ȃǿǴǸǻǽDZǯȎ ȀȁǿȂǹȁȂǿǯ ǻǽǵǼǽ ǶǯdzǯDZǯȁȋ ǷǻȎ ǷȀǾǽǺȋǶȂǴǻǽDzǽ ȃǿǴǸǻǯ Ǒǽȁ ǾǿǷǻǴǿ ǽǾǿǴdzǴǺȎȍȈǷǸ Ȇȁǽ ǹǽDzdzǯ ǾǽǺȋǶǽDZǯȁǴǺȋ DZȊǰǷǿǯǴȁ Ȍȁǽȁ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ dzǽǺǵǼǽ ǽȁ ǹǿȊDZǯȁȋȀȎ ǼǽDZǽǴ ǽǹǼǽ ǰǿǯȂǶǴǿǯ
ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ ȀǽǰȊȁǷǴ Click dzǺȎ HyperlinkButton ǰȂdzǴȁ ȃǽǿǻǷǿǽDZǯȁȋȀȎ ǾǴǿǴdz ǾǴǿǴȄǽdzǽǻ Ǿǽ ǶǯdzǯǼǼǽǻȂ URI Ǭȁǽ ǻǽǵǴȁ ǰȊȁȋ ǽȆǴǼȋ ǾǽǺǴǶǼȊǻ ǾǽȁǽǻȂ Ȇȁǽ ǽǰǴȀǾǴȆǷDZǯǴȁ ǶǯDZǴǿȇǴǼǷǴ ǺȍǰǽǸ ǾǿǴdz DZǯǿǷȁǴǺȋǼǽǸ ǽǰǿǯǰǽȁǹǷ ǾǴǿǴdz ǶǯDzǿȂǶǹǽǸ ǼǽDZǽDzǽ ȀǽdzǴǿǵǷǻǽDzǽ ǓǯǺǴǴ ǿǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ȀǽǰȊȁǷȎ Click ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ NavigateUri Ƕǯdzǯ Ǽǽ ǶǼǯȆǴǼǷǴ http://www.microsoft.com Ǽǽ ȃǯǹȁǷȆǴȀǹǷ ȀȁǿǯǼǷȅǯ ǾǴǿǴȄǽdzǷȁ Ǿǽ ǯdzǿǴȀȂ http://www.silverlight.net ǾǽȁǽǻȂ Ȇȁǽ Click DZȊǾǽǺǼȎǴȁȀȎ ǿǯǼȋȇǴ ǾǴǿǴȄǽdzǯ Ƿ ǻǴǼȎǴȁ ǶǼǯȆǴǼǷǴ NavigateUri. Ǒǽ-ǾǴǿDZȊȄ, ǿǯȀȀǻǽȁǿǷǻ XAML:
Ǘ ȁǴǾǴǿȋ ǽǰǿǯȁǷǻ DZǼǷǻǯǼǷǴ Ǽǯ DZȊdzǴǺǴǼǼȊǸ C#-ǹǽdz DZ ǹǽȁǽǿǽǻ ǽǰǿǯǰǯȁȊDZǯǴȁȀȎ ȀǽǰȊȁǷǴ HyperlinkButton Click: private void HyperlinkButton Click(object sender, RoutedEventArgs e) { HyperlinkButton h = (HyperlinkButton)sender; string strTest = h.NavigateUri.AbsoluteUri; if (strTest == "http://www.microsoft.com/") { h.NavigateUri = new Uri("http://www.silverlight.net"); } }
ǞǿǷ DZȊǾǽǺǼǴǼǷǷ ȌȁǽDzǽ ǹǽdzǯ DZȊ ȂDZǷdzǷȁǴ Ȇȁǽ ǼǴȀǻǽȁǿȎ Ǽǯ ȁǽ Ȇȁǽ dzǺȎ HyperlinkButton ǽǾǿǴdzǴǺǴǼ ǽdzǷǼ URL, DZ ȄǽdzǴ ǽǰǿǯǰǽȁǹǷ ȀǽǰȊȁǷȎ Click ǴǻȂ ǰȂdzǴȁ ǶǯdzǯǼ dzǿȂDzǽǸ URL Ƿ ǾǴǿǴȄǽdz ǰȂdzǴȁ DZȊǾǽǺǼǴǼ Ǿǽ ǼǽDZǽǻȂ URL.
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Image ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Image ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǽȁǽǰǿǯǵǴǼǷȎ ǷǶǽǰǿǯǵǴǼǷǸ ǝǼ ǻǽǵǴȁ ǾǿǷǼǷǻǯȁȋ ȃǽǿǻǯ ȁȊ ȃǯǸǺǽDZ .bmp, .jpg Ƿ .png ǞȂȁȋ ǹ ǷǶǽǰǿǯǵǴǼǷȍ ǶǯdzǯǴȁȀȎ ȀDZǽǸȀȁDZǽǻ Source ǜǯǾǿǷǻǴǿ
ǞǿǷǻǴȆǯǼǷǴ ǔȀǺǷ DZ ǹǽdzǴ dzǯǴȁȀȎ ȀȀȊǺǹǯ Ǽǯ ǼǴǾǽdzdzǴǿǵǷDZǯǴǻȊǸ ȃǽǿǻǯȁ, ǷǺǷ Source ǶǯdzǯǼ ǼǴȀǽǽȁDZǴȁȀȁ DZȂȍȈǷǻ ǽǰǿǯǶǽǻ, ǰȂdzǴȁ ȀȃǽǿǻǷǿǽDZǯǼǽ ȀǽǰȊȁǷǴ ImageFailed ǝȇǷǰǹǯ ǷǶǽǰǿǯǵǴǼǷȎ .
ǒǺǯDZǯ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight: ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ ǹǽǻǾǽǼǽDZǹǷ
145
ǔȀǺǷ ȃǯǹȁǷȆǴȀǹǷǴ ǿǯǶǻǴǿȊ ǷǶǽǰǿǯǵǴǼǷȎ ǽȁǺǷȆǯȍȁȀȎ ǽȁ ǶǯdzǯǼǼȊȄ dzǺȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Image ȁǴ ǴȀǺǷ ǷǻǴǴȁȀȎ ȌǺǴǻǴǼȁ Image ǿǯǶǻǴǿǽǻ 100 î 100 Ƿ DZ ǼǴDzǽ ǶǯDzǿȂǵǯǴȁȀȎ .jpg-ǷǶǽǰǿǯǵǴǼǷǴ 2000 î 2000 ǾǷǹȀǴǺǽDZ ȂǾǿǯDZǺȎȁȋ ǾǽDZǴdzǴǼǷǴǻ ǽȁǽǰǿǯǵǴǼǷȎ ǻǽǵǼǽ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ Stretch ǝǼǽ ǻǽǵǴȁ ǾǿǷ ǼǷǻǯȁȋ ȀǺǴdzȂȍȈǷǴ ǶǼǯȆǴǼǷȎ x
Fill ǗǶǻǴǼȎǴȁ ǿǯǶǻǴǿȊ ǷǶǽǰǿǯǵǴǼǷȎ ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ ǿǯǶǻǴǿǯǻ ǽǰǺǯȀȁǷ DZȊDZǽdzǯ ǷȀǾǽǺȋǶȂȎ ǼǴǶǯ DZǷȀǷǻǽǴ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷǴ Ǿǽ ǽȀȎǻ Ȅ Ƿ Ȃ.
x
Uniform ǗǶǻǴǼȎǴȁ ǿǯǶǻǴǿȊ ǷǶǽǰǿǯǵǴǼǷȎ ȁǯǹ ȆȁǽǰȊ ǽǼǽ ǾǽǻǴȀȁǷǺǽȀȋ DZ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Image, Ǽǽ ǾǿǷ Ȍȁǽǻ ȀǽȄǿǯǼȎǴȁ ǾǿǽǾǽǿȅǷǷ ǷǶǽǰǿǯǵǴǼǷȎ.
x
UniformToFill ǗǶǻǴǼȎǴȁ ǿǯǶǻǴǿȊ ǷǶǽǰǿǯǵǴǼǷȎ ȁǯǹ ȆȁǽǰȊ ǽǼǽ ǾǽǺǼǽȀȁȋȍ ǶǯǾǽǺǼǷǺǽ ǽǰǺǯȀȁȋ DZȊ DZǽdzǯ ǽǰǿǴǶǯȎ ǴDzǽ DZ ȀǺȂȆǯǴ ǼǴǽǰȄǽdzǷǻǽȀȁǷ.
x
None ǝȁǽǰǿǯǵǯǴȁ ǷǶǽǰǿǯǵǴǼǷǴ ǹǯǹ ǴȀȁȋ, Ȇȁǽ ǾǿǷDZǽdzǷȁ ǹ ǴDzǽ ǽǰǿǴǶǹǴ ǴȀǺǷ ǽǼǽ ǼǴ ǾǽǻǴȈǯǴȁȀȎ DZ ȌǺǴǻǴǼȁ Image.
ǦǯȀȁǽ ǷǶǽǰǿǯǵǴǼǷǴ ǼǴǽǰȄǽdzǷǻǽ Ƕǯdzǯȁȋ ǼǴ DZǽ DZǿǴǻȎ ǿǯǶǿǯǰǽȁǹǷ ȂǹǯǶȊDZǯȎ URI DZ XAML-ǹǽdzǴ ǯ ǽǾǿǴdzǴ ǺǷȁȋ ǴDzǽ DZǽ DZǿǴǻȎ DZȊǾǽǺǼǴǼǷȎ DZǽǶǻǽǵǼǽ ǹǯǹ ǿǴǶȂǺȋȁǯȁ ǽǰǿǯȈǴǼǷȎ ǹ ǰǯǶǴ dzǯǼǼȊȄ ǷǺǷ ȆǴDzǽ-ǺǷǰǽ Ǿǽ dzǽǰǼǽDzǽ Ǒ ȁǯǹǷȄ ȀǺȂȆǯȎȄ DZ ǹǯȆǴȀȁDZǴ ǷȀȁǽȆǼǷǹǯ dzǺȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Image ǷȀǾǽǺȋǶȂǴȁȀȎ ǹǺǯȀȀ BitmapImage ǾǿǽȀȁǿǯǼȀȁDZǯ ǷǻǴǼ System.Windows.Media.Imaging ǓǯǺǴǴ ǾǿǷDZǴdzǴǼ ǾǿǷǻǴǿ ȁǽDzǽ ǹǯǹ Ȍȁǽ dzǴǺǯǴȁȀȎ ǠǼǯȆǯǺǯ XAML:
ǖǯȁǴǻ DZ ȃǯǸǺǴ DZȊdzǴǺǴǼǼǽDzǽ C# ǹǽdzǯ ǼǴǽǰȄǽdzǷǻǽ ǾǽdzǹǺȍȆǷȁȋ ǾǿǽȀȁǿǯǼȀȁDZǽ ǷǻǴǼ: using System.Windows.Media.Imaging;
Ǘ DZǽȁ ǹǽdz, ǹǽȁǽǿȊǸ ǽǰǴȀǾǴȆǷȁ ǶǯDzǿȂǶǹȂ ǷǶǽǰǿǯǵǴǼǷȎ Ǿǽ URL ǾǿǷ ǶǯDzǿȂǶǹǴ ȀȁǿǯǼǷȅȊ: public Page(){ InitializeComponent(); this.Loaded += new RoutedEventHandler(Page Loaded); } void Page Loaded(object sender, RoutedEventArgs e) { Uri uri = new Uri("sl.jpg",UriKind.Relative); theImage.Source = new BitmapImage(uri); }
Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ ȀǽǶdzǯǴȁȀȎ ǼǽDZȊǸ ǽǰȉǴǹȁ Uri Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǾȂȁǷ ǹ ǷǶǽǰǿǯǵǴǼǷȍ ǑȁǽǿǽǸ ǾǯǿǯǻǴȁǿ DZ ǹǽǼȀȁǿȂǹȁǽǿǴ ² ǽǾȅǷȎ ǽǾǿǴdzǴǺȎȍȈǯȎ ǹǯǹ dzǽǺǵǴǼ DZȊȆǷȀǺȎȁȋȀȎ Uri ǗȀǾǽǺȋǶȂǴǻȊǸ URI ǻǽǵǴȁ ǰȊȁȋ ǽȁǼǽȀǷȁǴǺȋǼȊǻ DZ Ȍȁǽǻ ȀǺȂȆǯǴ ǾǽǷȀǹ ǶǯdzǯǼǼǽDzǽ ǿǴȀȂǿȀǯ ǰȂdzǴȁ DZǴȀȁǷȀȋ DZ ȁǽǻ ǵǴ ǹǯȁǯǺǽDzǴ DZ ǹǽȁǽǿǽǻ ǿǯȀǾǽǺǯDzǯǴȁȀȎ ǹǽǻǾǽǼǴǼȁ ǯǰȀǽǺȍȁǼȊǻ DZ Ȍȁǽǻ ȀǺȂȆǯǴ ǾǽǷȀǹ ǶǯdzǯǼǼǽDzǽ ǿǴȀȂǿȀǯ ǰȂdzǴȁ DZǴȀȁǷȀȋ ǼǯǾǿȎ ǻȂȍ ǾǽȌȁǽǻȂ ǻǴȀȁǽǾǽǺǽǵǴǼǷǴ dzǽǺǵǼǽ ȂǹǯǶȊDZǯȁȋȀȎ Ȁ ǾǿǷǻǴǼǴǼǷǴǻ ȀǷǼȁǯǹȀǷȀǯ http://ȀǴǿDZǴǿ/ǿǴȀȂǿȀ) ǷǺǷ ǹǽǻǰǷǼǯȅǷǴǸ ǾǴǿDZȊȄ dzDZȂȄ ǙǽDzdzǯ Uri ȀǽǶdzǯǼ ǽǼ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ȀǽǶdzǯǼǷȎ ǼǽDZǽDzǽ BitmapImage ǹǽȁǽǿȊǸ ǽǾǿǴdzǴǺȎǴȁȀȎ ǹǯǹ ǷȀȁǽȆǼǷǹ dzǺȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Image.
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ListBox ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ListBox ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ȀǽdzǴǿǵǷǻǽDzǽ DZ DZǷdzǴ ȂǾǽǿȎdzǽȆǴǼǼǽDzǽ ȀǾǷȀǹǯ Ǭȁǽ dzǽȀȁǯȁǽȆǼǽ DzǷǰǹǷǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ȁǯǹ Ȇȁǽ ȌǺǴǻǴǼȁȊ ȀǾǷȀǹǯ ǻǽDzȂȁ ȀǽǶdzǯDZǯȁȋȀȎ ǷǶ Ȁǽ dzǴǿǵǷǻǽDzǽ ǺȍǰǽDzǽ ȁǷǾǯ Ǽǽ ǽǰȊȆǼǽ ȀǾǷȀǽǹ ǽǰǿǯǶȂǴȁȀȎ ȌǺǴǻǴǼȁǯǻǷ ListBoxItem (ǬǺǴǻǴǼȁ ȀǾǷȀǹǯ ǹǯǹ DZ ȀǺǴdzȂȍȈǴǻ ǾǿǷǻǴǿǴ
146
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
ǑǽǶǻǽǵǼǽȀȁȋ DZȊǰǽǿǯ ȌǺǴǻǴǼȁǽDZ ǽǰǿǯǶȂȍȈǷȄ ListBox ǾǽǺȋǶǽDZǯȁǴǺǴǻ ǿǴǯǺǷǶȂǴȁȀȎ ǾǽȀǿǴdzȀȁDZǽǻ ȀǽǰȊ ȁǷȎ SelectionChanged ǑȊǰǿǯǼǼȊǸ ȌǺǴǻǴǼȁ ǷǶǻǴǼǴǼ Ƿ ȀDZǽǸȀȁDZǯ SelectedItem ǑȊǰǿǯǼǼȊǸ ȌǺǴǻǴǼȁ Ǒ ǾǿǴdzȊdzȂȈǴǻ ȃǿǯDzǻǴǼȁǴ XAML-ǹǽdzǯ ǽǰǿǯǰǽȁǹǽǸ ȀǽǰȊȁǷȎ SelectionChanged ǶǯǼǷǻǯǺȀȎ ǽǰǿǯǰǽȁȆǷǹ ǻǴ ȁǽdzǯ ListBox SelectionChanged Ǒǽȁ ǹǽdz: private void ListBox SelectionChanged( object sender, SelectionChangedEventArgs e) { ListBoxItem x = theList.SelectedItem as ListBoxItem; string strTest = x.Content.ToString(); }
ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ ȀDZǽǸȀȁDZǽ SelectedItem DZǽǶDZǿǯȈǯǴȁ object ǯ ǼǴ ListBoxItem ǾǽȁǽǻȂ Ȇȁǽ ǹǯǹ ȂǾǽ ǻǷǼǯǺǽȀȋ ǿǯǼǴǴ DZ ListBox ǻǽDzȂȁ ǿǯǶǻǴȈǯȁȋȀȎ ǿǯǶǼȊǴ ȁǷǾȊ ȀǽdzǴǿǵǷǻǽDzǽ ǞǽȌȁǽǻȂ DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ SelectedItem ǾǿǷDZǽdzǷȁȀȎ ǹ ListBoxItem. ǞǽǻǼǷȁǴ Ȇȁǽ DZ ListBox ǻǽǵǴȁ ǿǯȀǾǽǺǯDzǯȁȋȀȎ ǿǯǶǼǽǴ ȀǽdzǴǿǵǷǻǽǴ ǓǯǺǴǴ ǾǿǷDZǴdzǴǼ ǾǿǷǻǴǿ ǹǽDzdzǯ ListBox DZǹǺȍȆǯǴȁ ȀǽȀȁǯDZǼȊǴ ȌǺǴǻǴǼȁȊ ǽǰǿǯǶǽDZǯǼǼȊǴ ǹǽǻǾǽǼǴǼȁǯǻǷ StackPanel ǹǯǵdzȊǸ ǷǶ ǹǽȁǽǿȊȄ ȀǽdzǴǿǵǷȁ Rectangle, Image Ƿ TextBlock.
Ǚǯǹ ǰȂdzǴȁ DZȊDzǺȎdzǴȁȋ Ȍȁǽȁ ListBox ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 7-1.
ǟǗǠ 7 1 ListBox Ȁǽ ȀǺǽǵǼȊǻǷ ȌǺǴǻǴǼȁǯǻǷ.
ǠǽdzǴǿǵǷǻǽǴ ȁǯǹǷȄ ȀǺǽǵǼȊȄ ȌǺǴǻǴǼȁǽDZ ǹǯǹ ǾǿǴdzȀȁǯDZǺǴǼȊǴ ǶdzǴȀȋ ǻǽǵǼǽ ǾǽǺȂȆǷȁȋ ȀǺǴdzȂȍȈǷǻ ǽǰǿǯ Ƕǽǻ Ȁ ǾǽǻǽȈȋȍ SelectedItem ǾǽǺȂȆǷȁȋ ǹǽǼȁǴǸǼǴǿ DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ StackPanel Ƿ ǶǯȁǴǻ ǷǶDZǺǴȆȋ ǷǶ ǼǴDzǽ ǼǴǽǰȄǽdzǷǻǽǴ ȀǽdzǴǿǵǷǻǽǴ ǜǯǾǿǷǻǴǿ: StackPanel s = theList.SelectedItem as StackPanel; TextBlock t = s.Children[2] as TextBlock; string strTest = t.Text;
ǒǺǯDZǯ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight: ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ ǹǽǻǾǽǼǽDZǹǷ
147
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ RadioButton ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ RadioButton ǾǽdzǽǰǼǽ CheckBox ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ȃǷǹȀǷǿǽDZǯǼǷȎ DZȊǰǽǿǯ ǾǽǺȋǶǽDZǯ ȁǴǺȎ ǝdzǼǯǹǽ ǽȁǺǷȆǯǴȁȀȎ ǽȁ CheckBox ȁǴǻ Ȇȁǽ ǽǰȊȆǼǽ ǾǿǷǻǴǼȎǴȁȀȎ DZ ȀǷȁȂǯȅǷȎȄ ǹǽDzdzǯ ǾǽǺȋǶǽDZǯȁǴǺȋ dzǽǺǵǴǼ DZȊǰǿǯȁȋ ǴdzǷǼȀȁDZǴǼǼȊǸ DZǯǿǷǯǼȁ ǷǶ ǿȎdzǯ ǾǿǴdzǺǯDzǯǴǻȊȄ ǽǾȅǷǸ ǝdzǷǼ ǷǶ ȀǾǽȀǽǰǽDZ ȂǾǿǯDZǺǴǼǷȎ Ǽǯǰǽǿǽǻ ǽǾȅǷǸ Ȁ DZǽǶǻǽǵǼǽȀȁȋȍ ǴdzǷǼȀȁDZǴǼǼǽDzǽ DZȊǰǽǿǯ ² Ƕǯdzǯȁȋ ȌǺǴ ǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ RadioButton ȀǽǽȁDZǴȁȀȁDZȂȍȈǷǴ ǽǾȅǷȎǻ ǹǯǹ ȌǺǴǻǴǼȁȊ ǽdzǼǽDzǽ ȂǿǽDZǼȎ DZ ǹǽǼȁǴǸǼǴǿǴ ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ:
Ǒ dzǯǼǼǽǻ XAML-ǹǽdzǴ ǷǻǴǴȁȀȎ dzDZǯ ǹǽǼȁǴǸǼǴǿǯ StackPanel ǽdzǷǼ ǷǶ ǹǽȁǽǿȊȄ ǿǯȀǾǽǺǽǵǴǼ DZ dzǿȂDzǽǻ ǞǴǿ DZȊǸ ǹǽǼȁǴǸǼǴǿ ȀǽdzǴǿǵǷȁ ǽǾȅǷǷ Ƿ DZȁǽǿǽǸ ² ǽǾȅǷǷ Ƿ Ǒ ǿǴǶȂǺȋȁǯȁǴ ǾǽǺȋǶǽDZǯȁǴǺȋ ǻǽ ǵǴȁ DZȊǰǿǯȁȋ ȁǽǺȋǹǽ ǽdzǼȂ ǷǶ ǽǾȅǷǸ ǽȁ dzǽ Ƿ ȁǽǺȋǹǽ ǽdzǼȂ ǷǶ ǽǾȅǷǸ ǽȁ dzǽ Ǚǯǹ Ȍȁǽ ǿǯǰǽȁǯǴȁ ǾǿǴdz ȀȁǯDZǺǴǼǽ Ǽǯ ǿǷȀ 7-2.
ǟǗǠ 7 2 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ RadioButton.
ǙǿǽǻǴ ȁǽDzǽ ǽǾȅǷǷ ǻǽǵǼǽ ȀDzǿȂǾǾǷǿǽDZǯȁȋ ǶǯdzǯDZǯȎ dzǺȎ ǹǯǵdzǽDzǽ RadioButton ȀDZǽǸȀȁDZǽ GroupName ǗǻȎ DzǿȂǾǾȊ Ǒ ǾǿǴdzȊdzȂȈǴǻ ǾǿǷǻǴǿǴ DZ StackPanel ǿǯȀǾǽǺǯDzǯǺǷȀȋ ǽǾȅǷǷ - Ƿ Silverlight ǿǯǶǿǴȇǯǺ ǾǽǺȋǶǽ DZǯȁǴǺȍ ǾǿǷǺǽǵǴǼǷȎ DZȊǰǷǿǯȁȋ ȁǽǺȋǹǽ ǽdzǼȂ ǷǶ ǼǷȄ ǔȀǺǷ ǾǽȁǿǴǰǽDZǯǺǽȀȋ ǰȊ ǿǯǶdzǴǺǷȁȋ Ȍȁǽȁ Ǽǯǰǽǿ ǽǾȅǷǸ Ǽǯ dzDZǴ DzǿȂǾǾȊ ȆȁǽǰȊ ǾǽǺȋǶǽDZǯȁǴǺȋ ǻǽDz DZȊǰǷǿǯȁȋ ǽdzǼȂ ǷǶ ǽǾȅǷǸ Ƿ Ƿ ǽdzǼȂ ǷǶ ǽǾȅǷǸ Ƿ DZǻǴȀȁǽ ǹǽǼȁǴǸǼǴǿǯ ǻǽǵǼǽ ǰȊǺǽ ǰȊ ǷȀǾǽǺȋǶǽDZǯȁȋ DzǿȂǾǾȊ RadioButton.
148
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
Ǚǯǹ Ȍȁǽ DZȊDzǺȎdzǷȁ DZ dzǴǸȀȁDZǷǷ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 7-3.
ǟǗǠ 7 3 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ RadioButton Ȁ DzǿȂǾǾǯǻǷ.
ǏǼǯǺǽDzǷȆǼǽ ȌǺǴǻǴǼȁǯǻ ȂǾǿǯDZǺǴǼǷȎ Button Ƿ CheckBox, RadioButton ǷǻǴǴȁ ȀDZǽǸȀȁDZǽ ClickMode ǽǾǿǴdzǴ ǺȎȍȈǴǴ ǹǯǹǽǴ dzǴǸȀȁDZǷǴ ǾǽǺȋǶǽDZǯȁǴǺȎ ǾǿǷDZǽdzǷȁ ǹ ȃǽǿǻǷǿǽDZǯǼǷȍ ȀǽǰȊȁǷȎ Click ǔDzǽ DZǽǶǻǽǵǼȊǻǷ ǶǼǯ ȆǴǼǷȎǻǷ ȎDZǺȎȍȁȀȎ Hover, ǾǿǷ ǹǽȁǽǿǽǻ ȀǽǰȊȁǷǴ ȃǽǿǻǷǿȂǴȁȀȎ ȂǵǴ ǽȁ ȁǽDzǽ Ȇȁǽ ǾǽǺȋǶǽDZǯȁǴǺȋ ǾǿǽDZǽdzǷȁ ǹȂǿȀǽǿǽǻ Ǿǽ ȌǺǴǻǴǼȁȂ ȂǾǿǯDZǺǴǼǷȎ Press ǾǿǷ ǹǽȁǽǿǽǻ ȀǽǰȊȁǷǴ ȃǽǿǻǷǿȂǴȁȀȎ Ǿǽ ȈǴǺȆǹȂ ǹǼǽǾǹǷ ǻȊȇǷ Ǿǽ ȌǺǴǻǴǼȁȂ ȂǾǿǯDZǺǴǼǷȎ Ƿ Release, ǾǿǷ ǹǽȁǽǿǽǻ ǹǼǽǾǹǯ ǻȊȇǷ dzǽǺǵǼǯ ǰȊȁȋ Ǽǯǵǯȁǯ ǯ Ǿǽȁǽǻ ǽȁǾȂȈǴǼǯ ǾǿǷ ǼǯȄǽǵdzǴǼǷǷ ǹȂǿȀǽǿǯ ǻȊȇǷ Ǽǯ ǹǼǽǾǹǴ DZȊǰǽǿǯ ǡǯǹǵǴ ǯǼǯǺǽDzǷȆǼǽ ȌǺǴǻǴǼȁȂ ȂǾǿǯDZǺǴǼǷȎ CheckBox, ȀǽȀȁǽȎǼǷǴ DZȊǰǽǿǯ ǽȁdzǴǺȋǼǽDzǽ RadioButton ǻǽǵǴȁ ǰȊȁȋ ǾǿǽDZǴǿǴǼǽ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ IsChecked.
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ TextBlock ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ TextBlock ǷȀǾǽǺȋǶȂǴȁȀȎ DZ ǾǿǷǺǽǵǴǼǷȎȄ Silverlight dzǺȎ ǽȁǽǰǿǯǵǴǼǷȎ ȁǴǹȀȁǯ. Ǒ Ȁǯǻǽǻ ǾǿǽȀȁǽǻ ȀǺȂȆǯǴ, dzǺȎ ǽȁǽǰǿǯǵǴǼǷȎ ȁǴǹȀȁ dzǽȀȁǯȁǽȆǼǽ ǾǿǷǻǴǼǷȁȋ TextBlock Ȁ ǶǯdzǯǼǼȊǻ ȀDZǽǸȀȁ DZǽǻ Text. ǜǯǾǿǷǻǴǿ:
ǟǯǶǻǴǿ ȁǴǹȀȁǯ ǻǽǵǼǽ ǻǴǼȎȁȋ ǶǯdzǯDZǯȎ ȀDZǽǸȀȁDZǽ FontSize DZ ǾǷǹȀǴǺǯȄ ǗȀǾǽǺȋǶȂǴǻȊǸ ȇǿǷȃȁ ǽǾǿǴdzǴǺȎ ǴȁȀȎ ȀDZǽǸȀȁDZǽǻ FontFamily ǼǯǾǿǷǻǴǿ XAML-ǹǽdz dzǺȎ DZȊDZǽdzǯ ȁǴǹȀȁǯ ȇǿǷȃȁǽǻ Arial Black ǿǯǶǻǴǿǽǻ DZȊDzǺȎdzǴǺ ǰȊ ȁǯǹ
ǠDZǽǸȀȁDZǽ FontStyle ǽǾǿǴdzǴǺȎǴȁ ǹǯǹ ǰȂdzǴȁ DZȊDZǴdzǴǼ ȁǴǹȀȁ ǹȂǿȀǷDZǽǻ ǷǺǷ ǽǰȊȆǼȊǻ ȇǿǷȃȁǽǻ ǦȁǽǰȊ ȁǴǹȀȁ ǽȁǽǰǿǯǵǯǺȀȎ ǹȂǿȀǷDZǽǻ ȀDZǽǸȀȁDZȂ FontStyle ǶǯdzǯǴȁȀȎ ǶǼǯȆǴǼǷǴ Italic:
ǦȁǽǰȊ ǷȀǾǽǺȋǶǽDZǯȁȋ ǽǰȊȆǼȊǸ ȇǿǷȃȁ, ǻǽǵǼǽ Ƕǯdzǯȁȋ ȀDZǽǸȀȁDZȂ FontStyle ǶǼǯȆǴǼǷǴ Normal ǷǺǷ ǾǿǽȀȁǽ ǽȀȁǯDZǷȁȋ ǴDzǽ ǼǴǶǯdzǯǼǼȊǻ. ǟǯǶǿȊDZȊ Ȁȁǿǽǹ Ƿ ǷȀǾǽǺȋǶǽDZǯǼǷǴ ǿǯǶǼȊȄ ȇǿǷȃȁǽDZ dzǺȎ ǽȁǽǰǿǯǵǴǼǷȎ ȁǴǹȀȁǯ ǿǴǯǺǷǶȂǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ Ǿǽ dzȌǺǴǻǴǼȁǽDZ TextBlock: Ƿ Ǚǯǹ ȀǺǴdzȂǴȁ ǷǶ ǴDzǽ ǷǻǴǼǷ ȀǽǶdzǯǴȁ ǿǯǶǿȊDZȊ DZ ȁǴǹȀȁǴ Ȁ ǾǴǿǴǼǽȀǽǻ ǽȀȁǯǺȋǼǽDzǽ ȁǴǹȀȁǯ Ǽǯ ǼǽDZȂȍ ȀȁǿǽǹȂ
ǒǺǯDZǯ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight: ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ ǹǽǻǾǽǼǽDZǹǷ
149
ǝdzǼǯǹǽ TextBlock ǼǴ ȎDZǺȎǴȁȀȎ ȌǺǴǻǴǼȁǽǻ ȂǾǿǯDZǺǴǼǷȎ dzǺȎ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ȀǽdzǴǿǵǷǻǽDzǽ ǹǯǹ ǼǴǹǽȁǽǿȊǴ ǷǶ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǹǽȁǽǿȊǴ ǰȊǺǷ ǾǿǴdzȀȁǯDZǺǴǼȊ DZ dzǯǼǼǽǸ DzǺǯDZǴ ǿǯǼǴǴ ǞǽȌȁǽǻȂ ǴȀǺǷ ǼǴǽǰȄǽdzǷ ǻǽ ǾǿǴdzȀȁǯDZǷȁȋ ȁǴǹȀȁ ǷǼǯȆǴ ȆǴǻ DZȀǴ ǽȀȁǯǺȋǼǽǴ ȀǽdzǴǿǵǷǻǽǴ ȀDZǽǸȀȁDZǯ Text ǷȀǾǽǺȋǶȂǴȁȀȎ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Run: My Second Text My Third Text My Fourth Text
ǖǯǻǴȆǯȁǴǺȋǼǽǴ ǹǯȆǴȀȁDZǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Run DZ ȁǽǻ Ȇȁǽ ǽǼ ǾǽdzdzǴǿǵǷDZǯǴȁ ȁǴ ǵǴ ȀDZǽǸȀȁDZǯ ȇǿǷȃȁǯ ǿǯǶǻǴǿǯ ȅDZǴȁǯ Ƿ ȁdz Ȇȁǽ Ƿ TextBlock ǡǯǹǷǻ ǽǰǿǯǶǽǻ ǽǼ ǾǿǴdzǽȀȁǯDZǺȎǴȁ ȁǽȁ ǵǴ ȂǿǽDZǴǼȋ ȂǾǿǯDZǺǴǼǷȎ ǴDzǽ ȀǽdzǴǿǵǷǻȊǻ Ȇȁǽ Ƿ TextBlock Ǭȁǽ ǽǶǼǯȆǯǴȁ Ȇȁǽ ȁǴǹȀȁ TextBlock Ƿ ȁǴǹȀȁ ǽȁǽǰǿǯǵǯǴǻȊǸ Ȁ ǾǽǻǽȈȋȍ Run, ǾǽǺǼǽȀȁȋȍ ȀǽDzǺǯȀǽDZǯǼȊ ǝdzǼǽ ǷǶ ǽȁǺǷȆǷǸ Silverlight 2 ǽȁ Silverlight 1.0 DZ ȁǽǻ Ȇȁǽ TextBlock DZ Silverlight 2 ǰǽǺȋȇǴ ǼǴ ǽDzǿǯǼǷȆǴǼ dzǴDZȎȁȋȍ ȇǿǷȃȁǯǻǷ DZȀȁǿǽǴǼǼȊǻǷ DZ Silverlight. Silverlight 2 ǿȂǹǽDZǽdzȀȁDZȂǴȁȀȎ ǾǿǯDZǷǺǯǻǷ ǶǯǻǴȈǴǼǷȎ ȀǷȀ ȁǴǻǼȊȄ ȇǿǷȃȁǽDZ ǾǽȌȁǽǻȂ ǴȀǺǷ ȇǿǷȃȁ ǾǿǴdzȀȁǯDZǺǴǼ DZ ȀǷȀȁǴǻǴ ȁǴǹȀȁ ǰȂdzǴȁ ǽȁǽǰǿǯǵǴǼ ȌȁǷǻ ȇǿǷȃȁǽǻ ǴȀǺǷ ȇǿǷȃȁ ǼǴdzǽȀȁȂǾǴǼ DZ ȀǷȀȁǴǻǴ ǰȂdzǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ǿǴǶǴǿDZǼȊǸ ȇǿǷȃȁ ǽǾǿǴdzǴǺǴǼǼȊǸ ǽǾǴǿǯȅǷ ǽǼǼǽǸ ȀǷȀȁǴǻǽǸ Ǘȁǯǹ ǿǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ ǼǴǹǽȁǽǿǽDzǽ XAML ȀǽǶdzǯǼǼǽDzǽ dzǺȎ ǽȁǽǰǿǯǵǴǼǷȎ TextBlock DZ ǹǽȁǽǿǽǻ ȀǽdzǴǿ ǵǷȁȀȎ ȁǴǹȀȁ ǾǿǴdzȀȁǯDZǺǴǼǼȊǸ ȇǿǷȃȁǽǻ Webdings ǯ ȁǯǹǵǴ ǼǴǹǽȁǽǿȊǸ ȁǴǹȀȁ Ǽǯ ǹǷȁǯǸȀǹǽǻ ȎǶȊǹǴ Ƿ ǷDZǿǷ ȁǴ My Second Text ᚤ弗≑≃➢䟨㔁做 ʦʫʸʮ ʧʥʺʩʴʤ ʺʥʬʩʤʷʬʠʸʹʩʡ ʺʥʶʥʡʷʥ ʯʥʩʣ
Ǚǯǹ Ȍȁǽ DZȊDzǺȎdzǷȁ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 7- ǓǯǼǼǯȎ ǼǽDZǯȎ DZǽǶǻǽǵǼǽȀȁȋ ǯǰȀǽǺȍȁǼǽ ȂǾǿǽȀȁǷǺǯ ǿǯǶǿǯ ǰǽȁǹȂ Silverlight-ǾǿǷǺǽǵǴǼǷǸ Ȁ ǻǼǽDzǽȎǶȊȆǼȊǻ ǾǽǺȋǶǽDZǯȁǴǺȋȀǹǷǻ ǷǼȁǴǿȃǴǸȀǽǻ
ǟǗǠ 7 4 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀǾǴȅǷǯǺȋǼȊȄ ȇǿǷȃȁǽDZ DZ Silverlight.
150
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ TextBox ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ TextBox ǽǰǴȀǾǴȆǷDZǯǴȁ ǾǽǺȋǶǽDZǯȁǴǺȎǻ ǽǰǺǯȀȁȋ dzǺȎ DZDZǽdzǯ ȁǴǹȀȁǯ Ǒ ȀǯǻǽǸ ǾǿǽȀȁǽǸ ȃǽǿǻǴ TextBox ǾǿǴdzǽȀȁǯDZǺȎǴȁ ǽǰǺǯȀȁȋ DZ ǹǽȁǽǿȂȍ ǾǽǺȋǶǽDZǯȁǴǺȋ ǻǽǵǴȁ DZDZǴȀȁǷ ǽdzǼȂ ȀȁǿǽǹȂ ȁǴǹȀȁǯ ǜǯ ǾǿǷǻǴǿ
Ǭȁǽ ǽȆǴǼȋ ǾǿǽȀȁǽǸ StackPanel ȀǽdzǴǿǵǯȈǷǸ dzDZǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ TextBox ǜǯ ǿǷȀ 7- ǾǽǹǯǶǯǼǽ ǹǯǹ Ȍȁǽ ǰȂdzǴȁ DZȊDzǺȎdzǴȁȋ Ǒ ȁǴǹȀȁǽDZȊǴ ǾǽǺȎ DZDZǴdzǴǼȊ ǼǴǹǽȁǽǿȊǴ ǶǼǯȆǴǼǷȎ dzǺȎ dzǴǻǽǼȀȁǿǯȅǷǷ ȁǽDzǽ ǹǯǹ ǾǽǺȋ ǶǽDZǯȁǴǺȋ ǻǽDz ǰȊ ǶǯǾǽǺǼȎȁȋ TextBox DZ ǾǿǷǺǽǵǴǼǷǷ
ǟǗǠ 7 5 ǞǿǽȀȁȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ TextBox.
ǦȁǽǰȊ ȌȁǷ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ TextBox ǻǽDzǺǷ ǾǿǷǼǷǻǯȁȋ ǻǼǽDzǽȀȁǿǽǹǽDZȊǸ DZDZǽdz ǾǽǼǯdzǽǰǷȁȀȎ ȀdzǴǺǯȁȋ dzDZǴ DZǴȈǷ Ǒǽ-ǾǴǿDZȊȄ ǼǴǽǰȄǽdzǷǻǽ Ƕǯdzǯȁȋ DZȊȀǽȁȂ ǷǺǷ ǾǽǻǴȀȁǷȁȋ ǷȄ DZ ǹǽǼȁǴǸǼǴǿ ǽǰǴȀǾǴȆǷDZǯȍȈǷǸ Ƿǻ ǼǴȀȁǯǼdzǯǿȁǼȂȍ DZȊȀǽȁȂ ǖǯȁǴǻ ȀDZǽǸȀȁDZȂ AcceptsReturn ǓǽǾȂȀǹǯȍȁȀȎ ȀǷǻDZǽǺȊ DZǽǶDZǿǯȁǯ ǹǯǿǴȁǹǷ ǾǽȁǿǴ ǰȂǴȁȀȎ Ƕǯdzǯȁȋ ǶǼǯȆǴǼǷǴ True ǰǺǯDzǽdzǯǿȎ ȆǴǻȂ ȌȁǷ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ȀǻǽDzȂȁ ǾǿǷǼǷǻǯȁȋ ȀǷǻDZǽǺȊ DZǽǶDZǿǯȁǯ ǹǯǿǴȁǹǷ Ǧȁǽ ǰȂdzǴȁ ǾǽǺȂȆǴǼǽ DZ ǿǴǶȂǺȋȁǯȁǴ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 7-6.
ǒǺǯDZǯ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight: ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ ǹǽǻǾǽǼǽDZǹǷ
ǟǗǠ 7 6
151
ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ TextBox ǼǯȀȁǿǽǴǼǼȊǴ dzǺȎ ǻǼǽDzǽȀȁǿǽǹǽDZǽDzǽ DZDZǽdzǯ ȁǴǹȀȁǯ ǾǽǺȋǶǽDZǯȁǴǺǴǻ.
ǠDZǽǸȀȁDZǽ Text ȁǯǹǽDzǽ TextBox ǰȂdzǴȁ DZǽǶDZǿǯȈǯȁȋ ǽǰȉǴǹȁ ȁǷǾǯ String DZ ǹǽȁǽǿǽǻ ǹǯǵdzǯȎ Ȁȁǿǽǹǯ ǰȂdzǴȁ ǽȁ dzǴǺǴǼǯ ȀǷǻDZǽǺǽǻ ¶\r· ǙǯǵdzȊǸ ǿǯǶ ǾǿǷ ǷǶǻǴǼǴǼǷǷ ȁǴǹȀȁǯ DZ TextBox ȃǽǿǻǷǿȂǴȁȀȎ ȀǽǰȊȁǷǴ TextChanged ǡǴǹȀȁ ǷǶǻǴǼǴǼ ǖǯ ǻǴȁȋȁǴ Ȍȁǽ ǾǿǽǷȀȄǽdzǷȁ ǾǽȀǺǴ ǹǯǵdzǽDzǽ ǼǯǵǯȁǷȎ ǹǺǯDZǷȇǷ ǾǽȌȁǽǻȂ ǴȀǺǷ ǼǴǽǰȄǽdzǷǻǽ ǽȁȀǺǴǵǷDZǯȁȋ DZȀǴ ǷǶǻǴǼǴǼǷȎ ǹǯǹ ǽdzǼǽ ȀǽǰȊȁǷǴ DZǽǶǻǽǵǼǽ ǺȂȆȇǴ ǰȂdzǴȁ ǾǴǿǴȄDZǯȁȊDZǯȁȋ ȀǽǰȊȁǷǴ LostFocus Ƿ ǿǯǰǽȁǯȁȋ Ȁ ȁǴǹȀȁǽǻ ǷǶ ǼǴDzǽ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ TextBox ǯDZȁǽǻǯȁǷȆǴȀǹǷ ǾǿǷǼǷǻǯȍȁ DZDZǽdz ȆǴǿǴǶ ǟǴdzǯǹȁǽǿ ǻǴȁǽdzǯ DZDZǽdzǯ Input Method Editor, IME dzǺȎ ǾǽdzdzǴǿǵǹǷ ǷǼǽȀȁǿǯǼǼȊȄ ȎǶȊǹǽDZ ǔȀǺǷ DZ ȀǷȀȁǴǻǴ ȂȀȁǯǼǽDZǺǴǼǯ ǾǽdzdzǴǿǵǹǯ ǿǯǶǺǷȆ ǼȊȄ ǹǺǯDZǷǯȁȂǿ Ƿ ȎǶȊǹǽDZ , IME ǰȂdzǴȁ ǿǯǰǽȁǯȁȋ DZ Silverlight 2 ȁǽȆǼǽ ȁǯǹ ǵǴ ǹǯǹ dzǺȎ ǺȍǰǽDzǽ dzǿȂDzǽDzǽ ȌǺǴ ǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ HTML Ǭȁǽ ǻǽǵǼǽ DZǷdzǴȁȋ Ǽǯ ǿǷȀ 7- DzdzǴ DZ ǽdzǼǽǻ TextBox ǷȀǾǽǺȋǶȂȍȁȀȎ ǿǯǶǼȊǴ ȎǶȊ ǹǷ IME ² ǷǶȂǻǷȁǴǺȋǼǽ
ǟǗǠ 7 7 ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ TextBox Ȁ ȁǴǹȀȁǽǻ Ǽǯ ǿǯǶǼȊȄ ȎǶȊǹǯȄ.
Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ ȀDZǽǸȀȁDZǽ Text DZǽǶDZǿǯȁǷȁ ȀȁǿǽǹȂ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǹǽdzǷǿǽDZǹǷ Unicode Ȁǽ DZȀǴǻǷ ȀǷǻ DZǽǺǯǻǷ Ƿ ¶\r· DZ ǹǯȆǴȀȁDZǴ ǿǯǶdzǴǺǷȁǴǺǴǸ Ȁȁǿǽǹ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ TextBox ǾǽǶDZǽǺȎȍȁ DZȊǰǷǿǯȁȋ ǾǽdzȀȁǿǽǹǷ Text Ƿ ȁǯǹǵǴ ǽǰǴȀǾǴȆǷDZǯȍȁ DZǽǶǻǽǵ ǼǽȀȁȋ ǼǯȀȁǿǽǷȁȋ ȁǽ ǹǯǹ DZȊDzǺȎdzǷȁ DZȊǰǿǯǼǼȊǸ ȁǴǹȀȁ ǓǺȎ ǶǯdzǯǼǷȎ ǷǺǷ DZǽǶDZǿǯȈǴǼǷȎ DZȊǰǿǯǼǼǽDzǽ DZ Ǽǯ ȀȁǽȎȈǷǸ ǻǽǻǴǼȁ ȁǴǹȀȁǯ ǷȀǾǽǺȋǶȂǴȁȀȎ ȀDZǽǸȀȁDZǽ SelectedText ǑȊǰǿǯǼǼȊǸ ȁǴǹȀȁ ǜǯȆǯǺǽ DZȊǰǿǯǼǼǽǸ Ǿǽdz
152
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
ȀȁǿǽǹǷ ǻǽǵǼǽ ǾǽǺȂȆǷȁȋ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ SelectionStart ǜǯȆǯǺǽ DZȊǰǿǯǼǼǽǸ ǾǽdzȀȁǿǽǹǷ ǴǴ dzǺǷǼȂ ² Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ SelectionEnd ǙǽǼǴȅ DZȊǰǿǯǼǼǽǸ ǾǽdzȀȁǿǽǹǷ ǞǿǷ Ǻȍǰǽǻ ǷǶǻǴǼǴǼǷǷ DZȊǰǽǿǯ Ǿǽdz ȀȁǿǽǹǷ ȃǽǿǻǷǿȂǴȁȀȎ ȀǽǰȊȁǷǴ SelectionChanged ǑȊǰǿǯǼǼȊǸ ȌǺǴǻǴǼȁ ǷǶǻǴǼǴǼ ǟǯȀȀǻǽȁǿǷǻ ȀǺǴdzȂȍȈǷǸ ǾǿǷǻǴǿ Ǒǽ-ǾǴǿDZȊȄ, XAML-ǹǽdz:
ǖdzǴȀȋ ǽǾǿǴdzǴǺȎǴȁȀȎ ȀǽǰȊȁǷǴ SelectionChanged, dzǺȎ ǹǽȁǽǿǽDzǽ ǽǾǿǴdzǴǺǴǼ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ TextBox SelectionChanged. ǟǯȀȀǻǽȁǿǷǻ: private void TextBox SelectionChanged(object sender, RoutedEventArgs e) { TextBox t = sender as TextBox; int st = t.SelectionStart; int ln = t.SelectionLength; string strT = t.SelectedText; }
Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ ǾǴǿǴǻǴǼǼǯȎ st ȁǷǾǯ int ȀǽdzǴǿǵǷȁ ǷǼdzǴǹȀ ǼǯȆǯǺȋǼǽDzǽ ȀǷǻDZǽǺǯ DZȊǰǿǯǼǼǽǸ ǾǽdzȀȁǿǽǹǷ ǽȁȀȆǷȁȊDZǯǴǻǽǸ ǽȁ ǼȂǺȎ ln ² dzǺǷǼǯ DZȊǰǿǯǼǼǽǸ ǾǽdzȀȁǿǽǹǷ Ƿ strT ² Ȁȁǿǽǹǯ ȀǽdzǴǿǵǯȈǯȎ DZȊǰǿǯǼǼȂȍ ǾǽdzȀȁǿǽǹȂ Ǘȁǯǹ ǼǯǾǿǷǻǴǿ ǴȀǺǷ DZȊǰǿǯǼǯ ǾǽdzȀȁǿǽǹǯ ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 7-8, st ǰȂdzǴȁ ǿǯDZǼǯ ln ǿǯDZ Ǽǯ Ƿ strT ǰȂdzǴȁ ǿǯDZǼǯ JKLMNOPQ.
ǟǗǠ 7 8 ǑȊǰǽǿ ǾǽdzȀȁǿǽǹǷ ȁǴǹȀȁǯ.
ǡǯǹǵǴ DZ TextBox ǻǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ ǿǯǶǼȊǴ ȇǿǷȃȁȊ ȁǽȆǼǽ ȁǯǹ ǵǴ ǹǯǹ Ȍȁǽ dzǴǺǯǴȁȀȎ DZ TextBlock Ǟǽdz ǿǽǰǼǽ ǽǰ Ȍȁǽǻ ǿǯȀȀǹǯǶȊDZǯǺǽȀȋ DZ ǿǯǶdzǴǺǴ ©ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ TextBlockª DZ ȌȁǽǸ DzǺǯDZǴ ǿǯǼǴǴ
ǝǰȈǷǴ ȀDZǽǸȀȁDZǯ, ȀǽǰȊȁǷȎ Ƿ ǻǴȁǽdzȊ Ǒ ǾǿǴdzȊdzȂȈǷȄ ǿǯǶdzǴǺǯȄ ǰȊǺǷ ǾǽdzǿǽǰǼǽ ǿǯȀȀǻǽȁǿǴǼȊ ǰǯǶǽDZȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight Ȁ ǯǹ ȅǴǼȁǷǿǽDZǯǼǷǴǻ DZǼǷǻǯǼǷȎ Ǽǯ ǷȄ ǽȀǽǰȊȄ ȀDZǽǸȀȁDZǯȄ ǻǴȁǽdzǯȄ Ƿ ȀǽǰȊȁǷȎȄ ǝdzǼǯǹǽ ȀȂȈǴȀȁDZȂǴȁ ǿȎdz ȃȂǼǹ ȅǷǽǼǯǺȋǼȊȄ DZǽǶǻǽǵǼǽȀȁǴǸ ǽǰȈǷȄ dzǺȎ DZȀǴȄ ǷǺǷ ǰǽǺȋȇǷǼȀȁDZǯ ȌȁǷȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ Ƿ DZȊ dzǽǺǵǼȊ ǾǽǶǼǯǹǽǻǷȁȋȀȎ Ȁ ǼǷǻǷ ǾǿǴǵdzǴ ȆǴǻ ǼǯȆǼǴȁǴ ǿǯǶǿǯǰǽȁǹȂ ȀǽǰȀȁDZǴǼǼȊȄ ǾǿǷǺǽǵǴǼǷǸ Silverlight.
ǝǰǿǯǰǽȁǹǯ ȃǽǹȂȀǯ ǬǺǴǻǴǼȁȊ ǹǽȁǽǿȊǴ ǻǽDzȂȁ ǾǿǷǼǷǻǯȁȋ DZDZǽdz ȃǽǿǻǷǿȂȍȁ ȀǽǰȊȁǷȎ GotFocus Ƿ LostFocus Ǭȁǽ DZǯǵǼǽǴ dzǽ ǾǽǺǼǴǼǷǴ DZ Silverlight 2 ǾǽȁǽǻȂ Ȇȁǽ DZ Silverlight 1.0 ȁǽǺȋǹǽ ǹǽǿǼǴDZǽǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǻǽDz ǾǿǷǼǷǻǯȁȋ ȌȁǷ ȀǽǰȊȁǷȎ
ǒǺǯDZǯ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight: ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ ǹǽǻǾǽǼǽDZǹǷ
153
ǠǽǰȊȁǷȎ GotFocus Ƿ LostFocus ȃǽǿǻǷǿȂȍȁȀȎ ǹǯǵdzȊǸ ǿǯǶ ǹǽDzdzǯ ǾǽǺȋǶǽDZǯȁǴǺȋ ǾǴǿǴȄǽdzǷȁ Ǽǯ ǷǺǷ ǾǽǹǷdzǯǴȁ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǺǷǰǽ ǼǯDZǽdzȎ ǹȂǿȀǽǿǽǻ ǻȊȇǷ ǺǷǰǽ ǷȀǾǽǺȋǶȂȎ ǹǺǯDZǷȇȂ Tab ǝǰǯ ȌȁǷȄ ȀǽǰȊȁǷȎ ȎDZǺȎȍȁ ȀȎ ȀǽǰȊȁǷȎǻǷ ǾǴǿǴdzǯȍȈǷǻǷȀȎ DZDZǴǿȄ Ǿǽ ǷǴǿǯǿȄǷǷ (bubbling events Ǭȁǽ ǽǶǼǯȆǯǴȁ Ȇȁǽ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǾǿǷǼǷǻǯǴȁ ȀǽǰȊȁǷǴ Ǽǽ ǼǴ ǽǰǿǯǰǯȁȊDZǯǴȁ ǴDzǽ ǠǽǰȊȁǷǴ ǾǴǿǴdzǯǴȁȀȎ ǴDzǽ ǿǽdzǷȁǴǺȍ Ƿ ȁǯǹ dzǯǺǴǴ DZDZǴǿȄ Ǿǽ ǷǴ ǿǯǿȄǷǷ dzǽ ȁǴȄ Ǿǽǿ Ǿǽǹǯ ǼǴ ǰȂdzǴȁ ǾǴǿǴȄDZǯȆǴǼǽ ǽǰǿǯǰǽȁȆǷǹǽǻ ȀǽǰȊȁǷȎ
ǝǰǿǯǰǽȁǹǯ ȀǽǰȊȁǷǸ ǻȊȇǷ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight ȃǽǿǻǷǿȂȍȁ ǼǴȀǹǽǺȋǹǽ ȀǽǰȊȁǷǸ ǻȊȇǷ: x
MouseEnter Ǭȁǽ ȀǽǰȊȁǷǴ ȃǽǿǻǷǿȂǴȁȀȎ ǾǿǷ DZȄǽdzǴ ǹȂǿȀǽǿǯ ǻȊȇǷ DZ ǽǰǺǯȀȁȋ ǽȁǽǰǿǯǵǴǼǷȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ.
x
MouseLeave Ǭȁǽ ȀǽǰȊȁǷǴ ȃǽǿǻǷǿȂǴȁȀȎ, ǹǽDzdzǯ ǹȂǿȀǽǿ ǻȊȇǷ ǾǽǹǷdzǯǴȁ ǽǰǺǯȀȁȋ ǽȁǽǰǿǯǵǴǼǷȎ ȌǺǴ ǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ.
x
MouseLeftButtonDown Ǭȁǽ ȀǽǰȊȁǷǴ ȃǽǿǻǷǿȂǴȁȀȎ ǾǿǷ ǼǯǵǯȁǷǷ ǾǽǺȋǶǽDZǯȁǴǺǴǻ ǺǴDZǽǸ ǹǼǽǾǹǷ ǻȊȇǷ ǹǽDzdzǯ ǹȂǿȀǽǿ ǼǯȄǽdzǷȁȀȎ Ǽǯdz ȌǺǴǻǴǼȁǽǻ ȂǾǿǯDZǺǴǼǷȎ.
x
MouseLeftButtonUp Ǭȁǽ ȀǽǰȊȁǷǴ ȃǽǿǻǷǿȂǴȁȀȎ ǾǿǷ ǽȁǾȂȀǹǯǼǷǷ ȂdzǴǿǵǷDZǯǴǻǽǸ ǺǴDZǽǸ ǹǼǽǾǹǷ ǻȊȇǷ, ǹǽDzdzǯ ǹȂǿȀǽǿ ǼǯȄǽdzǷȁȀȎ Ǽǯdz ȌǺǴǻǴǼȁǽǻ ȂǾǿǯDZǺǴǼǷȎ.
x
MouseMove
Ǭȁǽ ȀǽǰȊȁǷǴ ȃǽǿǻǷǿȂǴȁȀȎ ǾǿǷ ǾǴǿǴǻǴȈǴǼǷǷ ǹȂǿȀǽǿǯ Ǿǽ ȌǺǴǻǴǼȁȂ ȂǾǿǯDZǺǴǼǷȎ.
ǙǿǽǻǴ ǾǴǿǴȆǷȀǺǴǼǼȊȄ ȀǽǰȊȁǷǸ dzǺȎ ǽǰǴȀǾǴȆǴǼǷȎ ǻǯǹȀǷǻǯǺȋǼǽDzǽ ǹǽǼȁǿǽǺȎ ǻǽDzȂȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ǻǴȁǽ dzȊ CaptureMouse Ƿ ReleaseMouseCapture ǙǽDzdzǯ dzǺȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ DZȊǶȊDZǯǴȁȀȎ ǻǴȁǽdz CaptureMouse DZȀǴ ȀǽǰȊȁǷȎ ǻȊȇǷ ǰȂdzȂȁ ǼǯǾǿǯDZǺȎȁȋȀȎ DZ Ȍȁǽȁ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǼǴǶǯDZǷȀǷǻǽ ǽȁ ȁǽDzǽ ǼǯȄǽdzǷȁ ȀȎ ǺǷ ǹȂǿȀǽǿ ǻȊȇǷ DZ ǴDzǽ DzǿǯǼǷȅǯȄ ǷǺǷ ǼǴȁ ǛǴȁǽdz ReleaseMouseCapture ǹǯǹ ȀǺǴdzȂǴȁ ǷǶ ǴDzǽ ǷǻǴǼǷ DZǽǶ DZǿǯȈǯǴȁ ǻǴȄǯǼǷǶǻ ǾǴǿǴȄDZǯȁǯ ȀǽǰȊȁǷǸ DZ ǼǽǿǻǯǺȋǼǽǴ ȀǽȀȁǽȎǼǷǴ ǬȁǷ ǻǴȁǽdzȊ ǽȆǴǼȋ ǾǽǺǴǶǼȊ dzǺȎ ǿǴǯǺǷ ǶǯȅǷǷ ǾǴǿǴǻǴȈǴǼǷȎ ǽǰȉǴǹȁǽDZ ǻǴȁǽdzǽǻ ©drag-and-dropª ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀǽǰȊȁǷǸ ǻȊȇǷ dzǺȎ ǿǴǯǺǷǶǯȅǷǷ ǾǴǿǴǻǴȈǴǼǷȎ ǽǰȉǴǹȁǽDZ ǻǴȁǽdzǽǻ ©Drag-and-dropª ǜǷǵǴ ǾǿǴdzȀȁǯDZǺǴǼ XAML-dzǽǹȂǻǴǼȁ ǽǰǴȀǾǴȆǷDZǯȍȈǷǸ ǽȁǿǷȀǽDZǹȂ ȌǺǺǷǾȀǽDZ Ǽǯ ȀȁǿǯǼǷȅǴ ǝǰǿǯȁǷȁǴ DZǼǷ ǻǯǼǷǴ Ȇȁǽ dzǺȎ DZȀǴȄ ȌǺǺǷǾȀǽDZ ǽǾǿǴdzǴǺǴǼȊ ǽdzǼǷ Ƿ ȁǴ ǵǴ ǽǰǿǯǰǽȁȆǷǹǷ ȀǽǰȊȁǷǸ ǻȊȇǷ
154
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
ǡǴǾǴǿȋ ǿǯȀȀǻǽȁǿǷǻ DZȊdzǴǺǴǼǼȊǸ ǹǽdz Ǒǽ-ǾǴǿDZȊȄ Ǽǯǻ ǼǴǽǰȄǽdzǷǻȊ ǾǴǿǴǻǴǼǼȊǴ dzǺȎ ȀǽȄǿǯǼǴǼǷȎ Ȅ Ƿ Ȃ ǹǽǽǿdzǷǼǯȁ ǹȂǿȀǽǿǯ ǻȊȇǷ DZ ǻǽǻǴǼȁ ǼǯȆǯǺǯ ǾǴǿǴǻǴȈǴǼǷȎ ǻǴȁǽdzǽǻ ©drag-and-dropª Ƿ ǴȈǴ ǽdzǼǯ ǾǴǿǴ ǻǴǼǼǯȎ dzǺȎ ǽǰǽǶǼǯȆǴǼǷȎ ȁǽDzǽ ȂdzǴǿǵǷDZǯǴȁȀȎ ǺǷ ǹǼǽǾǹǯ ǻȊȇǷ DZ ǼǯȀȁǽȎȈǷǸ ǻǽǻǴǼȁ double beginX = 0; double beginY = 0; bool isMouseDown = false;
ǔȀǺǷ ǹȂǿȀǽǿ ǼǯȄǽdzǷȁȀȎ Ǽǯdz ǺȍǰǽǸ ǷǶ ǹǼǽǾǽǹ Ƿ ǼǯǵǷǻǯǴȁȀȎ ǹǼǽǾǹǯ ǻȊȇǷ DZȊǾǽǺǼȎǴȁȀȎ ȃȂǼǹȅǷȎ Ellipse MouseLeftButtonDown. private void Ellipse MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Ellipse b = sender as Ellipse; beginX = e.GetPosition(this).X; beginY = e.GetPosition(this).Y; isMouseDown = true; b.CaptureMouse(); }
ǝȁǾǿǯDZǷȁǴǺǴǻ ȎDZǺȎǴȁȀȎ ȂǼǷDZǴǿȀǯǺȋǼȊǸ ǽǰȉǴǹȁ ǾǽȌȁǽǻȂ ǾǿǴǵdzǴ DZȀǴDzǽ ǼǴǽǰȄǽdzǷǻǽ ǾǿǷDZǴȀȁǷ ǴDzǽ ǹ ȁǷ ǾȂ ȌǺǺǷǾȀ ǞǽȀǺǴ ȌȁǽDzǽ ǷȀǾǽǺȋǶȂǴǻ ǯǿDzȂǻǴǼȁ MouseButtonEventArgs (ǏǿDzȂǻǴǼȁȊ ȀǽǰȊȁǷǸ ǹǼǽǾǹǷ ǻȊȇǷ) dzǺȎ ǾǽǺȂȆǴǼǷȎ ȁǴǹȂȈǷȄ ǹǽǽǿdzǷǼǯȁ Ȅ Ƿ Ȃ Ƿ ǶǯdzǯǼǷȎ ǷȄ ǹǯǹ ǼǯȆǯǺȋǼȊȄ ǶǼǯȆǴǼǷǸ ǖǯȁǴǻ ǾǽȀǹǽǺȋǹȂ ǹǼǽǾǹǯ ǻȊȇǷ ȂdzǴǿǵǷDZǯǴȁȀȎ ǼǯǵǯȁǽǸ ǴǴ ǾǴǿǴǻǴȈǴǼǷȎ dzǽǺǵǼȊ ǽȁȀǺǴǵǷDZǯȁȋȀȎ ǾǽȌȁǽǻȂ ǾǴǿǴǻǴǼǼǽǸ isMouseDown ǶǯdzǯǴȁȀȎ ǶǼǯȆǴǼǷǴ True ǜǯǹǽǼǴȅ ǻȊ ȄǽȁǷǻ ǽȁȀǺǴǵǷDZǯȁȋ ȀǽǰȊȁǷȎ ǻȊȇǷ dzǺȎ ȌȁǽDzǽ ȌǺǺǷǾȀǯ Ǻȍ ǰǽDzǽ ǷǶ ǶǯdzǯǼǼȊȄ ȁǯǹǷǻ ǽǰǿǯǶǽǻ ȆȁǽǰȊ dzǯǵǴ ǴȀǺǷ ǾǽǺȋǶǽDZǯȁǴǺȋ ȂDZǽdzǷȁ ǹȂǿȀǽǿ ǻȊȇǷ Ȁ ȌȁǽDzǽ ȌǺǺǷǾȀǯ ǽǼ ǾǿǽdzǽǺǵǯǺ ǾǽǺȂȆǯȁȋ ȀǽǰȊȁǷȎ Ǘȁǯǹ ǾǽȀǹǽǺȋǹȂ ǾǽǺȋǶǽDZǯȁǴǺȋ dzDZǷDzǯǴȁ ǻȊȇȋȍ dzǽǺǵǼǽ ȃǽǿǻǷǿǽDZǯȁȋȀȎ ȀǽǰȊȁǷǴ MouseMove ǝǼǽ ǽǰ ǿǯǰǯȁȊDZǯǴȁȀȎ ȃȂǼǹȅǷǴǸ-ǽǰǿǯǰǽȁȆǷǹǽǻ ȀǽǰȊȁǷȎ Ellipse MouseMove: private void Ellipse MouseMove(object sender, MouseEventArgs e) { if (isMouseDown) { Ellipse b = sender as Ellipse; double currX = e.GetPosition(this).X; double currY = e.GetPosition(this).Y; b.SetValue(Canvas.LeftProperty, currX); b.SetValue(Canvas.TopProperty, currY); } }
Ǭȁǽ ȀǽǰȊȁǷǴ ǰȂdzǴȁ ȃǽǿǻǷǿǽDZǯȁȋȀȎ ǾǿǷ ǾǿǽȄǽǵdzǴǼǷǷ ǹȂǿȀǽǿǯ ǻȊȇǷ Ǿǽ ȌǺǺǷǾȀȂ ǼǴǶǯDZǷȀǷǻǽ ǽȁ ȁǽDzǽ DZȊǾǽǺǼȎǴȁȀȎ ǺǷ ǾǴǿǴǻǴȈǴǼǷǴ ȌȁǽDzǽ ȌǺǺǷǾȀǯ ǷǺǷ ǼǴȁ ǜǽ ǼǯȀ ǷǼȁǴǿǴȀȂȍȁ ȁǽǺȋǹǽ DZǯǿǷǯǼȁȊ ǹǽDzdzǯ ǾǽǺȋ ǶǽDZǯȁǴǺǷ ǾǴǿǴȁȎDzǷDZǯǴȁ ȌǺǺǷǾȀ ǯ Ȍȁǽ Ǿǽ ǽǾǿǴdzǴǺǴǼǷȍ ǽǶǼǯȆǯǴȁ Ȇȁǽ ǾǴǿǴǻǴǼǼǯȎ isMouseDown ǷǻǴǴȁ ǶǼǯȆǴǼǷǴ True Ǒ Ȍȁǽǻ ȀǺȂȆǯǴ ǻȊ ǾǽǺȂȆǯǴǻ ȁǴǹȂȈǷǴ ǹǽǽǿdzǷǼǯȁȊ ǹȂǿȀǽǿǯ ǻȊȇǷ Ƿ ǷȀǾǽǺȋǶȂǴǻ ǷȄ dzǺȎ ǶǯdzǯǼǷȎ ǾǿǷȀǽǴdzǷǼǴǼǼȊȄ ȀDZǽǸȀȁDZ Top Ƿ Left ȌǺǺǷǾȀǯ Ǒ ǿǴǶȂǺȋȁǯȁǴ ǰȂdzǴȁ ȀǽǶdzǯǼ ȌȃȃǴǹȁ ǾǴǿǴȁȎDzǷDZǯǼǷȎ ȌǺǺǷǾȀǯ ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ ǹǽǽǿdzǷǼǯȁǯǻ ǹȂǿȀǽǿǯ ǻȊȇǷ ǜǯǹǽǼǴȅ ǾǿǷ ǽȁǾȂȀǹǯǼǷǷ ȂdzǴǿǵǷDZǯǴǻǽǸ ǹǼǽǾǹǷ ǻȊȇǷ ȃǽǿǻǷǿȂǴȁȀȎ ȀǽǰȊȁǷǴ MouseLeftButtonUp ǾǴ ǿǴȄDZǯȁȊDZǯǴǻǽǴ ȃȂǼǹȅǷǴǸ Ellipse MouseLeftButtonUp: private void Ellipse MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { Ellipse b = sender as Ellipse; isMouseDown = false; b.ReleaseMouseCapture(); }
Ǭȁǽ ǽǰǴȀǾǴȆǷDZǯǴȁ DZǽǶDZǿǯȈǴǼǷǴ ǾǴǿǴǻǴǼǼǽǸ isMouseDown ǹ ǷȀȄǽdzǼǽǻȂ ǶǼǯȆǴǼǷȍ Ƿ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴ ǼǷȎ ǽȁȀǺǴǵǷDZǯȍȈǷǸ ȀǽǰȊȁǷȎ ǻȊȇǷ ǾǿǴǹǿǯȈǯǴȁ dzǴǺǯȁȋ Ȍȁǽ Ǒ ǿǴǶȂǺȋȁǯȁǴ DZǽȀȀȁǯǼǯDZǺǷDZǯǴȁȀȎ ǽǰȊȆǼǽǴ
ǒǺǯDZǯ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight: ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ ǹǽǻǾǽǼǽDZǹǷ
155
ǾǽDZǴdzǴǼǷǴ ǻȊȇǷ ǯ ȌǺǺǷǾȀ ǽȀȁǯǴȁȀȎ ǾǴǿǴdzDZǷǼȂȁȊǻ DZ dzǿȂDzǽǴ ǻǴȀȁǽ ǑȀǴ Ȍȁǽ DZ dzǴǸȀȁDZǷǷ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 7- Ƿ -10. ǜǯ ǿǷȀ 7- ǾǽǹǯǶǯǼǽ ǹǯǹ ǾǿǷǺǽǵǴǼǷǴ DZȊDzǺȎdzǷȁ DZ ǷȀȄǽdzǼǽǻ ȀǽȀȁǽȎǼǷǷ ǔȀǺǷ ǾǽǺȋǶǽDZǯȁǴǺȋ ǼǯDZǴdzǴȁ ǹȂǿ Ȁǽǿ ǻȊȇǷ Ǽǯ ǺȍǰǽǸ ǷǶ ȌǺǺǷǾȀǽDZ Ƿ ǶǯȁǴǻ ǼǯǵǻǴȁ ǹǼǽǾǹȂ ǻȊȇǷ Ƿ ǾǿǽdzǽǺǵǷȁ ǾǴǿǴǻǴȈǴǼǷǴ ȌǺǺǷǾȀ ǼǯȆǼǴȁ dzDZǷDzǯȁȋȀȎ Ƕǯ ǹȂǿȀǽǿǽǻ ǡǯǹǷǻ ǽǰǿǯǶǽǻ ǾǽǺȋǶǽDZǯȁǴǺȋ ǻǽǵǴȁ ǻǴǼȎȁȋ ǿǯȀǾǽǺǽǵǴǼǷǴ ȌǺǺǷǾȀǽDZ Ǽǯ ȌǹǿǯǼǴ ǻǴȁǽdzǽǻ ©drag-and-dropª Ǭȁǽ ǾǿǴdzȀȁǯDZǺǴǼǽ Ǽǯ ǿǷȀ 7-10 ǙǿǽǻǴ ȀǽǰȊȁǷǸ ǻȊȇǷ ȀȂȈǴȀȁDZȂȍȁ ȀǽǰȊȁǷȎ ǹǺǯDZǷǯȁȂǿȊ ǹǽȁǽǿȊǴ ǻǽDzȂȁ ȃǽǿǻǷǿǽDZǯȁȋȀȎ dzǺȎ ǻǼǽDzǷȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǞǽdzǿǽǰǼǴǴ ǽǰ Ȍȁǽǻ ǿǯȀȀǹǯǶȊDZǯǴȁȀȎ DZ ȀǺǴdzȂȍȈǴǻ ǿǯǶdzǴǺǴ
ǟǗǠ 7 9 ǞǿǷǺǽǵǴǼǷǴ ǿǴǯǺǷǶȂȍȈǴǴ ǾǴǿǴǻǴȈǴǼǷǴ ǽǰȉǴǹȁǽDZ ǻǴȁǽdzǽǻ ©Drag and dropª.
ǟǗǠ 7 10 ǞǴǿǴǻǴȈǴǼǷǴ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǻǴȁǽdzǽǻ ©drag and dropª.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǹǺǯDZǷǯȁȂǿȊ ǙǿǽǻǴ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ TextBox ǹǽȁǽǿȊǸ ǾǿǴdzǺǯDzǯǴȁ ǾǽǺȋǶǽDZǯȁǴǺȍ DZǽǶǻǽǵǼǽȀȁȋ DZDZǽdzǯ ȁǴǹȀȁǯ Ȁ ǹǺǯDZǷǯȁȂǿȊ ǻǼǽDzǷǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ȃǽǿǻǷǿȂȍȁ ȀǽǰȊȁǷȎ KeyDown Ƿ KeyUp ǹǽȁǽǿȊǴ ǻǽDzȂȁ ǷȀ ǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ǾǴǿǴȄDZǯȁǯ DZDZǽdzǯ Ȁ ǹǺǯDZǷǯȁȂǿȊ ǠǽǰȊȁǷǴ KeyDown ȃǽǿǻǷǿȂǴȁȀȎ ǾǿǷ ǹǯǵdzǽǻ ǼǯǵǯȁǷǷ ǹǺǯDZǷȇǷ ǹǽDzdzǯ ȃǽǹȂȀ ǼǯȄǽdzǷȁȀȎ Ǽǯ ȌǺǴǻǴǼȁǴ ǣȂǼǹȅǷȎ-ǽǰǿǯǰǽȁȆǷǹ ȌȁǽDzǽ ȀǽǰȊȁǷȎ ǾǿǷǼǷǻǯǴȁ ȂǼǷDZǴǿ ȀǯǺȋǼȊǸ ǽǰȉǴǹȁ-ǽȁǾǿǯDZǷȁǴǺȋ Ƿ ǽǰȉǴǹȁ KeyEventArgs, ǹǽȁǽǿȊǸ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ǷǶDZǺǴȆǴǼǷȎ ǷǼȃǽǿǻǯȅǷǷ ǽ ǼǯǵǯȁǽǸ ǹǺǯDZǷȇǴ ǝǼ ǷǻǴǴȁ ȀDZǽǸȀȁDZǽ key DZǽǶDZǿǯȈǯȍȈǴǴ ǽǰȉǴǹȁ Key Ȁ ǷǼȃǽǿǻǯȅǷǴǸ ǽ ǹǺǯDZǷȇǴ Ǭȁǽ ǾǺǯȁȃǽǿǻǽǼǴǶǯDZǷȀǷǻǽǴ ȀDZǽǸȀȁDZǽ ǾǽȌȁǽǻȂ ǽǼǽ ǺȂȆȇǴ DZȀǴDzǽ ǾǽdzȄǽdzǷȁ dzǺȎ ǷȀǾǽǺȋǶǽDZǯǼǷȎ
156
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
DZ ǾǿǷǺǽǵǴǼǷȎȄ 6LOYHUOLJKt. KeyEventArgs ǾǿǴdzǺǯDzǯǴȁ ȁǯǹǵǴ ǴȈǴ ǽdzǼǽ ȀDZǽǸȀȁDZǽ PlatformKeyCode Ǚǽdz ǹǺǯ DZǷȇǷ Ǽǯ dzǯǼǼǽǸ ǾǺǯȁȃǽǿǻǴ ǹǽȁǽǿǽǴ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ Ȁǽ ȀDZǽǸȀȁDZǽǻ key dzǺȎ ǾǽǺȂȆǴǼǷȎ ǹǽdzǽDZ ǹǺǯDZǷȇ ǷȀǾǽǺȋǶȂǴǻȊȄ DZ ǹǽǼǹǿǴȁǼǽǸ ǽǾǴǿǯȅǷǽǼǼǽǸ ȀǷȀȁǴǻǴ ǙǿǽǻǴ ȁǽDzǽ ȀȁǯȁǷȆǴȀǹǽǴ ȀDZǽǸȀȁDZǽ Keyboard.Modifers DZǽǶDZǿǯȈǯǴȁ ǶǼǯȆǴǼǷǴ ModifierKeys ǛǽdzǷȃǷȅǷ ǿȂȍȈǷǴ ǹǺǯDZǷȇǷ ǹǽȁǽǿǽǴ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ ȁǽDzǽ ǹǯǹǯȎ ǷǶ ǻǽdzǷȃǷȅǷǿȂȍȈǷȄ ǹǺǯDZǷȇ Alt, Control, Shift, Windows ǷǺǷ Apple ǰȊǺǯ Ǽǯǵǯȁǯ ǞǿǽȀȁǽ ǷȀǾǽǺȋǶȂǸȁǴ ǾǽǰǷȁǽDZǽǴ Ǘ Ǽǯ DZǽǶ DZǿǯȈǴǼǼǽǴ ǶǼǯȆǴǼǷǴ ȀDZǽǸȀȁDZǯ dzǺȎ ǾǿǽDZǴǿǹǷ ǷȀǹǽǻǽǸ ǻǽdzǷȃǷȅǷǿȂȍȈǴǸ ǹǺǯDZǷȇǷ ǼǯǾǿǷǻǴǿ Shift).
ǖǯǹǺȍȆǴǼǷǴ Ǒ dzǯǼǼǽǸ DzǺǯDZǴ ǰȊǺǷ ǾǿǴdzȀȁǯDZǺǴǼȊ ǼǴǹǽȁǽǿȊǴ ǰǯǶǽDZȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight (Button, CheckBox, HyperlinkButton, Image, ListBox, RadioButton, TextBlock Ƿ TextBox Ƿ ǾǽǹǯǶǯǼǽ ǹǯǹ ǽǼǷ ǻǽDzȂȁ ǷȀǾǽǺȋ ǶǽDZǯȁȋȀȎ dzǺȎ ȀǽǶdzǯǼǷȎ ǾǿǷǺǽǵǴǼǷǸ Silverlight ǙǿǽǻǴ ȁǽDzǽ dzǯǼ ǽǰǶǽǿ ȀDZǽǸȀȁDZ ǻǴȁǽdzǽDZ Ƿ ȀǽǰȊȁǷǸ ǽǰ ȈǷȄ dzǺȎ DZȀǴȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ Ȇȁǽ ǾǽǻǽǵǴȁ DZǯǻ ǼǯȆǯȁȋ ǷȀǾǽǺȋǶǽDZǯȁȋ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ ǹǽǻǾǽǼǽDZǽȆǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ DZ Silverlight. Ǒ ȀǺǴdzȂȍȈǴǸ DzǺǯDZǴ ǿǯȀȀǻǯȁǿǷDZǯȍȁȀȎ ǿǯȀȇǷǿǴǼǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight Ƿ ǿǯȀȀǹǯǶȊDZǯǴȁȀȎ ǹǯǹ ǽǼǷ ǻǽDzȂȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ǿǯȀȇǷǿǴǼǷȎ ǹǿȂDzǯ DZǽǶǻǽǵǼǽȀȁǴǸ DZǯȇǷȄ ǾǿǷǺǽǵǴǼǷǸ
ǒǺǯDZǯ 8
ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight: ǿǯȀȇǷǿǴǼǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Ǒ ǒǺǯDZǴ ©ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight: ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ ǹǽǻǾǽǼǽDZǹǷª ǰȊǺ ǾǿǴdzȀȁǯDZǺǴǼ Ǽǯǰǽǿ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ Silverlight Ƿ ǾǿǽDZǴdzǴǼ ǽǰǶǽǿ ȁǯǹǷȄ ǽȀǼǽDZǼȊȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǹǯǹ TextBox Ƿ CheckBox ǝdzǼǯǹǽ dzǺȎ ȀǽDZǿǴǻǴǼǼȊȄ ǼǯȀȊȈǴǼǼȊȄ ǷǼȁǴǿǯǹȁǷDZǼȊȄ ǾǿǷǺǽǵǴǼǷǸ RIAs ǼǴǽǰȄǽdzǷǻȊ Ǽǯ ǻǼǽDzǽ ǰǽǺǴǴ ȀǺǽǵǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ȁǯǹǷǴ ǹǯǹ ȁǯǰǺǷȅȊ Ȁ dzǯǼǼȊǻǷ ǹǯǺǴǼdzǯǿǷ Ƿ ȁdz Ǒ dzǯǼǼǽǸ DzǺǯDZǴ DZȊ ǼǯȂȆǷȁǴȀȋ ǷȀǾǽǺȋǶǽDZǯȁȋ ȌȁǷ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ DZ ȀDZǽǷȄ Silverlight ǾǿǷǺǽǵǴǼǷȎȄ ǜǴǹǽȁǽǿȊǴ ǷǶ ȌȁǷȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ȁǯǹǷǴ ǹǯǹ DataGrid (ǡǯǰǺǷȅǯ Ȁ dzǯǼǼȊǻǷ ǶǯȀǺȂǵǷDZǯȍȁ ǽȁdzǴǺȋǼǽǸ ǹǼǷDzǷ ǾǽȌȁǽǻȂ ǼǴ ǽǵǷdzǯǸȁǴ ǾǽǺȂȆǷȁȋ ǶdzǴȀȋ ǾǽǺǼȊǸ API ȌȁǷȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǝdzǼǯǹǽ DZ dzǯǼǼǽǸ DzǺǯDZǴ ǾǿǴdzǽȀȁǯDZǺǴǼǽ dzǽȀȁǯȁǽȆǼǽ ȀDZǴdzǴǼǷǸ ǽǰ ȌȁǷȄ ǿǯȀȇǷǿǴǼǼȊȄ ȌǺǴǻǴǼȁǯȄ ȂǾǿǯDZǺǴǼǷȎ ǹǽȁǽǿȊǴ ǾǽǶDZǽǺȎȁ ǾǽǼǷǻǯȁȋ Ȇȁǽ ǾǿǽǷȀȄǽdzǷȁ ǾǿǷ ǷȄ ǷȀǾǽǺȋǶǽDZǯǼǷǷ ǟǯȀǾǽǺǯDzǯȎ ȌȁǷǻǷ ǶǼǯǼǷȎǻǷ ǻǽǵǼǽ ǾǿǽdzǽǺǵǯȁȋ ȌǹȀ ǾǴǿǷǻǴǼȁǷǿǽDZǯȁȋ Ƿ ǷǶȂȆǯȁȋ ȌȁǷ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ȂǵǴ ȀǯǻǽȀȁǽȎȁǴǺȋǼǽ
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ DataGrid ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ DataGrid ǿǯǶǿǯǰǽȁǯǼ dzǺȎ ǽǰǺǴDzȆǴǼǷȎ ǶǯdzǯȆǷ Ǿǽ ǽȁǽǰǿǯǵǴǼǷȍ dzǯǼǼȊȄ DZ ȃǽǿǻǯȁǴ ȁǯǰǺǷȅȊ Ǭȁǽ ȀǴȁǹǯ dzǯǼǼȊȄ ǯ ǼǴ ǾǿǽȀȁǽ ȀǴȁǹǯ ǾǽȁǽǻȂ Ȇȁǽ ǽǼǯ ǻǽǵǴȁ ǰȊȁȋ ȀDZȎǶǯǼǯ Ȁ ǷȀȁǽȆǼǷǹǽǻ dzǯǼ ǼȊȄ ǐǽǺǴǴ ǾǽdzǿǽǰǼǽ ǽȁǽǰǿǯǵǴǼǷǴ dzǯǼǼȊȄ ǿǯȀȀǻǯȁǿǷDZǯǴȁȀȎ DZ ǒǺǯDZǴ ©ǠǽǶdzǯǼǷǴ DZǶǯǷǻǽdzǴǸȀȁDZȂȍ ȈǷȄ Ȁ ȀǴǿDZǴǿǽǻ ǾǿǷǺǽǵǴǼǷǸ DZ Silverlightª Ǽǽ ȆȁǽǰȊ DZȊ ǻǽDzǺǷ ǽȀǽǶǼǯȁȋ ǻǽȈȋ DataGrid, ǼǴǹǽȁǽǿȊǴ ǷǶ ǻǴȁǽdzǷǹ ǿǯǰǽȁȊ Ȁ ǼǷǻ ǰȂdzȂȁ ǷȀǾǽǺȋǶǽDZǯǼȊ ǶdzǴȀȋ ǞǿǷ dzǽǰǯDZǺǴǼǷǷ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ DataGrid DZ ǽǹǼǽ ǿǴdzǯǹȁǷǿǽDZǯǼǷȎ XAML, ǾǽǺȂȆǯǴǻ ȁǯǹǽǸ XAMLǹǽdz:
Ǟǽǹǯ Ȇȁǽ DataGrid ǼǴ ǻǽǵǴȁ dzǴǺǯȁȋ ǾǿǯǹȁǷȆǴȀǹǷ ǼǷȆǴDzǽ ǾǽȌȁǽǻȂ dzǽǰǯDZǷǻ DZ ǼǴDzǽ dzDZǯ ȀDZǽǸȀȁDZǯ ǷǻȎ Ƿ AutoGenerateColumns (ǠȁǽǺǰȅȊ ȃǽǿǻǷǿȂȍȁȀȎ ǯDZȁǽǻǯȁǷȆǴȀǹǷ ǹǽȁǽǿǽǴ ǽǰǴȀǾǴȆǷȁ ǯDZȁǽǻǯȁǷȆǴȀǹǽǴ ȀǽǶ dzǯǼǷǴ ǼǴǽǰȄǽdzǷǻȊȄ ȀȁǽǺǰȅǽDZ dzǯǼǼȊȄ ǾǿǷ ǾǿǷDZȎǶǹǴ ȀǴȁǹǷ ǹ DataGrid Ǒǽȁ ǹǯǹ DZȊDzǺȎdzǷȁ XAML dzǺȎ DataGrid ǾǽȀǺǴ ȌȁǷȄ dzǽǾǽǺǼǴǼǷǸ:
Ǒǽȁ Ƿ DZȀǴ Ȇȁǽ ȁǿǴǰȂǴȁȀȎ dzǺȎ ǾǽdzDzǽȁǽDZǹǷ DataGrid ǹ ǷȀǾǽǺȋǶǽDZǯǼǷȍ ȀDZȎǶǯǼǼȊȄ dzǯǼǼȊȄ ǞǿǴǵdzǴ ȆǴǻ ǾǴ ǿǴȄǽdzǷȁȋ ǹ ǽȀȁǯǺȋǼȊǻ ȀDZǽǸȀȁDZǯǻ ǻǴȁǽdzǯǻ Ƿ ȀǽǰȊȁǷȎǻ ȌȁǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ dzǯDZǯǸȁǴ DZȊǾǽǺǼǷǻ ǾǿǽȀȁȂȍ ǾǿǷDZȎǶǹȂ dzǯǼǼȊȄ ǐȂdzǴǻ ǷȀǾǽǺȋǶǽDZǯȁȋ RSS-ǹǯǼǯǺ Ǿǽ ǯdzǿǴȀȂ http://feeds.reuters.com/reuters/oddlyEnoughNews?format=xml. Ǘȁǯǹ, DZ ǼǯȆǯǺǴ Page.xaml.cs dzǽǰǯDZǺȎǴǻ ȀȀȊǺǹȂ Ǽǯ System.Net: using System.Net;
158
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
ǓǯǺǴǴ ǼǴǽǰȄǽdzǷǻǽ ǼǯȀȁǿǽǷȁȋ ǽǰȉǴǹȁ WebClient ǑǴǰ-ǹǺǷǴǼȁ Ǽǯ ȆȁǴǼǷǴ dzǯǼǼȊȄ Ǿǽ ȌȁǽǻȂ URI Ƿ dzǽǰǯDZǷȁȋ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ dzǺȎ ǽǰǿǯǰǽȁǹǷ ǶǯDZǴǿȇǴǼǷȎ ǶǯDzǿȂǶǹǷ dzǯǼǼȊȄ ǓǺȎ ȌȁǽDzǽ DZ ǹǽǼȀȁǿȂǹȁǽǿ Page dzǽǰǯDZ ǺȎǴǻ ȀǺǴdzȂȍȈǷǸ ǹǽdz WebClient client = new WebClient(); Uri uri = new Uri("http://feeds.reuters.com/reuters/topNews?format=xml"); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler( client DownloadStringCompleted); client.DownloadStringAsync(uri);
ǡǴǾǴǿȋ Ǿǽ ǶǯDZǴǿȇǴǼǷǷ ǶǯDzǿȂǶǹǷ dzǯǼǼȊȄ ǰȂdzǴȁ ǶǯǾȂȀǹǯȁȋȀȎ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ client DownloadStringCompleted Ǒ ȌȁǽǸ ȃȂǼǹȅǷǷ ǰȂdzǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ȀǾǴȅǷǯǺȋǼȊǸ ǹǺǯȀȀ ȁǷǾǯ NewsHeadline ǖǯDzǽǺǽDZǽǹ ǼǽDZǽȀȁǴǸ Ǒǽȁ ǹǽdz ȌȁǽDzǽ ǹǺǯȀȀǯ: public class NewsHeadLine { public string strHead { get; set; } public string strLine { get; set; } }
client DownloadStringCompleted ǷȀǾǽǺȋǶȂǴȁ ǰǷǰǺǷǽȁǴǹǷ System.Xml.Linq, ǾǽȌȁǽǻȂ ǾǽǼǯdzǽǰǷȁȀȎ dzǽǰǯDZǷȁȋ ȀȀȊǺǹȂ Ǽǯ ǼǷȄ. ǓǺȎ ȌȁǽDzǽ ȈǴǺǹǼǷȁǴ ǾǿǯDZǽǸ ǹǼǽǾǹǽǸ ǻȊȇǷ References Ƿ DZȊǰǴǿǷȁǴ Add Reference ǜǯ DZǹǺǯdzǹǴ .NET DZȊ ȂDZǷdzǷȁǴ ǰǷǰǺǷǽȁǴǹȂ System.Xml.Linq ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 8- ǑȊǰǴǿǷȁǴ ǴǴ Ƿ ȈǴǺǹǼǷȁǴ OK. ǦȁǽǰȊ ǹǽdz ȀǹǽǻǾǷǺǷǿǽDZǯǺȀȎ DZ ǼǴǻ dzǽǺǵǼǯ ǰȊȁȋ ȂǹǯǶǯǼǯ Ȍȁǯ ǰǷǰǺǷǽȁǴǹǯ ǓǺȎ ȌȁǽDzǽ ǾǿǽȀȁǽ dzǽǰǯDZǺȎǴǻ dzǯǼǼǽǴ DZȊǿǯǵǴǼǷǴ DZ ǼǯȆǯǺǽ Page.xaml.cs: using System.Xml.Linq;
Ǘȁǯǹ, ǾǽǺȂȆǯǴǻ ǹǽdz ǽǰǿǯǰǽȁȆǷǹǯ ȀǽǰȊȁǷǸ client DownloadStringCompleted: void client DownloadStringCompleted( object sender, DownloadStringCompletedEventArgs e) { XDocument xmlHeadlines = XDocument.Parse(e.Result); var headlines = from story in xmlHeadlines.Descendants("item") select new NewsHeadLine { strHead = (string)story.Element("title"), strLine = (string)story.Element("link") }; GrdHeadline.ItemsSource = headlines; }
Ǭȁǽȁ ǹǽdz ǽǰǴȀǾǴȆǷDZǯǴȁ ȀǷǼȁǯǹȀǷȆǴȀǹǷǸ ǿǯǶǰǽǿ dzǯǼǼȊȄ DZǽǶDZǿǯȈǯǴǻȊȄ DZ ǿǴǶȂǺȋȁǯȁǴ ǶǯǾǿǽȀǯ ǹ ȀǴǿDZǷȀȂ ȄǿǯǼȎȈǷȄȀȎ DZ e.Result DZ ǽǰȉǴǹȁ XDocument ǞǽȀǺǴ ȌȁǽDzǽ Ȁ ǾǽǻǽȈȋȍ Linq dzǯǼǼȊǴ DZȊǰǷǿǯȍȁȀȎ ǷǶ XDocument Ƿ ȀǽǶdzǯǴȁȀȎ ǹǽǺǺǴǹȅǷȎ ǶǯDzǽǺǽDZǹǽDZ ǖǯȁǴǻ Ȍȁǯ ǹǽǺǺǴǹȅǷȎ ǾǿǷȀDZǯǷDZǯǴȁȀȎ ǹǯǹ ǶǼǯȆǴǼǷǴ ȀDZǽǸȀȁDZȂ ItemsSource ǗȀȁǽȆǼǷǹ ȌǺǴǻǴǼȁǽDZ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ DataGrid ǟǴǶȂǺȋȁǯȁȊ ǾǿǴdzȀȁǯDZǺǴǼȊ Ǽǯ ǿǷȀ 8-2.
ǒǺǯDZǯ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ 6LOYHUOLJKW ǿǯȀȇǷǿǴǼǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ
159
ǟǗǠ 8 1 ǓǽǰǯDZǺǴǼǷǴ ȀȀȊǺǹǷ Ǽǯ System.Xml.Linq.
ǟǗǠ 8 2 ǝǰǿǯǶǴȅ ǹǽǺǺǴǹȅǷǷ ǶǯDzǽǺǽDZǹǽDZ ȀǽǶdzǯǼǼȊǸ ǾǿǷ DZȊǾǽǺǼǴǼǷǷ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ DataGrid.
Ǒ DataGrid DZǽǶǻǽǵǼȊ dzDZǯ ǿǴǵǷǻǯ DZȊǰǽǿǯ ǽdzǷǼǽȆǼȊǸ ǾǿǷ ǹǽȁǽǿǽǻ ǻǽǵǼǽ DZȊǰǷǿǯȁȋ Ǿǽ ǽdzǼǽǸ ȀȁǿǽǹǴ Ƿ ǻǼǽǵǴȀȁDZǴǼǼȊǸ ǾǿǷ ǹǽȁǽǿǽǻ ǾǿǷ ȂdzǴǿǵǯǼǷǷ ǹǺǯDZǷȇ Ctrl ǷǷǺǷ Shift ǻǽǵǴȁ ǰȊȁȋ DZȊǰǿǯǼǽ ǼǴȀǹǽǺȋǹǽ Ȁȁǿǽǹ. ǬȁǷ ǿǴǵǷǻȊ ǶǯdzǯȍȁȀȎ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ SelectionMode ǟǴǵǷǻ DZȊǰǽǿǯ ǹǽȁǽǿǽǴ ǾǿǷǼǷǻǯǴȁ ǶǼǯȆǴ ǼǷȎ DataGridSelectionMode.Single dzǺȎ ǽdzǷǼǽȆǼǽDzǽ DZȊǰǽǿǯ Ƿ DataGridSelectionMode.Extended dzǺȎ ǻǼǽǵǴ ȀȁDZǴǼǼǽDzǽ ǞǿǷ ǷȀǾǽǺȋǶǽDZǯǼǷǷ ǴdzǷǼǷȆǼǽDzǽ ǿǴǵǷǻǯ DZȊǰǿǯǼǼȊǸ ȌǺǴǻǴǼȁ ȀǽȄǿǯǼȎǴȁȀȎ DZ SelectedItem ǔȀǺǷ Ȍȁǽȁ ǽǰȉǴǹȁ ȁǷǾǯ object ǾǴǿǴdz ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǽǼ dzǽǺǵǴǼ ǰȊȁȋ ǾǿǷDZǴdzǴǼ ǹ ȀǽǽȁDZǴȁȀȁDZȂȍȈǴǻȂ ȁǷǾȂ ǑȊ DZǷ dzǴǺǷ Ȇȁǽ ȀǴȁǹǯ ǶǯǾǽǺǼȎǺǯȀȋ ȌǺǴǻǴǼȁǯǻǷ ǽǾǿǴdzǴǺǴǼǼǽDzǽ ǼǯǻǷ ǹǺǯȀȀǯ NewsHeadLine. Ǘȁǯǹ, dzǺȎ ǴdzǷǼǷȆǼǽDzǽ DZȊǰǽǿǯ DZȊǰǿǯǼǼȊǴ dzǯǼǼȊǴ ǻǽDzȂȁ ǰȊȁȋ ǾǽǺȂȆǴǼȊ ȀǺǴdzȂȍȈǷǻ ǽǰǿǯǶǽǻ: NewsHeadLine theHeadline = GrdHeadline.SelectedItem as NewsHeadLine;
ǙǽDzdzǯ ȂȀȁǯǼǽDZǺǴǼ ǿǴǵǷǻ ǻǼǽǵǴȀȁDZǴǼǼǽDzǽ DZȊǰǽǿǯ ǻǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ ȀDZǽǸȀȁDZǽ SelectedItems DZǽǶ DZǿǯȈǯȍȈǴǴ ǹǽǺǺǴǹȅǷȍ ȀǾǷȀǹǽDZ Ǭȁǽ ǽȆǴǼȋ ǾǿǽȀȁǽ ȀdzǴǺǯȁȋ, DZǽȁ ǹǽdz:
160
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2 string strHead; string strLink; System.Collections.IList listOfItems = GrdHeadline.SelectedItems; foreach(NewsHeadLine newsHead in listOfItems) { strHead = newsHead.strHead; strLink = newsHead.strLine; }
Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ, ȀDZǽǸȀȁDZǽ SelectedItems DZǽǶDZǿǯȈǯǴȁ System.Collections.IList. ǞǽȀǺǴ ȌȁǽDzǽ ǻǽǵǼǽ ǾǴǿǴ ǰǿǯȁȋ ǴDzǽ ȌǺǴǻǴǼȁȊ, ǷǶDZǺǴǹǯȎ ǹǯǵdzȊǸ ǷǶ ǽǰȉǴǹȁǽDZ NewsHeadline Ƿ ǾǽǺȂȆǯȎ ǴDzǽ dzǯǼǼȊǴ. ǞǿǷ ǷȀǾǽǺȋǶǽDZǯǼǷǷ ǺȍǰǽǸ ȁǯǰǺǷȅȊ Ƿ DataGrid ǶdzǴȀȋ ǼǴ ǷȀǹǺȍȆǴǼǷǴ DZȀǴDzdzǯ ǾǽǺǴǶǼǽ ȀdzǴǺǯȁȋ ǴǴ ǰǽǺǴǴ ȂdzǽǰǼǽǸ dzǺȎ DZǽȀǾǿǷȎȁǷȎ ǾȂȁǴǻ ǷȀǾǽǺȋǶǽDZǯǼǷȎ ȅDZǴȁǼȊȄ ǾǽǺǽȀ ȁǴ ȆǴǿǴdzǽDZǯȁȋ ǶǯǹǿǯȇǴǼǼȂȍ Ƿ ǼǴǶǯ ǹǿǯȇǴǼǼȂȍ ȀȁǿǽǹǷ ǾǽǾǴǿǴǻǴǼǼǽ ǿǯǶǼȊǻǷ ȅDZǴȁǯǻǷ ǷǺǷ ǽȁȁǴǼǹǯǻǷ Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ ȆȁǽǰȊ ȀdzǴǺǯȁȋ DataGrid ǾǽǺǽȀǯȁȊǻ ǻǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ ȀDZǽǸȀȁDZǯ RowBackground ǣǽǼ ȀȁǿǽǹǷ Ƿ AlternatingRowBackground ǦǴǿǴdzȂȍȈǷǸȀȎ ȃǽǼ ȀȁǿǽǹǷ Ǒ ǹǯȆǴȀȁDZǴ ǶǼǯȆǴǼǷǸ ȌȁǷǻ ȀDZǽǸȀȁDZǯǻ ǶǯdzǯǴȁȀȎ ȅDZǴȁ ǹǷȀȁǷ ȀǺǴdzȂȍ ȈǷǻ ǽǰǿǯǶǽǻ GrdHeadline.RowBackground = new SolidColorBrush(Colors.LightGray); GrdHeadline.AlternatingRowBackground = new SolidColorBrush(Colors.Yellow);
ǟǴǶȂǺȋȁǯȁ ȁǯǹǽDzǽ ȃǽǿǻǯȁǷǿǽDZǯǼǷȎ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 8-3.
ǟǗǠ 8 3 ǦǴǿǴdzǽDZǯǼǷǴ ȅDZǴȁǽDZ Ȁȁǿǽǹ.
ǑǽǶǻǽǵǼǽ DZȊ ǽǰǿǯȁǷǺǷ DZǼǷǻǯǼǷǴ Ȇȁǽ ȀȁǽǺǰȅȊ dzǽǰǯDZǺȎȍȁȀȎ DZ ȁǽǻ ǾǽǿȎdzǹǴ DZ ǹǽȁǽǿǽǻ dzǯǼǼȊǴ ǽǾǿǴ dzǴǺǴǼȊ DZ ǹǺǯȀȀǴ NewsHeadLine ǝdzǼǯǹǽ ǾǽǿȎdzǽǹ DZȊDZǽdzǯ dzǯǼǼȊȄ Ǽǯ ȌǹǿǯǼ ǻǽǵǼǽ ǻǴǼȎȁȋ ǜǯȀȁǿǽǸǹȂ Ǿǽ ȂǻǽǺȆǯǼǷȍ ǻǽǵǼǽ ǾǴǿǴǽǾǿǴdzǴǺǷȁȋ ȀDZǽǸȀȁDZǽǻ DisplayIndex ǗǼdzǴǹȀ ǽȁǽǰǿǯǵǴǼǷȎ ǜǯǾǿǷǻǴǿ DZ ǼǯȇǴǻ DataGrid dzDZǯ ȀȁǽǺǰȅǯ Ǒ ǾǴǿDZǽǻ DZȊDZǽdzȎȁȀȎ ǶǯDzǽǺǽDZǹǷ DZǽ DZȁǽǿǽǻ ² ȀȀȊǺǹǷ ǗȄ ǻǽǵǼǽ ǾǽǻǴǼȎȁȋ ǻǴȀȁǯ ǻǷ ȀǺǴdzȂȍȈǷǻ ȀǾǽȀǽǰǽǻ GrdHeadline.Columns[0].DisplayIndex = 1; GrdHeadline.Columns[1].DisplayIndex = 0;
ǐǽǺǴǴ ȇǷǿǽǹǷǴ DZǽǶǻǽǵǼǽȀȁǷ ȂǾǿǯDZǺǴǼǷȎ DZǷǶȂǯǺȋǼȊǻ ǾǿǴdzȀȁǯDZǺǴǼǷǴǻ dzǯǼǼȊȄ DZ ȀǴȁǹǴ ǾǿǴdzǽȀȁǯDZǺȎǴȁ ȇǯǰǺǽǼ dzǯǼǼȊȄ ǧǯǰǺǽǼ dzǯǼǼȊȄ ² Ȍȁǽ XAML ǽǾǿǴdzǴǺȎȍȈǷǸ ȁǽ ǹǯǹ dzǽǺǵǼȊ ǰȊȁȋ ǽǿDzǯǼǷǶǽDZǯǼȊ dzǯǼ ǼȊǴ DZǹǺȍȆǯȎ ǾǿǷDZȎǶǹȂ ǹ ǹǽǼǹǿǴȁǼȊǻ ǾǽǺȎǻ ǜǯǾǿǷǻǴǿ DZ ǾǿǴdzȊdzȂȈǷȄ ǾǿǷǻǴǿǯȄ DZȊDZǽdzǯ ǹǯǵdzǯȎ ȎȆǴǸ ǹǯ ȁǯǰǺǷȅȊ ǰȊǺǯ ȀDZȎǶǯǼǯ Ȁ ǽǾǿǴdzǴǺǴǼǼȊǻ ȌǺǴǻǴǼȁǽǻ RSS-ǹǯǼǯǺǯ ǦȁǽǰȊ DZȊDZǴȀȁǷ dzDZǯ ǾǽǺȎ RSS-ǹǯǼǯǺǯ DZ ǽdzǼǽǸ ȎȆǴǸǹǴ ǼǴǽǰȄǽdzǷǻǽ ǷȀǾǽǺȋǶǽDZǯȁȋ ȇǯǰǺǽǼ dzǯǼǼȊȄ ǟǯȀȀǻǽȁǿǷǻ ȀǺǴdzȂȍȈǷǸ XAML:
Ǒ Ȍȁǽǻ XAML ȀȁǽǺǰȅȊ DataGrid ǶǯdzǯǼȊ ǶǯǿǯǼǴǴ Ȁ ǾǽǻǽȈȋȍ ȌǺǴǻǴǼȁǯ . ǛȊ ǻǽ ǵǴǻ ǾǴǿǴǽǾǿǴdzǴǺǷȁȋ ȇǯǰǺǽǼ dzǺȎ ȀȁǽǺǰȅǽDZ Ǿǽ ȂǻǽǺȆǯǼǷȍ ǹǽDzdzǯ DZ ȎȆǴǸǹǴ DZȊDZǽdzǷȁȀȎ ǽdzǼǽ ǾǽǺǴ Ƕǯdzǯ DZǯȎ dzǺȎ ǹǯǵdzǽǸ ȎȆǴǸǹǷ DZ ǹǽȁǽǿǽǻ ǷǻǴǴȁȀȎ ǹǽdz ǽǾǷȀȊ DZǯȍȈǷǸ ǹǯǹ dzǽǺǵǼǯ ǽȁǽǰǿǯǵǯȁȋȀȎ ȎȆǴǸǹǯ Ǚǯǹ DZǷdzǷȁǴ ǽǾǷȀǯǼǽ ȁǽǺȋǹǽ dzDZǴ ȎȆǴǸǹǷ ǾǽȌȁǽǻȂ dzǯǼǼǯȎ ȁǯǰǺǷȅǯ ǼǴǶǯDZǷȀǷǻǽ ǽȁ ǹǽǺǷȆǴȀȁDZǯ ǾǽǺǴǸ dzǯǼǼȊȄ ǰȂdzǴȁ ǷǻǴȁȋ ȁǽǺȋǹǽ dzDZǯ ȀȁǽǺǰȅǯ ǞǴǿDZȊǸ ȀȁǽǺǰǴȅ ǽǾǿǴdzǴǺǴǼǼȊǸ ȇǯǰǺǽǼǽǻ ǾǴǿDZǽǸ ȎȆǴǸǹǷ ǰȂdzǴȁ ǾǿǴdzȀȁǯDZǺǴǼ ȌǺǴǻǴǼȁǽǻ StackPanel ȀǽdzǴǿǵǯȈǷǻ ȁǿǷ ȁǴǹȀȁǽDZȊȄ ǾǽǺȎ DZ ǹǽȁǽǿȊȄ DZȊDZǽdzȎȁȀȎ Ƕǯ dzǯǼǼǽǴ DZ ǹǽdzǴ ©ª ȀDZȎǶǯǼǼǽǴ Ȁ dzǯǼǼȊǻǷ ȀDZǽǸȀȁDZǽ strHead ǹǺǯȀȀǯ NewsHeadline Ƿ ȀDZȎǶǯǼǼǽǴ Ȁ dzǯǼǼȊ ǻǷ ȀDZǽǸȀȁDZǽ strPubDate ȁǽDzǽ ǵǴ ǹǺǯȀȀǯ NewsHeadline. StackPanel DZȊDZǽdzǷȁ ȌȁǷ ǾǽǺȎ dzǿȂDz Ǽǯdz dzǿȂDzǽǻ ǑȁǽǿǽǸ ȀȁǽǺǰǴȅ ǽǾǷȀǯǼǼȊǸ ȇǯǰǺǽǼǽǻ DZȁǽǿǽǸ ȎȆǴǸǹǷ ȎDZǺȎǴȁȀȎ ǾǿǽȀȁȊǻ TextBlock ȀDZȎǶǯǼǼȊǻ Ȁ ǾǽǺǴǻ strLine ǑǽǶǻǽǵǼǽ DZȊ ǶǯǻǴȁǷǺǷ Ȇȁǽ ǶdzǴȀȋ ǾǽȎDZǷǺǽȀȋ ǴȈǴ ǽdzǼǽ ǾǽǺǴ strPubDate ǹǽȁǽǿǽDzǽ ǼǴ ǰȊǺǽ DZ ǷȀȄǽdzǼǽǻ ǾǿǷǻǴǿǴ ǹǺǯȀȀǯ ǾǽȌȁǽǻȂ ǽǾǷȀǯǼǷǴ ǹǺǯȀȀǯ Ƿ ǹǽdz ǾǿǷDZȎǶǹǷ ǼǴǽǰȄǽdzǷǻǽ ǽǰǼǽDZǷȁȋ Ǒǽȁ ǼǽDZǽǴ ǽǾǷȀǯǼǷǴ ǹǺǯȀȀǯ: public class { public public public public }
NewsHeadLine string string string string
strHead { get; set; } strLine { get; set; } strDescription { get; set; } strPubDate { get; set; }
Ǘ DZǽȁ ǼǽDZȊǸ ǹǽdz ǾǿǷDZȎǶǹǷ dzǯǼǼȊȄ, ǹǽȁǽǿȊǸ ǽǰǴȀǾǴȆǷDZǯǴȁ ǾǿǷDZȎǶǹȂ dzǽǾǽǺǼǷȁǴǺȋǼȊȄ ǾǽǺǴǸ: void client DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { XDocument xmlHeadlines = XDocument.Parse(e.Result); var headlines = from story in xmlHeadlines.Descendants("item") select new NewsHeadLine { strHead = (string)story.Element("title"), strLine = (string)story.Element("link"), strDescription = (string)story.Element("description"), strPubDate = (string)story.Element("pubDate") };
162
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2 GrdHeadline.ItemsSource = headlines; }
ǦȁǽǰȊ ȂDZǷdzǴȁȋ ǼǽDZȊǴ dzǯǼǼȊǴ ǼǴǽǰȄǽdzǷǻǽ DZǼǴȀȁǷ ǴȈǴ ǽdzǼȂ ǼǴǰǽǺȋȇȂȍ ǹǽǿǿǴǹȁǷDZȂ ² ǷǶǻǴǼǷȁȋ DZȊȀǽȁȂ ȀȁǿǽǹǷ ǠǴǸȆǯȀ DZ ǼǴǸ ǻǽǵǴȁ ǽȁǽǰǿǯǵǯȁȋȀȎ ȁǽǺȋǹǽ ǽdzǼǯ Ȁȁǿǽǹǯ ȁǴǹȀȁǯ DZ ǿǴǶȂǺȋȁǯȁǴ ȆǴDzǽ ȀǽdzǴǿǵǷǻǽǴ ǾǴǿDZǽǸ ȎȆǴǸǹǷ ǰȂdzǴȁ ǽǰǿǴǶǯǼǽ Ǿǽ DZǴǿȁǷǹǯǺǷ ǡǯǹǵǴ ǾǽǼǯdzǽǰǷȁȋȀȎ ǽȁǹǺȍȆǷȁȋ ǯDZȁǽǻǯȁǷȆǴȀǹǽǴ ǽǾǿǴdzǴ ǺǴǼǷǴ ȀȁǽǺǰȅǽDZ ǾǽȁǽǻȂ Ȇȁǽ ǻȊ ȄǽȁǷǻ ǾǴǿǴǽǾǿǴdzǴǺǷȁȋ ǾǽDZǴdzǴǼǷǴ ǾǿǷDZȎǶǹǷ dzǯǼǼȊȄ DataGrid Ǿǽ ȂǻǽǺ ȆǯǼǷȍ Ǭȁǽ ǽǰǴȀǾǴȆǷDZǯǴȁ ȀǺǴdzȂȍȈǷǸ ǹǽdz ǾǽǻǴȀȁǷȁǴ ǴDzǽ DZ ǹǽǼȀȁǿȂǹȁǽǿ Page): GrdHeadline.AutoGenerateColumns = false; GrdHeadline.RowHeight = 60;
ǡǴǾǴǿȋ ǾǽȀǺǴ DZȊǾǽǺǼǴǼǷȎ ȌȁǽDzǽ ǹǽdzǯ Ǽǯ ȌǹǿǯǼ ǰȂdzǴȁ DZȊDZǴdzǴǼ DataGrid Ȁ ȎȆǴǸǹǯǻǷ ȀǽǽȁDZǴȁȀȁDZȂȍȈǷǻǷ ǶǯdzǯǼǼȊǻ ȇǯǰǺǽǼǯǻ ǿǷȀ 8- ǑȊDzǺȎdzǷȁ ǼǴ ǽȆǴǼȋ ǹǿǯȀǷDZǽ Ǽǽ ǶǯǻǴȆǯȁǴǺȋǼǽ ǷǺǺȍȀȁǿǷǿȂǴȁ DZǽǶǻǽǵǼǽ ȀȁǷ ȂǾǿǯDZǺǴǼǷȎ ǾǿǴdzȀȁǯDZǺǴǼǷǴǻ dzǯǼǼȊȄ DZ ȌǺǴǻǴǼȁǴ ȂǾǿǯDZǺǴǼǷȎ DataGrid.
ǟǗǠ 8 4 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȇǯǰǺǽǼǯ dzǯǼǼȊȄ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ DZǷǶȂǯǺȋǼǽDzǽ ǾǿǴdzȀȁǯDZǺǴǼǷȎ dzǯǼǼȊȄ.
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ DataGrid ǽǰǺǯdzǯǴȁ ǰǽDzǯȁǴǸȇǷǻ API ǹǽȁǽǿȊǸ ǶǯȀǺȂǵǷDZǯǴȁ ǽȁdzǴǺȋǼǽǸ ǹǼǷDzǷ ǝdzǼǯ ǹǽ ȁǽDzǽ Ȇȁǽ ǰȊǺǽ ǿǯȀȀǹǯǶǯǼǽ ǽ ǼǴǻ Ǽǯ ȌȁǷȄ ǼǴȀǹǽǺȋǹǷȄ ȀȁǿǯǼǷȅǯȄ dzǽȀȁǯȁǽȆǼǽ ȆȁǽǰȊ ǾǽǼȎȁȋ ǹǯǹȂȍ ǼǴ DZǴǿǽȎȁǼȂȍ DzǷǰǹǽȀȁȋ ǽǼ ǽǰǴȀǾǴȆǷDZǯǴȁ ǑȊ ȀǻǽǵǴȁǴ ǷȀǾǽǺȋǶǽDZǯȁȋ ȌȁȂ ǰǯǶǽDZȂȍ ǷǼȃǽǿǻǯȅǷȍ dzǺȎ ǾǴǿǴȄǽ dzǯ Ǽǯ ȀǺǴdzȂȍȈǷǸ ȂǿǽDZǴǼȋ ǾǿǷ ȀǽǶdzǯǼǷǷ ȀǽǰȀȁDZǴǼǼȊȄ ǾǿǷǺǽǵǴǼǷǸ Silverlight!
ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Calendar Ƿ DatePicker ǑǽǶǻǽǵǼǽȀȁȋ ǷȀǾǽǺȋǶǽDZǯǼǷȎ dzǯȁ DZ ǾǿǷǺǽǵǴǼǷȎȄ Silverlight ǽǰǴȀǾǴȆǷDZǯǴȁȀȎ ȌǺǴǻǴǼȁǯǻǷ ȂǾǿǯDZǺǴǼǷȎ Calendar ǙǯǺǴǼdzǯǿȋ Ƿ DatePicker (ǬǺǴǻǴǼȁ DZȊǰǽǿǯ dzǯȁ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Calendar DZȊDZǽdzǷȁ Ǽǯ ȌǹǿǯǼ dzǼǷ ǶǯdzǯǼǼǽDzǽ ǻǴȀȎȅǯ ǷǺǷ ǻǴȀȎȅȊ ǶǯdzǯǼǼǽDzǽ Dzǽdzǯ Ƿ ǾǿǴdzǽȀȁǯDZǺȎǴȁ ǹǼǽǾǹǷ Ȁǽ ȀȁǿǴǺǹǯǻǷ dzǺȎ ǾǴǿǴǻǴ ȈǴǼǷȎ Ǿǽ ǻǴȀȎȅǯǻ ǷǺǷ Dzǽdzǯǻ DatePicker ȀǽȆǴȁǯǴȁ Ȍȁǽ ǾǿǴdzȀȁǯDZǺǴǼǷǴ Ȁ ȁǴǹȀȁǽDZȊǻ ǾǽǺǴǻ DZ ǹǽȁǽǿǽǴ ǾǽǺȋǶǽDZǯȁǴǺȋ ǻǽǵǴȁ DZDZǽdzǷȁȋ dzǯȁȂ DZ ȀǽǽȁDZǴȁȀȁDZȂȍȈǴǻ ȃǽǿǻǯȁǴ ǷǺǷ DZȊǾǯdzǯȍȈǷǻ ȀǾǷȀǹǽǻ DZ ǹǽȁǽǿǽǻ ǻǽǵǼǽ DZȊǰǿǯȁȋ ǽǾǿǴdzǴǺǴǼǼȂȍ dzǯȁȂ ǟǯȀȀǻǽȁǿǷǻ ȀǼǯȆǯǺǯ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Calendar. ǝǼ ǾǿǽȀȁ ǾǽȌȁǽǻȂ ȂdzǽǰǼǽ ǼǯȆǷǼǯȁȋ Ȁ ǼǴDzǽ: P\&DOHQGDU [1DPH ´FDO´!P\&DOHQGDU!
ǒǺǯDZǯ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ 6LOYHUOLJKW ǿǯȀȇǷǿǴǼǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ
163
Ǭȁǽ ǽǰǴȀǾǴȆǷȁ ǽȁǽǰǿǯǵǴǼǷǴ Calendar DZ ȀȁǯǼdzǯǿȁǼǽǻ ǾǿǴdzȀȁǯDZǺǴǼǷǷ ǻǴȀȎȅǯ Ȁ DZȊdzǴǺǴǼǼȊǻ ȀǽǽȁDZǴȁȀȁ DZǴǼǼǽ ȀǴDzǽdzǼȎȇǼǴǻȂ ȆǷȀǺȂ dzǼǴǻ ǞǽȀǻǽȁǿǷȁǴ Ǽǯ ǿǷȀ 8- Ǚǯǹ DZǷdzǷȁǴ Ȍȁǽȁ ȀǼǷǻǽǹ ȌǹǿǯǼǯ ǰȊǺ ȀǽǶdzǯǼ ǼǽȎǰǿȎ DZ ǾǽǼǴdzǴǺȋǼǷǹ
ǟǗǠ 8 5 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Calendar.
ǛǴȀȎȅ ǽȁǽǰǿǯǵǯǴǻǽǸ dzǯȁȊ ǶǯdzǯǴȁȀȎ ȀDZǽǸȀȁDZǽǻ DisplayDate ǝȁǽǰǿǯǵǯǴǻǯȎ dzǯȁǯ ǜǯǾǿǷǻǴǿ ȀǺǴdzȂȍ ȈǷǸ ǹǽdz ǽǰǴȀǾǴȆǷDZǯǴȁ DZȊǰǽǿ dzǯȁȊ ȎǼDZǯǿȎ Dzǽdzǯ DateTime d = new DateTime(2009, 1, 1); cal.DisplayDate = d;
Ǭȁǽ ǽǰǴȀǾǴȆǷȁ ǽȁǽǰǿǯǵǴǼǷǴ DZȊǰǿǯǼǼǽDzǽ ǻǴȀȎȅǯ Ǽǽ ǰǴǶ ȂǹǯǶǯǼǷȎ ǹǽǼǹǿǴȁǼǽDzǽ dzǼȎ ǞǽȀǻǽȁǿǷȁǴ Ǽǯ ǹǯ ǺǴǼdzǯǿȋ ǾǿǴdzȀȁǯDZǺǴǼǼȊǸ Ǽǯ ǿǷȀ 8-6.
ǟǗǠ 8 6 ǗǶǻǴǼǴǼǷǴ ǽȁǽǰǿǯǵǯǴǻǽǸ dzǯȁȊ.
ǠǿǯDZǼǷȁǴ ǿǷȀ. 8-6 Ƿ ǿǷȀ. 8-5. ǛǽǵǼǽ ǶǯǻǴȁǷȁȋ, Ȇȁǽ Ǽǯ ǿǷȀ. 8- dzǯȁǯ ǼǴ DZȊǰǿǯǼǯ ǞǿǷ ǶǯdzǯǼǷǷ ǽȁǽǰǿǯ ǵǯǴǻǽǸ dzǯȁȊ DZȊǰǿǯǼǼǯȎ dzǯȁǯ ǰȊǺǯ ǽǰǼȂǺǴǼǯ ǾǽȌȁǽǻȂ ȀDZǽǸȀȁDZǽ SelectedDate ǑȊǰǿǯǼǼǯȎ dzǯȁǯ ǷǻǴǴȁ ǶǼǯȆǴǼǷǴ null ǔȀǺǷ DZȊ DZȊǰǴǿǴȁǴ ǹǯǹǽǸ-ȁǽ dzǴǼȋ Ǽǯ ȌǹǿǯǼǴ ȀDZǽǸȀȁDZȂ SelectedDate ǰȂdzǴȁ ǾǿǷȀDZǽǴǼǽ Ȍȁǽ ǶǼǯȆǴǼǷǴ ȁǷǾǯ DateTime ǷǺǷ dzǯȁȂ ǻǽǵǼǽ Ƕǯdzǯȁȋ DZ ǹǽdzǴ ȆǴǿǴǶ DZȀǴ ȁǽ ǵǴ ȀDZǽǸȀȁDZǽ SelectedDate ǜǯǾǿǷ ǻǴǿ DateTime s = new DateTime(2009, 1, 31); cal.SelectedDate = s;
Ǚǯǹ Ȍȁǽ DZȊDzǺȎdzǷȁ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 8- ǡǴǾǴǿȋ Ǽǯ ǽȁǽǰǿǯǵǯǴǻǽǻ ǹǯǺǴǼdzǯǿǴ DZȊǰǿǯǼǯ dzǯȁǯ ȎǼ DZǯǿȎ
164
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
ǙǽǺǺǴǹȅǷȎ BlackoutDates ǜǴdzǽȀȁȂǾǼȊǴ dzǯȁȊ ǾǽǶDZǽǺȎǴȁ ǶǯdzǯDZǯȁȋ dzǷǯǾǯǶǽǼ dzǯȁ ǹǽȁǽǿȊǴ ǼǴ ǻǽDzȂȁ ǰȊȁȋ DZȊǰǿǯǼȊ Ǭȁǯ ǹǽǺǺǴǹȅǷȎ ȀǽdzǴǿǵǷȁ ȁǷǾ CalendarDateRangeCollection ǙǽǺǺǴǹȅǷȎ dzǷǯǾǯǶǽǼǯ dzǯȁ ǹǯǺǴǼdzǯ ǿȎ DZ ǹǽȁǽǿȊǸ ǻǽDzȂȁ dzǽǰǯDZǺȎȁȋȀȎ dzǷǯǾǯǶǽǼȊ dzǯȁ ǑȀǴ dzǯȁȊ ǾǽǾǯdzǯȍȈǷǴ DZ Ȍȁǽȁ dzǷǯǾǯǶǽǼ ǰȂdzȂȁ ǽȁǽ ǰǿǯǵǯȁȋȀȎ ǼǴǯǹȁǷDZǼȊǻǷ Ƿ ȁǯǹǷǻ ǽǰǿǯǶǽǻ ǼǴ ǻǽDzȂȁ ǰȊȁȋ DZȊǰǿǯǼȊ ǠDZǽǸȀȁDZǯ SelectableDateStart ǜǯȆǯ Ǻǽ dzǯȁ dzǽȀȁȂǾǼȊȄ dzǺȎ DZȊǰǽǿǯ Ƿ SelectableDateEnd ǙǽǼǴȅ dzǯȁ dzǽȀȁȂǾǼȊȄ dzǺȎ DZȊǰǽǿǯ Ƕǯdzǯȍȁ dzǷǯǾǯǶǽǼ ǽȁǽǰǿǯǵǯǴǻȊȄ dzǯȁ ǜǯǾǿǷǻǴǿ Ȁ ǾǽǻǽȈȋȍ ȌȁǷȄ ȀDZǽǸȀȁDZ ǻǽǵǼǽ ǽǰǴȀǾǴȆǷȁȋ DZȊDZǽdz Ǽǯ ȌǹǿǯǼ ǹǯǺǴǼdzǯǿȋ ȀǽdzǴǿǵǯȈǷǸ dzǷǯǾǯǶǽǼ ǽȁǽǰǿǯǵǯǴǻȊȄ dzǯȁ Ƿ dzǷǯǾǯǶǽǼ ǽǰȊȆǼǽ ǾǽdzdzǷǯǾǯǶǽǼ dzǯȁ dzǽȀȁȂǾǼȊȄ dzǺȎ DZȊǰǽ ǿǯ
ǟǗǠ. 8 7 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀDZǽǸȀȁDZǯ SelectedDate.
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ DatePicker ȀǽȆǴȁǯǴȁ ȌȁȂ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁȋ Ȁ ȁǴǹȀȁǽDZȊǻ ǾǽǺǴǻ ǠDZǽǸȀȁDZǽ Text ȌȁǽDzǽ ǾǽǺȎ ȀǽdzǴǿǵǷȁ DZȀǴ Ȇȁǽ ǾǽǺȋǶǽDZǯȁǴǺȋ DZDZǽdzǷȁ DZ ǹǯȆǴȀȁDZǴ dzǯȁȊ ǔȀǺǷ ǼǴDZǽǶǻǽǵǼǽ DZȊǾǽǺǼǷȁȋ ȀǷǼȁǯǹȀǷ ȆǴȀǹǷǸ ǿǯǶǰǽǿ DZDZǴdzǴǼǼȊȄ ǾǽǺȋǶǽDZǯȁǴǺǴǻ dzǯǼǼȊȄ ȃǽǿǻǷǿȂǴȁȀȎ ǽȇǷǰǹǯ TextParseError ǝȇǷǰǹǯ ȀǷǼȁǯǹ ȀǷȆǴȀǹǽDzǽ ǿǯǶǰǽǿǯ ȁǴǹȀȁǯ ǠǾǿǯDZǯ ǽȁ ȁǴǹȀȁǽDZǽDzǽ ǾǽǺȎ ǻǽǵǼǽ ȂDZǷdzǴȁȋ ǶǼǯȆǽǹ DZȊǰǽǿ ǹǽȁǽǿǽDzǽ ǽǰǴȀǾǴȆǷDZǯǴȁ ǽȁǽǰǿǯǵǴǼǷǴ ȌǺǴ ǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Calendar dzǺȎ DZȊǰǽǿǯ dzǯȁȊ ǙǽDzdzǯ ǾǽǺȋǶǽDZǯȁǴǺȋ ȈǴǺǹǯǴȁ Ȍȁǽȁ ǶǼǯȆǽǹ ȃǽǿǻǷǿȂǴȁȀȎ ȀǽǰȊȁǷǴ CalendarOpened ǙǯǺǴǼdzǯǿȋ ǽȁǹǿȊȁ ǙǽDzdzǯ ǾǽǺȋǶǽDZǯȁǴǺȋ ǶǯǹǿȊDZǯǴȁ ǴDzǽ ȃǽǿǻǷǿȂǴȁȀȎ ȀǽǰȊȁǷǴ CalendarClosed ǙǯǺǴǼdzǯǿȋ ǶǯǹǿȊȁ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Calendar Ƿ DatePicker ǽǰǴȀǾǴȆǷDZǯȍȁ ǰǯǶǽDZȊǴ ȀǿǴdzȀȁDZǯ dzǺȎ ȀǽǶdzǯǼǷȎ ǾǿǷǺǽǵǴǼǷǸ DZ ǹǽȁǽǿȊȄ DZDZǽdz ǽȀǼǽDZȊDZǯǴȁȀȎ Ǽǯ dzǯȁǯȄ Ƿ ǹǽȁǽǿȊǴ ǻǽDzȂȁ ǽȁǽǰǿǯ ǵǯȁȋ ǷǼȃǽǿǻǯȅǷȍ ǹǯǺǴǼdzǯǿȎ.
ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ RepeatButton Ƿ ToggleButton ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ RepeatButton (ǙǼǽǾǹǯ ǾǽDZȁǽǿǯ ǾǿǴdzǽȀȁǯDZǺȎǴȁ ǹǼǽǾǹȂ ǾǿǷ ǼǯǵǯȁǷǷ ǹǽȁǽǿǽǸ ȃǽǿ ǻǷǿȂǴȁȀȎ ǻǼǽǵǴȀȁDZǽ ȀǽǰȊȁǷǸ ȈǴǺȆǹǯ ǦǯȀȁǽȁǯ ȃǽǿǻǷǿǽDZǯǼǷȎ ȀǽǰȊȁǷǸ ǽǾǿǴdzǴǺȎǴȁȀȎ ȀDZǽǸȀȁDZǽǻ Delay ǖǯdzǴǿǵǹǯ ǽǼǽ ǶǯdzǯǴȁȀȎ DZ ǻǷǺǺǷȀǴǹȂǼdzǯȄ ǜǯǾǿǷǻǴǿ, ǿǯȀȀǻǽȁǿǷǻ ȀǺǴdzȂȍȈǷǸ XAML:
Ǒ Ȍȁǽǻ ȃǿǯDzǻǴǼȁǴ ǶǯdzǯǴȁȀȎ ǹǽdz ǹǼǽǾǹǷ ǾǽDZȁǽǿǯ rpt Ȁ ǶǯdzǴǿǵǹǽǸ ǻǷǺǺǷȀǴǹȂǼdz ȀǽdzǴǿǵǷǻǽǴ ǹǽȁǽǿǽǸ Ǿǽ ȂǻǽǺȆǯǼǷȍ ǿǯDZǼǽ ǝǰǿǯǰǽȁǹǯ ȈǴǺȆǹǯ ǾǽǺȋǶǽDZǯȁǴǺȎ ǼǯȄǽdzǷȁȀȎ DZ ǽǰǿǯǰǽȁȆǷǹǴ ȀǽǰȊȁǷǸ rpt Click. Ǒǽȁ ǹǽdz ȌȁǽDzǽ ǽǰǿǯǰǽȁȆǷǹǯ ȀǽǰȊȁǷǸ private void rpt Click(object sender, RoutedEventArgs e) { int n = Convert.ToInt16(rpt.Content); n++; rpt.Content = n.ToString(); }
ǒǺǯDZǯ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ 6LOYHUOLJKW ǿǯȀȇǷǿǴǼǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ
165
ǙǽDzdzǯ ǾǽǺȋǶǽDZǯȁǴǺȋ ȈǴǺǹǯǴȁ ǹǼǽǾǹȂ ȁǴǹȂȈǴǴ ǶǼǯȆǴǼǷǴ ȀDZǽǸȀȁDZǯ Content ǷǶDZǺǴǹǯǴȁȀȎ ǾǿǴǽǰǿǯǶǽDZȊDZǯ ǴȁȀȎ DZ ȅǴǺǽǴ ȆǷȀǺǽ ȂDZǴǺǷȆǷDZǯǴȁȀȎ Ǽǯ ǴdzǷǼǷȅȂ Ƿ ǽǾȎȁȋ ǾǿǷȀDZǯǷDZǯǴȁȀȎ ǹǯǹ ǶǼǯȆǴǼǷǴ ȀDZǽǸȀȁDZǯ Content Ǒ ǿǴǶȂǺȋȁǯȁǴ ǼǯdzǾǷȀȋ Ǽǯ ǹǼǽǾǹǴ ȂDZǴǺǷȆǷDZǯǴȁȀȎ Ǿǽǹǯ ǾǽǺȋǶǽDZǯȁǴǺȋ ȂdzǴǿǵǷDZǯǴȁ ǹǼǽǾǹȂ ǻȊȇǷ ǼǯǵǯȁǽǸ Ǽǯdz RepeatButton Ǭȁǽ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ǹǯǹ ȀǾǽȀǽǰ ǹǽǼȁǿǽǺȎ ǾǿǷ ǽǰǿǯǰǽȁǹǴ ǻǼǽǵǴȀȁDZǯ ǾǽDZȁǽ ǿȎȍȈǷȄȀȎ dzǴǸȀȁDZǷǸ ǜǯǾǿǷǻǴǿ dzǺȎ ǿǯǶǺǷȆǼȊȄ ȁǷǾǽDZ ȀȆǴȁȆǷǹǽDZ ǿǴǯǺǷǶǽDZǯǼǼȊȄ ȁǯǹǷǻ ǽǰǿǯǶǽǻ Ȇȁǽ ǾǽǺȋǶǽDZǯȁǴǺȍ ǾǿǴdzǽȀȁǯDZǺȎǴȁȀȎ ǹǼǽǾǹǯ Ȁǽ ȀȁǿǴǺǹǽǸ Ƿ Ǿǽǹǯ ǽǼ ȂdzǴǿǵǷDZǯǴȁ ǴǴ ǶǼǯȆǴǼǷǴ ȂDZǴǺǷȆǷDZǯǴȁȀȎ Ǒǽ DZȀǴȄ ǽȀȁǯǺȋǼȊȄ ǽȁǼǽȇǴǼǷȎȄ RepeatButton ȎDZǺȎǴȁȀȎ ǽǰȊȆǼǽǸ ǹǼǽǾǹǽǸ ǾǽȌȁǽǻȂ DZȀǴ dzǴȁǯǺǷ ǽ ǴDzǽ ǷȀ ǾǽǺȋǶǽDZǯǼǷǷ ǻǽǵǼǽ ǼǯǸȁǷ DZ ǒǺǯDZǴ DZ ǹǽȁǽǿǽǸ ǿǯȀȀǻǯȁǿǷDZǯǴȁȀȎ ȂǼǷDZǴǿȀǯǺȋǼȊǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Button. ToggleButton ǑȊǹǺȍȆǯȁǴǺȋ ² Ȍȁǽ ǹǼǽǾǹǯ ǹǽȁǽǿǯȎ ǰȂdzȂȆǷ ǼǯǵǯȁǽǸ ǽȀȁǯǴȁȀȎ DZ Ȍȁǽǻ ȀǽȀȁǽȎǼǷǷ dzǽ ȁǴȄ Ǿǽǿ Ǿǽǹǯ Ǿǽ ǼǴǸ ǼǴ ȈǴǺǹǼȂȁ ȀǼǽDZǯ Ǭȁǽȁ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ȀǽȆǴȁǯǴȁ DZ ȀǴǰǴ ǾǴǿǴǹǺȍȆǯȁǴǺȋ Ƿ ǽǰȊȆ ǼȂȍ ǹǼǽǾǹȂ ǠDZǽǸȀȁDZǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ToggleButton ǾǽdzǽǰǼȊ ǷȀǾǽǺȋǶȂǴǻȊǻ DZ ǾǴǿǴǹǺȍȆǯȁǴǺȎȄ Ƿ ǽǰȊȆǼȊȄ ǹǼǽǾǹǯȄ ToggleButton ȁǽǵǴ ǷǻǴǴȁ ȀDZǽǸȀȁDZǽ IsChecked Ȁ ǾǽǻǽȈȋȍ ǹǽȁǽǿǽDzǽ ǻǽǵǼǽ ǷǶDZǺǴǹǯȁȋ ǴDzǽ ȁǴǹȂȈǴǴ ǶǼǯȆǴǼǷǴ Ƿ ȀDZǽǸȀȁDZǽ IsThreeState ǹǽȁǽǿǽǴ ǾǽȀǿǴdzȀȁDZǽǻ ǶǼǯȆǴǼǷȎ Null ǾǽǶDZǽǺȎǴȁ ǶǯdzǯDZǯȁȋ ȁǿǴȁȋǴ ȀǽȀȁǽȎǼǷǴ ȀǿǴdzǼǴǴ ǻǴǵdzȂ ǽǰȊȆǼȊǻ Ƿ ǼǯǵǯȁȊǻ Ǚǯǹ Ƿ ȀȁǯǼdzǯǿȁǼȊǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Button ǒǺǯDZǯ 7), RepeatButton Ƿ ToggleButton ȎDZǺȎȍȁȀȎ ȌǺǴǻǴǼ ȁǯǻǷ ȂǾǿǯDZǺǴǼǷȎ Ȁ ȀǽdzǴǿǵǷǻȊǻ ȁǴ ǻǽDzȂȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ǽȁǽǰǿǯǵǴǼǷȎ ȀǺǽǵǼǽDzǽ ȀǽdzǴǿǵǷǻǽDzǽ Ƿ ȀǽǶdzǯǼǷȎ ǹǼǽǾǽǹ Ȁ ǷǶǽǰǿǯǵǴǼǷȎǻǷ DZǷdzǴǽǹǼǽǾǽǹ Ƿ ǻǼǽDzǽDzǽ dzǿȂDzǽDzǽ dzǺȎ DZǯȇǷȄ ǾǿǷǺǽǵǴǼǷǸ Silverlight.
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ScrollViewer ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ScrollViewer ȎDZǺȎǴȁȀȎ ǹǽǼȁǴǸǼǴǿǽǻ dzǺȎ ǽȁǽǰǿǯǵǴǼǷȎ ǷǼȃǽǿǻǯȅǷǷ ǝǼ ǾǿǴdzǽȀȁǯDZ ǺȎǴȁ DzǽǿǷǶǽǼȁǯǺȋǼȂȍ Ƿ DZǴǿȁǷǹǯǺȋǼȂȍ ǾǽǺǽȀȊ ǾǿǽǹǿȂȁǹǷ Ȇȁǽ ǽǰǴȀǾǴȆǷDZǯǴȁ DZǽǶǻǽǵǼǽȀȁȋ ǾǽǺȋǶǽDZǯȁǴ Ǻȍ ǾǴǿǴǻǴȈǯȁȋ ǽǰǺǯȀȁȋ ǽȁǽǰǿǯǵǴǼǷȎ Ƿ ǾǿǽȀǻǯȁǿǷDZǯȁȋ DZȀǴ ȀǽdzǴǿǵǷǻǽǴ ǴȀǺǷ ǴDzǽ ǿǯǶǻǴǿȊ ǾǿǴDZȊȇǯȍȁ ǿǯǶǻǴǿȊ ǹǽǼȁǴǸǼǴǿǯ ǜǯǺǷȆǷǴ ǾǽǺǽȀ ǾǿǽǹǿȂȁǹǷ ǽǾǿǴdzǴǺȎǴȁȀȎ ȀDZǽǸȀȁDZǯǻǷ HorizontalScrollBarVisibility ǑǷdzǷǻǽȀȁȋ DzǽǿǷǶǽǼȁǯǺȋǼǽǸ ǾǽǺǽȀȊ ǾǿǽǹǿȂȁǹǷ Ƿ VerticalScrollBarVisibility ǑǷdzǷǻǽȀȁȋ DZǴǿȁǷǹǯǺȋǼǽǸ Ǿǽ ǺǽȀȊ ǾǿǽǹǿȂȁǹǷ Ǟǽ ȂǻǽǺȆǯǼǷȍ ǴȀǺǷ ȀǽdzǴǿǵǷǻǽǴ ǾǿǴDZȊȇǯǴȁ ǿǯǶǻǴǿȊ ScrollViewer ǽȁǽǰǿǯǵǯǴȁȀȎ DZǴǿȁǷǹǯǺȋǼǯȎ ǾǽǺǽȀǯ ǾǿǽǹǿȂȁǹǷ DzǽǿǷǶǽǼȁǯǺȋǼǯȎ ǾǽǺǽȀǯ ǾǿǽǹǿȂȁǹǷ ǼǴ ǽȁǽǰǿǯǵǯǴȁȀȎ ǼǴǶǯDZǷȀǷǻǽ ǽȁ ȀǽdzǴǿǵǷǻǽDzǽ ǟǯȀȀǻǽȁǿǷǻ ȀǺǴdzȂȍȈǷǸ ǾǿǷǻǴǿ XAML:
Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ ScrollViewer ȎDZǺȎǴȁȀȎ ǴdzǷǼȀȁDZǴǼǼȊǻ dzǽȆǴǿǼǷǻ ȌǺǴǻǴǼȁǽǻ ȂǾǿǯDZǺǴǼǷȎ Ǽǯ ǿǯǰǽȆǴǸ Ǿǽ DZǴǿȄǼǽȀȁǷ ǿǯǶǻǴǿǽǻ 400 î 300 ǾǽȌȁǽǻȂ ǴDzǽ ǿǯǶǻǴǿȊ ȁǯǹǵǴ ǰȂdzȂȁ 400 î 300 Ǒ ǼǴǻ ǿǯȀǾǽǺǯDzǯǴȁȀȎ ǷǶǽ ǰǿǯǵǴǼǷǴ ǿǯǶǻǴǿǽǻ 1280 î 1024. ǟǴǶȂǺȋȁǯȁ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 8-8.
166
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
ǟǗǠ 8 8 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ScrollViewer.
Ǚǯǹ DZǷdzǼǽ Ǽǯ ǿǷȀ 8- ǽȁǽǰǿǯǵǯǴȁȀȎ ȁǽǺȋǹǽ ǶǯǹǿǯȇǴǼǼǯȎ ȀǴǿȊǻ ǽǰǺǯȀȁȋ ǾǽȁǽǻȂ Ȇȁǽ DZǷdzǼǯ ȁǽǺȋǹǽ ǺǴ DZǯȎ ȆǯȀȁȋ ǷǶǽǰǿǯǵǴǼǷȎ ǒǽǿǷǶǽǼȁǯǺȋǼǯȎ ǾǽǺǽȀǯ ǾǿǽǹǿȂȁǹǷ ǽȁȀȂȁȀȁDZȂǴȁ ȁǯǹ Ȇȁǽ ǻȊ ǼǴ ǻǽǵǴǻ ǾǴǿǴǻǴȀ ȁǷȁȋȀȎ DZǾǿǯDZǽ ǹ ȅDZǴȁǼǽǸ ȆǯȀȁǷ ǿǷȀȂǼǹǯ ǜǽ ǴȀǺǷ DZ ǽǾǷȀǯǼǷǴ ScrollViewer DZ XAML dzǽǰǯDZǷȁȋ HorizontalScrollBarVisibility ´Trueµ, ǾǽǺȋǶǽDZǯȁǴǺȋ Ȁǻǽ ǵǴȁ ȂDZǷdzǴȁȋ DZȀǴ ǽȀȁǯǺȋǼǽǴ ǷǶǽǰǿǯǵǴǼǷǴ. Ǒǽȁ Ȍȁǽȁ XAML-ǹǽdz:
ǟǴǶȂǺȋȁǯȁȊ ǾǿǴdzȀȁǯDZǺǴǼȊ Ǽǯ ǿǷȀ 8-9.
ǟǗǠ 8 9 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ScrollViewer Ȁ DzǽǿǷǶǽǼȁǯǺȋǼǽǸ ǾǽǺǽȀǽǸ ǾǿǽǹǿȂȁǹǷ.
ǞǽdzȀǹǯǶǹǯ ǛǽǵǼǽ ȁǯǹǵǴ ǾǴǿǴǽǾǿǴdzǴǺǷȁȋ DZǷdzǷǻǽȀȁȋ DZǴǿȁǷǹǯǺȋǼǽǸ ǾǽǺǽȀȊ ǾǿǽǹǿȂȁǹǷ. Ǟǽ ȂǻǽǺȆǯǼǷȍ ǽǼǯ DZǷdzǷǻǯȎ, Ǽǽ ǴǴ ǻǽǵǼǽ ǽȁǹǺȍȆǷȁȋ (ȁ.Ǵ. ǽǼǯ ǼǴ ǰȂdzǴȁ ǽȁǽǰǿǯǵǯȁȋȀȎ) ǶǯdzǯDZ ȀDZǽǸȀȁDZȂ VerticalScrollBarVisibility ǶǼǯȆǴǼǷǴ Hidden.
ǒǺǯDZǯ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ 6LOYHUOLJKW ǿǯȀȇǷǿǴǼǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ
167
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Slider ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Slider ǽǰǴȀǾǴȆǷDZǯǴȁ ǾǽǺȋǶǽDZǯȁǴǺȍ DZǽǶǻǽǵǼǽȀȁȋ DZȊǰǷǿǯȁȋ ǶǼǯȆǴǼǷǴ ǷǶ ǶǯdzǯǼǼǽDzǽ dzǷǯǾǯǶǽǼǯ ǾǴǿǴdzDZǷDzǯȎ DZǴǿȁǷǹǯǺȋǼȊǸ ȌǺǴǻǴǼȁ ǼǯǶȊDZǯǴǻȊǸ ǰǴDzȂǼǹǽǻ (thumb DZdzǽǺȋ ǺǷǼǷǷ ǼǯȆǷǼǯȎ ǽȁ ǼǯǷǻǴǼȋȇǴDzǽ ǶǼǯȆǴǼǷȎ DZ dzǷǯǾǯǶǽǼǴ ǶǯǹǯǼȆǷDZǯȎ ǼǯǷǰǽǺȋȇǷǻ ǶǼǯȆǴǼǷǴǻ ǓǽȀȁȂǾ ǹ ǶǼǯȆǴǼǷȍ ǽǰǴȀǾǴ ȆǷDZǯǴȁȀȎ ȆǴǿǴǶ ȀDZǽǸȀȁDZǽ Value ǖǼǯȆǴǼǷǴ DZǽǶDZǿǯȈǯȍȈǴǴ DZǴǺǷȆǷǼȂ ȁǷǾǯ Double. ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Slider ǻǽǵǼǽ ǼǯȀȁǿǽǷȁȋ ǻǼǽǵǴȀȁDZǽǻ ȀǾǽȀǽǰǽDZ ǜǯǾǿǷǻǴǿ ȀDZǽǸȀȁDZǯ Minimum ǛǷǼǷǻȂǻ Ƿ Maximum ǛǯǹȀǷǻȂǻ ǷȀǾǽǺȋǶȂȍȁȀȎ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ ǻǷǼǷǻǯǺȋǼǽDzǽ Ƿ ǻǯǹȀǷǻǯǺȋǼǽDzǽ ǶǼǯȆǴǼǷǸ dzǷǯǾǯǶǽǼǯ ǔȀǺǷ ǼǴǽǰȄǽdzǷǻǽ ȆȁǽǰȊ ǾǽǺȋǶǽDZǯȁǴǺȋ DZȊǰǷǿǯǺ ǶǼǯȆǴǼǷǴ ǷǶ dzǷǯǾǯǶǽǼǯ ȆǷȀǴǺ ǽȁ dzǽ ǶǯdzǯǸȁǴ ȀDZǽǸȀȁDZȂ Minimum ǶǼǯȆǴǼǷǴ Ƿ ȀDZǽǸȀȁDZȂ Maximum ǶǼǯȆǴǼǷǴ ǔȈǴ ǽdzǼǽ ȀDZǽǸȀȁDZǽ ȀDZȎǶǯǼǼǽǴ Ȁ ȌǺǴǻǴǼȁǽǻ ȂǾǿǯDZǺǴǼǷȎ Slider, ² Orientation ǝǿǷǴǼȁǯȅǷȎ ǹǽȁǽǿǽǴ ǷȀ ǾǽǺȋǶȂǴȁȀȎ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ ǼǯǾǿǯDZǺǴǼǷȎ ǾǴǿǴǻǴȈǴǼǷȎ ǰǴDzȂǼǹǯ ǔǻȂ ǻǽǵǴȁ ǰȊȁȋ ǶǯdzǯǼȊ ǶǼǯȆǴǼǷȎ Horizontal ǒǽǿǷǶǽǼȁǯǺȋǼǽ ǷǺǷ Vertical ǑǴǿȁǷǹǯǺȋǼǽ ǙǽDzdzǯ ȀDZǽǸȀȁDZȂ Orientation ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ Horizontal Ǿǽ ȂǻǽǺȆǯǼǷȍ ǾǴǿǴǻǴȈǴǼǷǴ Slider ǽȁ ǼǯǷǻǴǼȋ ȇǴDzǽ ǹ ǼǯǷǰǽǺȋȇǴǻȂ ǶǼǯȆǴǼǷȍ ǿǴǯǺǷǶȂǴȁȀȎ DZ ǼǯǾǿǯDZǺǴǼǷǷ ȀǺǴDZǯ ǼǯǾǿǯDZǽ Ƿ ȀǼǷǶȂ DZDZǴǿȄ ǴȀǺǷ Orientation ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ Vertical ǬȁǷ ȀȁǯǼdzǯǿȁǼȊǴ ǼǯȀȁǿǽǸǹǷ ǻǽǵǼǽ ǾǴǿǴǽǾǿǴdzǴǺǷȁȋ ȀDZǽǸȀȁDZǽǻ IsDirectionReversed ǝǰǿǯȁǼǽǴ ǼǯǾǿǯDZǺǴǼǷǴ ǶǯdzǯǼǷǴ ǶǼǯȆǴǼǷȎ True ǹǽȁǽǿǽǻȂ ǽǰǴȀǾǴȆǷȁ ǷǶǻǴǼǴǼǷǴ ǼǯǾǿǯDZǺǴ ǼǷȎ DZǽǶǿǯȀȁǯǼǷȎ ǶǼǯȆǴǼǷǸ DZ Slider. ǙǿǽǻǴ ȁǽDzǽ ǻǽǵǼǽ ǾǴǿǴǻǴȈǯȁȋ ǰǴDzȂǼǽǹ ȈǴǺǹǯȎ Ǽǯ ǾǽǺǽȀǴ ǾǴǿǴǻǴȈǴǼǷȎ ȁǷǾǽDZǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴ ǼǷȎ Slider ǙǯǵdzȊǸ ȈǴǺȆǽǹ ǽǰǴȀǾǴȆǷDZǯǴȁ ǷǶǻǴǼǴǼǷǴ ǶǼǯȆǴǼǷȎ Ǽǯ ǽǾǿǴdzǴǺǴǼǼȂȍ DZǴǺǷȆǷǼȂ Ǭȁǽ ǾǽDZǴ dzǴǼǷǴ ǽǾǿǴdzǴǺȎǴȁȀȎ ȀDZǽǸȀȁDZǽǻ LargeChange ǐȊȀȁǿǽǴ ǾǴǿǴǻǴȈǴǼǷǴ ǶǯdzǯǼǷǴ ȆǷȀǺǽDZǽDzǽ ǶǼǯȆǴǼǷȎ, ǹǽ ȁǽǿǽǻȂ ǽǰǴȀǾǴȆǷDZǯǴȁ ȂDZǴǺǷȆǴǼǷǴ ǷǺǷ ȂǻǴǼȋȇǴǼǷǴ ǶǼǯȆǴǼǷȎ ǰǴDzȂǼǹǯ Ǽǯ ǶǯdzǯǼǼȂȍ DZǴǺǷȆǷǼȂ ǓǯǺǴǴ ǾǿǷDZǴdzǴǼ ǾǿǷǻǴǿ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Slider DZ XAML:
ǠǽǶdzǯDZǯǴǻȊǸ ǶdzǴȀȋ Slider ǰȂdzǴȁ DZǴǿȁǷǹǯǺȋǼȊǻ Ȁ ǼǯǷǻǴǼȋȇǷǻ ǶǼǯȆǴǼǷǴǻ ȀDZǴǿȄȂ ǼǯǷǰǽǺȋȇǷǻ ² ȀǼǷǶȂ ǝǼ ǽǰǴȀǾǴȆǷȁ DZǽǶǻǽǵǼǽȀȁȋ ǾǴǿǴȁȎDzǷDZǯȎ ǰǴDzȂǼǽǹ DZȊǰǷǿǯȁȋ ǶǼǯȆǴǼǷȎ DZ dzǷǯǾǯǶǽǼǴ ǽȁ dzǽ ǡǯǹǵǴ ǾǽǺȋǶǽDZǯȁǴǺȋ ȀǻǽǵǴȁ ȂDZǴǺǷȆǷDZǯȁȋ ǶǼǯȆǴǼǷȎ Ǽǯ ȈǴǺǹǯȎ ǾǽǺǽȀȂ ǾǴǿǴǻǴȈǴǼǷȎ.
ǖǯǹǺȍȆǴǼǷǴ Ǒ dzǯǼǼǽǸ DzǺǯDZǴ ǻȊ ǾǿǽdzǽǺǵǷǺǷ ǷǶȂȆǴǼǷǴ Ǽǯǰǽǿǯ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǛǼǽDzǽ DZǼǷǻǯǼǷȎ ǰȊǺǽ ȂdzǴǺǴǼǽ DataGrid ǴDzǽ ȀDZǽǸȀȁDZǯǻ ǻǴȁǽdzǯǻ Ƿ ȀǽǰȊȁǷȎǻ ǾǽȀǹǽǺȋǹȂ Ȍȁǽ DZǯǵǼȊǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴ ǼǷȎ ǽǰǴȀǾǴȆǷDZǯȍȈǷǸ ǾǿǷǺǽǵǴǼǷȎǻ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁȋ ǯǼǯǺǽDzǷȆǼȂȍ ȌǺǴǹȁǿǽǼǼȊǻ ȁǯǰǺǷȅǯǻ ǞǿǷ ǽǰ ȀȂǵdzǴǼǷǷ DataGrid ǾǿǴdzȀȁǯDZǺǴǼ ǹǽdz ǾǿǴdzǺǯDzǯǴǻȊǸ Silverlight dzǺȎ ȂǾǿǽȈǴǼǷȎ ǾǿǷDZȎǶǹǷ dzǯǼǼȊȄ ǯ ȁǯǹǵǴ ǿǯȀȀǻǽȁǿǴǼȊ ȇǯǰǺǽǼȊ dzǯǼǼȊȄ Ƿ ǷȄ ǷȀǾǽǺȋǶǽDZǯǼǷǴ dzǺȎ ǹǽǻǾǽǼǽDZǹǷ ȁǯǰǺǷȅ ǙǿǽǻǴ ȁǽDzǽ DZȊ ǾǽǶǼǯǹǽ ǻǷǺǷȀȋ Ȁ dzǿȂDzǷǻǷ ǿǯȀȇǷǿǴǼǼȊǻǷ ǷǼȀȁǿȂǻǴǼȁǯǻǷ dzǽȀȁȂǾǼȊǻǷ DZ Silverlight, DZǹǺȍȆǯȎ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZ ǺǴǼǷȎ Calendar, DatePicker, ScrollViewer Ƿ Slider. ǜǯ Ȍȁǽǻ ǻȊ ǶǯDZǴǿȇǯǴǻ ǽǰǶǽǿ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ Silverlight Ƿ DZ ȀǺǴdzȂȍȈǴǸ DzǺǯDZǴ ǶǯǸǻǴǻȀȎ ȀǽǶdzǯ ǼǷǴǻ ȀǽǰȀȁDZǴǼǼȊȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ
ǒǺǯDZǯ 9
ǠǽǶdzǯǼǷǴ ȀǽǰȀȁDZǴǼǼǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight Ǒ ǒǺǯDZǴ ©ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ ǹǽǻǾǽǼǽDZǹǷª ǰȊǺ ǾǿǴdzȀȁǯDZǺǴǼ ǹǿǯȁǹǷǸ ǽǰǶǽǿ ǷȀǾǽǺȋǶǽDZǯǼǷȎ Microsoft Visual Studio dzǺȎ ȀǽǶdzǯǼǷȎ ǾǿǷǺǽǵǴǼǷǸ Silverlight Ǽǯ C#. Ǒ ǒǺǯDZǴ ©ǬǺǴ ǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǿǯȀȇǷǿǴǼǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎª ǽǾǷȀǯǼȊ ǼǴǹǽȁǽǿȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ dzǽȀȁȂǾǼȊǴ DZ Silverlight. ǑǴǿǽȎȁǼǽ Ǽǯ dzǯǼǼȊǸ ǻǽǻǴǼȁ DZǯȀ ǷǼȁǴǿǴȀȂǴȁ ǹǯǹǷǴ ǴȈǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ dzǽȀȁȂǾǼȊ DZ ǰǯǶǽDZǽǻ ǼǯǰǽǿǴ ǜǽ ǴȀȁȋ dzDZǯ DZǯǿǷǯǼȁǯ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ǻǽǵǼǽ ǺǷǰǽ ǾǽǹȂ Ǿǯȁȋ ǺǷǰǽ ȀǽǶdzǯDZǯȁȋ ȀǯǻǽȀȁǽȎȁǴǺȋǼǽ ǔȀȁȋ ǻǼǽǵǴȀȁDZǽ ǾǿǽǷǶDZǽdzǷȁǴǺǴǸ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǾǽdzǿǽǰǼǴǴ ǽ ǼǷȄ ǻǽǵǼǽ ȂǶǼǯȁȋ Ǽǯ ȀǯǸȁǴ http://www.silverlight.net ǝdzǼǯǹǽ ǷȀǾǽǺȋǶȂȎ Silverlight ǻǽǵǼǽ ȀǽǶdzǯDZǯȁȋ Ȁǽǰ ȀȁDZǴǼǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ dzǺȎ Silverlight Ǒ dzǯǼǼǽǸ DzǺǯDZǴ ǾǿǴdzǺǯDzǯǴȁȀȎ ǾǿǯǹȁǷȆǴȀǹǷǸ ǾǽdzȄǽdz ǹ Ǿǽ ȀȁǿǽǴǼǷȍ ȁǯǹǷȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ
ǠǽǶdzǯǼǷǴ ǾǿǽǴǹȁǯ Ǘȁǯǹ ǼǯȆǼǴǻ ǞǴǿDZȊǸ ȇǯDz ² ȀǽǶdzǯǼǷǴ ǼǽDZǽDzǽ ǾǿǽǴǹȁǯ Silverlight DZ Visual Studio. ǓǴǺǯǴǻ Ȍȁǽ DZȊǰǷǿǯȎ ǽǾȅǷȍ New Project DZ ǻǴǼȍ File ǿǷȀ 9-1).
ǟǗǠ 9 1 ǠǽǶdzǯǼǷǴ ǾǿǽǴǹȁǯ ǼǽDZǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ.
Ǚǯǹ DZǷdzǼǽ Ǽǯ ǿǷȀ 9- Ȍȁǽȁ ǾǿǽǴǹȁ ǰȂdzǴȁ ǼǯǶȊDZǯȁȋȀȎ CircleControl ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǹǿȂDz ǔȀǺǷ DZǴǿ ǼȂȁȋȀȎ ǹ ǒǺǯDZǴ ©ǝȀǼǽDZȊ XAMLª DZȊ ȂDZǷdzǷȁǴ Ȇȁǽ XAML ǼǴ ǾǿǴdzǺǯDzǯǴȁ ȃǷDzȂǿȊ Circle ǙǿȂDz Ǽǽ DZ ǼǴǻ ǴȀȁȋ Ellipse Ȁǽ ȀDZǽǸȀȁDZǯǻǷ ǽǾǿǴdzǴǺȎȍȈǷǻǷ ȇǷǿǷǼȂ Ƿ DZȊȀǽȁȂ ǛȊ ȂǼǯȀǺǴdzȂǴǻ ȃǷDzȂǿȂ ǽȁ Ellipse Ǽǽ DZǻǴ Ȁȁǽ ȇǷǿǷǼȊ Ƿ DZȊȀǽȁȊ ǾǿǷǻǴǼǷǻ ȀDZǽǸȀȁDZǽ Radius ǟǯdzǷȂȀ Ȇȁǽ ǾǽǶDZǽǺǷȁ Silverlight ǽȁǿǷȀǽDZȊDZǯȁȋ ǹǿȂDz ǨǴǺǹǼǷȁǴ OK Ƿ ǽȁǹǿǽǴȁȀȎ ǛǯȀȁǴǿ ǾǿǷǺǽǵǴǼǷǸ Silverlight ǿǷȀ 9- ǞǿǷǻǷȁǴ ǼǯȀȁǿǽǸǹǷ Ǿǽ ȂǻǽǺȆǯǼǷȍ Ƿ Visual Studio ȀǽǶdzǯȀȁ DZȀǴ ǼǴǽǰȄǽdzǷǻǽǴ dzǺȎ ǾǿǷǺǽǵǴǼǷȎ Silverlight ǞǽdzǿǽǰǼǴǴ ǽ ǾǿǷǺǽǵǴǼǷȎȄ Silverlight Ƿ ǹǯǵdzǽǻ ǷǶ ȀǽȀȁǯDZǺȎȍȈǷȄ ǷȄ ȃǯǸǺǽDZ ǿǯȀȀǹǯǶȊDZǯǴȁȀȎ DZ ǒǺǯDZǴ ©ǗȀǾǽǺȋǶǽDZǯǼǷǴ Visual Studio Ȁ Silverlight 2ª ǡǴǾǴǿȋ DZȀǴ DzǽȁǽDZǽ dzǺȎ ȀǺǴdzȂȍȈǴDzǽ ȇǯDzǯ - dzǽǰǯDZǺǴǼǷȎ ȀǯǻǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ
ǒǺǯDZǯ ǠǽǶdzǯǼǷǴ ȀǽǰȀȁDZǴǼǼǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ 6LOYHUOLJKW
169
ǟǗǠ 9 2 ǛǯȀȁǴǿ ǾǿǷǺǽǵǴǼǷǸ Silverlight Application Wizard.
ǓǽǰǯDZǺǴǼǷǴ ȇǯǰǺǽǼǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ȀǽǶdzǯǴȁȀȎ ȁǽȆǼǽ ȁǯǹ ǵǴ ǹǯǹ ǺȍǰǽǸ dzǿȂDzǽǸ ǾǿǽǴǹȁ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ XAML Ƿ ǴȀǺǷ ǼǴǽǰȄǽdzǷǻǽ ǼǴǹǽȁǽǿǽDzǽ DZȊdzǴǺǴǼǼǽDzǽ ǹǽdzǯ ǞǿǷǻǴǼȎǴǻȊǸ ȇǯǰǺǽǼ ǽǰǴȀǾǴȆǷDZǯǴȁ ȀǽǶdzǯǼǷǴ ȁǴȀȁǽDZǽDzǽ ǾǿǽǴǹȁǯ ǹǽȁǽǿȊǸ DZǹǺȍȆǯǴȁ ȃǯǸǺ App.xaml dzǺȎ ǹǽdzǯ ǾǿǷǺǽǵǴǼǷȎ Ƿ ȃǯǸǺ Page.xaml ǽȀǼǽDZǼǽDzǽ UI. ǠǽǶdzǯDZǯǴǻȊǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰȂdzǴȁ dzǽǰǯDZǺǴǼ DZ Page.xaml ǠǽDZȀǴǻ Ȁǹǽǿǽ DZȊ ȂDZǷdzǷȁǴ ǹǯǹ Ȍȁǽ dzǴ ǺǯǴȁȀȎ ǠǼǯȆǯǺǯ ȀǽǶdzǯdzǷǻ Ȁǯǻ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǨǴǺǹǼǴǻ ǾǿǯDZǽǸ ǹǼǽǾǹǽǸ ǻȊȇǷ Ǽǯ ǾǿǽǴǹȁǴ DZ dzǯǼǼǽǻ ȀǺȂ ȆǯǴ CircleControl DZȊǰǴǿǴǻ Add Ƿ ǶǯȁǴǻ New Item ǜǽDZȊǸ ȌǺǴǻǴǼȁ . ǞǽȎDZǷȁȀȎ dzǷǯǺǽDzǽDZǽǴ ǽǹǼǽ Add New Item ǓǽǰǯDZǺǴǼǷǴ ǼǽDZǽDzǽ ȌǺǴǻǴǼȁǯ ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 9-3.
ǟǗǠ 9 3 ǓǽǰǯDZǺǴǼǷǴ ǼǽDZǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight.
Ǒ Ȍȁǽǻ dzǷǯǺǽDzǽDZǽǻ ǽǹǼǴ ǷǶ ǾǿǴdzǺǯDzǯǴǻȊȄ ǹǯȁǴDzǽǿǷǸ DZȊǰǷǿǯǴǻ Silverlight DZȊǰǷǿǯǴǻ ȇǯǰǺǽǼ Silverlight User Control Ƿ ǾǿǷȀDZǯǷDZǯǴǻ ǴǻȂ ǷǻȎ ǞǽȀǺǴ ȌȁǽDzǽ ȈǴǺǹǯǴǻ Add. ǐȂdzǴȁ ȀǽǶdzǯǼ ǰǯǶǽDZȊǸ UserControl Ǒǽȁ ǹǯǹ DZȊDzǺȎdzǷȁ XAML dzǺȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Circle DZ ǾǿǽǴǹȁǴ CircleControl:
170
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ǽǯ ǷȀǾǽǺȋǶǽDZǯǼǷǴ ǾǿǽȀȁǿǯǼȀȁDZ ǷǻǴǼ ǓǺȎ x:Class ǹǽȁǽǿȊǸ ǽǾǿǴdzǴǺȎǴȁ ǽǰȉǴǹȁ dzǺȎ Silverlight, ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ CircleControl.Circle. ǞǽȀǹǽǺȋǹȂ ǹǿȂDz ǰȂdzǴȁ ǷǻǴȁȋ ȁǽǺȋǹǽ ǽdzǷǼ DZǷǶȂǯǺȋǼȊǸ ȌǺǴǻǴǼȁ ȂǼǯȀǺǴdzǽDZǯǼǼȊǸ ǽȁ ǰǯǶǽDZǽDzǽ ȁǷǾǯ Ellipse DZ ȀǴȁǹȂ LayoutRoot ǼǴǽǰȄǽdzǷǻǽ dzǽǰǯDZǷȁȋ ȀǺǴdzȂȍȈǴǴ
ǜǯǾǷȀǯǼǷǴ ǹǽdzǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Ǚǽdz ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǽȆǴǼȋ ǾǿǽȀȁ Circle ² Ȍȁǽ UserControl ȃǽǿǻǷǿȂȍȈǷǸ DZǷǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴ ǼǷǴ ǶǯdzǯǼǼǽDzǽ XAML ǹǽȁǽǿȊǸ ȀǽdzǴǿǵǷȁ Ellipse Ǚ ȌȁǽǻȂ ȁǿǴǰȂǴȁȀȎ dzǽǰǯDZǷȁȋ ȀDZǽǸȀȁDZǽ Radius ǽǾǿǴdzǴ ǺȎȍȈǴǴ ǿǯdzǷȂȀ Circle Ƿ ȀDZǽǸȀȁDZǽ FillColor ǥDZǴȁ ǶǯǺǷDZǹǷ ǽǰǴȀǾǴȆǷDZǯȍȈǴǴ DZǽǶǻǽǵǼǽȀȁȋ ǶǯǹǿǯȇǷDZǯȁȋ ǹǿȂDz UserControl ǼǴ ǾǿǴdzǽȀȁǯDZǺȎǴȁ ȀDZǽǸȀȁDZǽ Fill ǾǽȌȁǽǻȂ ǴDzǽ ǾǿǷdzǴȁȀȎ ǿǴǯǺǷǶǽDZǯȁȋ ȀǯǻǽȀȁǽȎȁǴǺȋǼǽ Ǒǽȁ Ȍȁǽȁ ǹǽdz ǝǼ dzǽǺǵǴǼ ǼǯȄǽdzǷȁȋȀȎ DZ ȃǯǸǺǴ DZȊdzǴǺǴǼǼǽDzǽ ǹǽdzǯ Ȁ ǿǯȀȇǷǿǴǼǷǴǻ .cs ǾǽȌȁǽǻȂ ǴȀǺǷ ȌǺǴ ǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǼǯǶDZǯǼ Circle.xaml Ȍȁǽȁ ȃǯǸǺ ǰȂdzǴȁ ǼǯǶȊDZǯȁȋȀȎ Circle.xaml.cs: using using using using using using using using using using using
System; System.Collections.Generic; System.Linq; System.Net; System.Windows; System.Windows.Controls; System.Windows.Documents; System.Windows.Input; System.Windows.Media; System.Windows.Media.Animation; System.Windows.Shapes;
namespace CircleControl { public partial class Circle : UserControl { public Circle() { // ǵȍȖȉȝȖȌȐȔȖ Ȍȓȧ ȐȕȐȞȐȈȓȐȏȈȞȐȐ ȗȍȘȍȔȍȕȕȣȝ InitializeComponent();
} public double Radius { get { return BaseEllipse.Width / 2; } set { BaseEllipse.Width = value * 2; BaseEllipse.Height = value * 2; } } public SolidColorBrush Fill { get { return (SolidColorBrush)BaseEllipse.Fill; } set { BaseEllipse.Fill = (SolidColorBrush)value; } } } }
ǒǺǯDZǯ ǠǽǶdzǯǼǷǴ ȀǽǰȀȁDZǴǼǼǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ 6LOYHUOLJKW
171
Ǚǯǹ DZǷdzǷȁǴ DZȀǴ ǽȆǴǼȋ ǾǿǽȀȁǽ ǠDZǽǸȀȁDZǽ Radius ȁǷǾǯ double DZǽǶDZǿǯȈǯǴȁ DZ ǻǴȁǽdzǴ get ȇǷǿǷǼȂ BaseEllipse ǐǯǶǽDZȊǸ ȌǺǺǷǾȀ dzǴǺǴǼǼȂȍ Ǽǯ ǓǺȎ ȁǷǾǯ Ellipse DZȀǴDzdzǯ ǶǯdzǯȍȁȀȎ ȇǷǿǷǼǯ Ƿ DZȊȀǽȁǯ Ƿ ǴȀȁǴȀȁDZǴǼǼǽ ǿǯ dzǷȂȀ ǹǿȂDzǯ ȎDZǺȎǴȁȀȎ ǾǽǺǽDZǷǼǽǸ ȇǷǿǷǼȊ ǷǺǷ DZȊȀǽȁȊ ȃǷDzȂǿȊ ǏǼǯǺǽDzǷȆǼǽ ǶǯdzǯDZǯȎ ǶǼǯȆǴǼǷǴ Radius DZȊ ȄǽȁǷȁǴ ȆȁǽǰȊ ȇǷǿǷǼǯ Ƿ DZȊȀǽȁǯ ǰǯǶǽDZǽDzǽ Ellipse ǰȊǺǷ DZ dzDZǯ ǿǯǶǯ ǰǽǺȋȇǴ ǿǯdzǷȂȀǯ Ǭȁǽ DZȊǾǽǺǼȎǴȁȀȎ DZ ǻǴȁǽdzǴ set ȀDZǽǸȀȁDZǯ ǦȁǽǰȊ ǽǾǿǴdzǴǺǷȁȋ ȀDZǽǸȀȁDZǽ Fill ǼǴǽǰȄǽdzǷǻǽ ǾǿǷDZǴȀȁǷ DZȄǽdzȎȈǴǴ ǶǼǯȆǴǼǷǴ ǹ ȁǷǾȂ SolidColorBrush Ƿ Ƕǯ dzǯȁȋ ǴDzǽ DZ ǹǯȆǴȀȁDZǴ ǶǼǯȆǴǼǷȎ Fill ǦȁǽǰȊ DZǽǶDZǿǯȁǷȁȋ ǶǼǯȆǴǼǷǴ Fill ǰǯǶǽDZǽDzǽ ȌǺǺǷǾȀǯ ǾǿǷDZǽdzǷǻ ǴDzǽ ǹ SolidColorBrush ǑȀǴ ǽȆǴǼȋ ǾǿǽȀȁǽ ǡǴǾǴǿȋ ǹǽDzdzǯ ǻȊ ǾǽǺȂȆǷǺǷ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǻǽǵǼǽ ǿǴǯǺǷǶǽDZǯȁȋ ǴDzǽ DZ ǾǿǷǺǽǵǴǼǷǷ ǔȀǺǷ DZȀǾǽǻ ǼǷȁȋ ǒǺǯDZȂ ȀȁǯǼdzǯǿȁǼȊǸ ȇǯǰǺǽǼ DZ ǹǯȆǴȀȁDZǴ UI Ǿǽ ȂǻǽǺȆǯǼǷȍ dzǺȎ ǾǿǷǺǽǵǴǼǷȎ ǶǯdzǯǴȁ Page.xaml Ǘȁǯǹ dzǽǰǯDZǷǻ Ǽǯȇ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ȁȂdzǯ ǞǿǴǵdzǴ DZȀǴDzǽ ǼǴǽǰȄǽdzǷǻǽ dzǽǰǯDZǷȁȋ ȀȀȊǺǹȂ Ǽǯ ǾǿǽȀȁǿǯǼȀȁDZǽ ǷǻǴǼ ǼǯȇǴDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ ǾǿǽǴǹȁ ǼǯǶȊDZǯǴȁȀȎ CircleControl Ƿ ǴDzǽ ǾǿǽȀȁǿǯǼȀȁDZǽ ǷǻǴǼ ǷǻǴǴȁ ȁǯǹǽǴ ǵǴ ǷǻȎ ǡǽȆǼȊǴ ȀDZǴdzǴǼǷȎ ǽ ǾǿǽȀȁǿǯǼȀȁDZǴ ǷǻǴǼ ǻǽǵǼǽ ǼǯǸȁǷ DZ ȀDZǽǸȀȁDZǯȄ ǾǿǽǴǹȁǯ. ǓǺȎ ȌȁǽDzǽ ȈǴǺǹǼǷȁǴ ǾǿǽǴǹȁ ǾǿǯDZǽǸ ǹǼǽǾǹǽǸ ǻȊȇǷ Ƿ DZȊǰǴǿǷȁǴ Properties, ȆȁǽǰȊ ǽȁǹǿȊȁȋ dzǷǯǺǽDz Project Properties. Ǭȁǽ ǾǽdzǿǽǰǼǽ ǽǰȀȂǵdzǯ ǺǽȀȋ DZ ǒǺǯDZǴ 3. ǑǯȇǴ ǷȀȄǽdzǼǽǴ ǽǰȉȎDZǺǴǼǷǴ UserControl DZ Page.xaml dzǽǺǵǼǽ DZȊDzǺȎdzǴȁȋ ǯǼǯǺǽDzǷȆǼǽ ȀǺǴdzȂȍȈǴǻȂ ȃǿǯDz ǻǴǼȁȂ ǹǽdzǯ. ǞǿǷǻǴȆǯǼǷǴ Ǒ ǼǴǹǽȁǽǿȊȄ DZǴǿȀǷȎȄ Visual Studio Tools dzǺȎ ǾǿǷǻǴǼȎǴȁȀȎ , DZ ǼǴǹǽȁǽǿȊȄ ² . Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ dzǺȎ dzǴǻǽǼȀȁǿǯȅǷǽǼǼȊȄ ȅǴǺǴǸ ǷȀǾǽǺȋǶȂǴȁȀȎ , Ǽǽ ǼǴ ǰȂdzǴȁ ǼǷǹǯǹǷȄ ǾǿǽǰǺǴǻ ǴȀǺǷ DZȊ DZǽǶȋǻǴȁǴ , ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ). PHP-ǹǽdz ǻǽǵǴȁ ȀǽdzǴǿǵǯȁȋ ȅǷǹǺȊ ǔȀǺǷ ǾǽȀǺǴ DZȊǿǯǵǴǼǷȎ ȅǷǹǺǯ ȀǺǴdzȂǴȁ ǼǴǹǽȁǽǿǽǴ ȀǽdzǴǿǵǷǻǽǴ ǽǼǽ ǰȂdzǴȁ DZȊDZǴdzǴǼǽ ǻǼǽDzǽǹǿǯȁǼǽ Ǒ ȁǴǺǴ ȅǷǹǺǯ ǻǽDzȂȁ ǾǿǷȀȂȁȀȁDZǽDZǯȁȋ ǽȁǹǿȊDZǯȍȈǷǸǶǯǹǿȊDZǯȍȈǷǸ ȁǴDzǷ 3+3 ǜǯǾǿǷǻǴǿ ǻǽǵǼǽ ȀdzǴǺǯȁȋ ȀǺǴdzȂȍȈǴǴ My Text Line is
Ǭȁǽ ǽǰǴȀǾǴȆǷȁ ǾǽDZȁǽǿǴǼǷǴ HTML-ȀǽdzǴǿǵǷǻǽDzǽ ȁǴǹȀȁǯ ǶǯǹǺȍȆǴǼǼǽDzǽ DZ ȌǺǴǻǴǼȁ ǿǯǶ Ǚǯǹ DZǷdzǷȁǴ ǼǴ ǽǰȎǶǯȁǴǺȋǼǽ ǶǯǹǺȍȆǯȁȋ DZǴȀȋ ȁǴǹȀȁ DZ ȁǴDzǷ Ǭȁǽ ǾǽǺǴǶǼǽǴ ȀDZǽǸȀȁDZǽ ǾǿǷ ǽǰȉǴdzǷǼǴ ǼǷǷ PHP Ƿ XAML. Ǒ XAML ȄǽǺȀȁ-ǹǽǼȁǴǸǼǴǿ ǻǽǵǴȁ ǰȊȁȋ ǾǽǻǴȈǴǼ DZ ȅǷǹǺ: ...
ǑȊǾǽǺǼǴǼǷǴ ȌȁǽDzǽ ǹǽdzǯ ǽǰǴȀǾǴȆǷȁ ǶǯǾǷȀȋ XAML ǿǯǶ Ǭȁǽ dzǴǺǯǴȁ PHP ǻǽȈǼȊǻ ȎǶȊǹǽǻ ǽǾǷȀǯǼǷȎ ȇǯǰǺǽǼǽDZ dzǺȎ Silverlight. ǑǽǶDZǿǯȈǯȎȀȋ ǹ ǼǯȇǴǻȂ ǾǿǷǻǴǿȂ ǿǯȀȀǻǽȁǿǷǻ ǹǯǹ ȂȀȁǯǼǽDZǷȁȋ ǾǽdzǹǺȍȆǴǼǷǴ ǹ ǰǯǶǴ dzǯǼǼȊȄ DZȊǾǽǺǼǷȁȋ ǶǯǾǿǽȀ ǹ ǼǴǸ Ƿ ǶǯǾǷȀǯȁȋ ȁǽ ǹǽǺǷȆǴȀȁDZǽ XAML-ȌǺǴǻǴǼȁǽDZ Canvas ǹǽȁǽǿǽǴ ȀǽǽȁDZǴȁȀȁDZȂǴȁ ȆǷȀǺȂ DZǽǶDZǿǯ ȈǴǼǼȊȄ ǿǴǶȂǺȋȁǯȁǽDZ ǡǯǹǵǴ ǽȁǿǴdzǯǹȁǷǿȂǴǻ ȀǽdzǴǿǵǷǻǽǴ ȌǺǴǻǴǼȁǽDZ TextBlock ȄǽǺȀȁǯ-ǹǽǼȁǴǸǼǴǿǯ ȆȁǽǰȊ ǽǼǷ ǽȁǽǰǿǯǵǯǺǷ ǷǼȃǽǿǻǯȅǷȍ ǾǽǺȂȆǴǼǼȂȍ ǷǶ ǰǯǶȊ dzǯǼǼȊȄ ǯ ȁǯǹǵǴ ǽǰǴȀǾǴȆǷǻ ȂǼǷǹǯǺȋǼǽȀȁȋ ǷǻǴǼ TextBlock. Ǒ ǷȁǽDzǴ dzǽǺǵǼǯ ǾǽǺȂȆǷȁȋȀȎ PHP-ȀȁǿǯǼǷȅǯ ȃǽǿǻǷǿȂȍȈǯȎ XAML ǹǽȁǽǿȊǸ ǰȂdzǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ǹǯǹ ǷȀ ȁǽȆǼǷǹ dzǺȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǜǽ ȆȁǽǰȊ ǰȊǺǽ ǼǴǻǼǽDzǽ ǷǼȁǴǿǴȀǼǴǸ ǷǶǻǴǼǷǻ PHP Ƿ DZDZǴ dzǴǻ ǾǯǿǯǻǴȁǿ state (ȇȁǯȁ) ǹǽȁǽǿȊǸ ǽǰǴȀǾǴȆǷȁ DZǽǶDZǿǯȈǴǼǷǴ ȀDZǴdzǴǼǷǸ ȁǽǺȋǹǽ dzǺȎ ǺȍdzǴǸ ǾǿǽǵǷDZǯȍ ȈǷȄ DZ ǶǯdzǯǼǼǽǻ ȇȁǯȁǴ Ǭȁǽ ǾǿǴDZǿǯȁǷȁ Ǽǯȇ ǹǽdz DZ ǼǯȀȁǽȎȈǷǸ dzǷǼǯǻǷȆǴȀǹǷǸ DzǴǼǴǿǯȁǽǿ XAML. Ǒǽ-ǾǴǿDZȊȄ ǼǴǽǰȄǽdzǷǻǽ ȆȁǽǰȊ Silverlight ǿǯȀǾǽǶǼǯDZǯǺ DZȊDZǽdz PHP ǹǯǹ XML. ǓǺȎ ȌȁǽDzǽ ǶǯdzǯǴǻ ȁǷǾ MIME Ȁǽ dzǴǿǵǷǻǽDzǽ DZȊDZǽdzǯ Ǭȁǽ dzǴǺǯǴȁȀȎ DZ PHP Ȁ ǾǽǻǽȈȋȍ ǹǽǻǯǼdzȊ header ǶǯDzǽǺǽDZǽǹ header('Content-type: text/xml');
ǗǶDZǺǴȆǴǼǷǴ ǾǯǿǯǻǴȁǿǯ ȀȁǿǽǹǷ ǶǯǾǿǽȀǯ ȁǴ http://server/script.php?param=value) DZ PHP ǽǰǴȀǾǴȆǷDZǯǴȁȀȎ ǻǯȀȀǷDZǽǻ $ REQUEST. Ǘȁǯǹ, ȆȁǽǰȊ ǾǿǽȆǷȁǯȁȋ ǶǼǯȆǴǼǷǴ ǾǯǿǯǻǴȁǿǯ State, ǷȀǾǽǺȋǶȂǴǻ ȀǺǴdzȂȍȈǷǸ ǹǽdz: $State=$ REQUEST['State'];
Ǒ PHP DZǴǿȀǷǷ 4.x ǷǻǴǴȁȀȎ DZȀȁǿǽǴǼǼȊǸ Ǽǯǰǽǿ ǹǽǻǯǼdz MySQL ǓǺȎ DZǴǿȀǷǸ 5.x Ƿ DZȊȇǴ Ǽǯǰǽǿ ǹǽǻǯǼdz MySQL dzǽǺǵǴǼ ǶǯdzǯDZǯȁȋȀȎ ǹǯǹ ǿǯȀȇǷǿǴǼǷǴ ǜǴǶǯDZǷȀǷǻǽ ǽȁ ǷȀǾǽǺȋǶȂǴǻǽǸ DZǴǿȀǷǷ, ȀǷǼȁǯǹȀǷȀ PHP ǯǼǯ ǺǽDzǷȆǴǼ. ǞǽdzǹǺȍȆǴǼǷǴ ǹ ȀǴǿDZǴǿȂ localhost Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǷǻǴǼǷ ǾǽǺȋǶǽDZǯȁǴǺȎ user Ƿ ǾǯǿǽǺȎ password DZȊ ǾǽǺǼȎǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ ǹǽǻǯǼdzȊ mysql connect:
ǒǺǯDZǯ ǠǽǶdzǯǼǷǴ DZǶǯǷǻǽdzǴǸȀȁDZȂȍȈǷȄ Ȁ ȀǴǿDZǴǿǽǻ ǾǿǷǺǽǵǴǼǷǸ DZ 6LOYHUOLJKW
183
$con = mysql connect("localhost", "user", "password");
ǜǯ ȀǴǿDZǴǿǴ ǻǽǵǴȁ ǿǯȀǾǽǺǯDzǯȁȋȀȎ ǼǴȀǹǽǺȋǹǽ ǰǯǶ dzǯǼǼȊȄ ǓǺȎ DZȊǰǽǿǯ ǼǴǽǰȄǽdzǷǻǽǸ ǰǯǶȊ dzǯǼǼȊȄ ǷȀ ǾǽǺȋǶȂǴȁȀȎ ǹǽǻǯǼdzǯ mysql select db: mysql select db("test", $con); // "test"
ȐȔȧ ȉȈȏȣ ȌȈȕȕȣȝ
ǖǯȁǴǻ ȆȁǽǰȊ DZȊǾǽǺǼǷȁȋ ǶǯǾǿǽȀ ǹ ȌȁǽǸ ǰǯǶǴ dzǯǼǼȊȄ ǷȀǾǽǺȋǶȂǴȁȀȎ ǹǽǻǯǼdzǯ mysql query DZ ǹǽȁǽǿȂȍ ǾǴ ǿǴdzǯǴȁȀȎ Ȁȁǿǽǹǯ ȀǽdzǴǿǵǯȈǯȎ ȃǯǹȁǷȆǴȀǹǷǸ ǶǯǾǿǽȀ SQL ǟǴǶȂǺȋȁǯȁ ǶǯǾǿǽȀǯ ǰȂdzǴȁ ǾǿǴdzȀȁǯDZǺȎȁȋ ȀǽǰǽǸ ǻǯȀȀǷDZ ǻǯȀȀǷDZǽDZ ǶǼǯȆǴǼǷǸ ǞǿǷDZǴdzǴǻ ǾǿǷǻǴǿ $sqlString = "SELECT * from addresses"; $result = mysql query($sqlString);
ǖǯȁǴǻ ǻǯȀȀǷDZ mysql fetch array ǿǯǶǰǷDZǯǴȁȀȎ Ǽǯ ȀȁǿǽǹǷ Ǡ ǾǽǻǽȈȋȍ ȅǷǹǺǯ while ǻǽǵǼǽ ǽǰǽǸȁǷ ǹǯǵdzȂȍ ȀȁǿǽǹȂ ǹǯǹ ǾǽǹǯǶǯǼǽ DZ ȀǺǴdzȂȍȈǴǻ ǾǿǷǻǴǿǴ while($row = mysql fetch array($result)) { ... }
ȁǯǹǷǻ ǽǰǿǯǶǽǻ, ǷȀȄǽdzȎ ǷǶ dzǯǼǼǽDzǽ ȀȅǴǼǯǿǷȎ, ǾǽǺȂȆǯǴǻ ȁǯǹǽǸ ǯǺDzǽǿǷȁǻ dzǴǸȀȁDZǷǸ: ǖǯdzǯǴǻ ȁǷǾ MIME text/xml. ǞǿǷǼǷǻǯǴǻ DZȄǽdzǼǽǸ ǾǯǿǯǻǴȁǿ (ȇȁǯȁ). ǖǯǾǷȀȊDZǯǴǻ ǼǯȆǯǺȋǼȊǸ ȁǴDz ©ǹǽǿǼǴDZǽDzǽª Canvas. ǗȀǾǽǺȋǶȂǴǻ DZȄǽdzǼǽǸ ǾǯǿǯǻǴȁǿ dzǺȎ ǾǽȀȁǿǽǴǼǷȎ ǶǯǾǿǽȀǯ. ǑȊǾǽǺǼȎǴǻ ǶǯǾǿǽȀ Ƿ ǾǽǺȂȆǯǴǻ ǿǴǶȂǺȋȁǷǿȂȍȈǴǴ ǻǼǽǵǴȀȁDZǽ. ǓǺȎ ǹǯǵdzǽǸ ȀȁǿǽǹǷ ǿǴǶȂǺȋȁǷǿȂȍȈǴDzǽ ǻǼǽǵǴȀȁDZǯ: a. ǠǽǶdzǯǴǻ XAML-ȇǯǰǺǽǼǯ. b. ǖǯǾǽǺǼȎǴǻ ǯȁǿǷǰȂȁȊ Text ȌǺǴǻǴǼȁǽDZ TextBlock dzǯǼǼȊǻǷ ǷǶ ȀǽǽȁDZǴȁȀȁDZȂȍȈǷȄ ǾǽǺǴǸ ǰǯǶȊ dzǯǼ ǼȊȄ. c. ǖǯǾǽǺǼȎǴǻ ǯȁǿǷǰȂȁȊ x:Name ȂǼǷǹǯǺȋǼȊǻǷ ID ǾǽǺȂȆǴǼǼȊǻǷ Ǽǯ ǽȀǼǽDZǯǼǷǷ ǾǽǿȎdzǹǽDZǽDzǽ ǼǽǻǴǿǯ ȀȁǿǽǹǷ. ǖǯǹǿȊDZǯǴǻ ȁǴDz ©ǹǽǿǼǴDZǽDzǽª Canvas. Ǚǽdz PHP-ȀȁǿǯǼǷȅȊ ǾǽǺǼǽȀȁȋȍ ǾǿǷDZǴdzǴǼ DZ ǺǷȀȁǷǼDzǴ 10- ǟǯǶǻǴȁǹǯ PHP DZ ǰǺǽǹǴ XAML DZȊdzǴǺǴǼǯ ǵǷǿ ǼȊǻ ȇǿǷȃȁǽǻ ǚǗǠǡǗǜǒ 10 2 PHP ǹǽdz dzǺȎ ȃǽǿǻǷǿǽDZǯǼǷȎ XAML 1.33333333333334 C:\Code\SLBook\Chapter11\DZCSample \source images\dzcsample\DSCN2961.JPG 0 0 1 1 1 C:\Code\SLBook\Chapter11\DZCSample \source images\dzcsample\DSCN2959.JPG 0.451782754964542 0.313488814592021 0.00099432659277551 0.00099432659277551 2
Ǚǯǹ DZǷdzǷȁǴ Ȍȁǽ dzǽDZǽǺȋǼǽ ǾǿǽȀȁǽǸ XAML-ǹǽdz Ǒ ǼǴǻ ȂǹǯǶȊDZǯǴȁȀȎ ȀǽǽȁǼǽȇǴǼǷǴ ȀȁǽǿǽǼ ǽȀǼǽDZǼǽDzǽ ǷǶǽ ǰǿǯǵǴǼǷȎ ǾǽǺȂȆǴǼǼǽǴ ǷȀȄǽdzȎ ǷǶ ǿǯǶǻǴǿǽDZ ǾǴǿDZǽDzǽ ǷǶǽǰǿǯǵǴǼǷȎ Ƿ ǹǯǵdzǽǴ ǷǶǽǰǿǯǵǴǼǷǴ ǾǿǴDZǿǯȈǯ ǴȁȀȎ DZ SceneNode ǢǶǴǺ ȀȅǴǼȊ ǞǴǿDZǽǴ ǷǶǽǰǿǯǵǴǼǷȎ ȎDZǺȎǴȁȀȎ ǾǴǿDZȊǻ SceneNode ǝǼǽ ǿǯȀǾǽǺǯDzǯǴȁȀȎ DZ ǾǽǶǷȅǷǷ Ƿ ȎDZǺȎǴȁȀȎ ǼǽǿǻǯǺǷǶǽDZǯǼǼȊǻ ǷǶǽǰǿǯǵǴǼǷǴǻ ȁǴ ǴDzǽ ȇǷǿǷǼǯ Ƿ DZȊȀǽȁǯ ǾǿǷǼǷǻǯȍȁȀȎ Ƕǯ ǟǯǶǻǴǿȊ Ƿ ǿǯȀǾǽǺǽǵǴǼǷǴ DZȀǴȄ ǽȀȁǯǺȋǼȊȄ ǷǶǽǰǿǯǵǴǼǷǸ ȂȀȁǯǼǯDZǺǷDZǯȍȁȀȎ ǽȁǼǽȀǷȁǴǺȋǼǽDzǽ ǾǴǿDZǽDzǽ ǑȁǽǿǽǴ ǷǶǽǰǿǯǵǴǼǷǴ ǿǯǶǻǴȈǯǴȁȀȎ DZ ȁǽȆǹǴ Ȁ ǹǽǽǿdzǷǼǯȁǯǻǷ Ǿǽ ǽȀǷ Ȅ Ƿ Ǿǽ ǽȀǷ Ȃ ǔDzǽ ǿǯǶǻǴǿ Ȁǽ ȀȁǯDZǺȎǴȁ ǾǿǷǻǴǿǼǽ ǿǯǶǻǴǿǽDZ ǾǴǿDZǽDzǽ ǷǶǽǰǿǯǵǴǼǷȎ ǡǯǹǷǻ ǽǰǿǯǶǽǻ ǴȀǺǷ ȂDZǴǺǷȆǷȁȋ ǾǴǿDZǽǴ ǷǶǽǰǿǯǵǴǼǷǴ ǾǿǷǻǴǿǼǽ DZ ǿǯǶ ǻǽǵǼǽ ǰȂdzǴȁ ȂDZǷdzǴȁȋ DZȁǽǿǽǴ ǷǶǽǰǿǯǵǴǼǷǴ ǔDzǽ Z-ǾǽǿȎdzǽǹ ǿǯDZǴǼ 2 (Z-ǾǽǿȎdzǽǹ ǾǴǿDZǽDzǽ ǷǶǽǰǿǯǵǴǼǷȎ ² ȁǴ ǽǼ ǰȂdzǴȁ ǽȁǿǷȀǽDZȊDZǯȁȋȀȎ ǾǽDZǴǿȄ ǾǴǿDZǽDzǽ ǷǶǽǰǿǯǵǴǼǷȎ
ǒǺǯDZǯ ǛȂǺȋȁǷǻǴdzǷǯ ǿȂǹǽǾǷȀǼȊǸ DZDZǽdz Ƿ 'HHS Zoom
233
ǙǿǽǻǴ ȁǽDzǽ ǿǴdzǯǹȁǽǿ Deep Zoom ǿǯǶdzǴǺȎǴȁ ǷǶǽǰǿǯǵǴǼǷǴ Ǽǯ ǿǯDZǼȊǴ ȃǿǯDzǻǴǼȁȊ ǾǽȌȁǽǻȂ ǾǿǷ ǻǯȀȇȁǯ ǰǷǿǽDZǯǼǷǷ ǿǷȀȂǼǹǯ ǶǯDzǿȂǵǯǴȁȀȎ ǼǴ DZȀǴ ǷǶǽǰǿǯǵǴǼǷǴ ǯ ǺǷȇȋ ǾǿǽȀǻǯȁǿǷDZǯǴǻȊǴ ȃǿǯDzǻǴǼȁȊ Ȇȁǽ ǽȆǴǼȋ ȌȃȃǴǹȁǷDZǼǽ ǾǿǷ ǿǯǰǽȁǴ Ȁ ǰǽǺȋȇǷǻǷ ǷǶǽǰǿǯǵǴǼǷȎǻǷ ǞǿǷ ǾǿǽȀǻǽȁǿǴ ǷǶǽǰǿǯǵǴǼǷȎ DZ ǻǯǺǴǼȋǹǽǻ ǻǯȀ ȇȁǯǰǴ DZȊ DZǷdzǷȁǴ DZȀǴ ȃǿǯDzǻǴǼȁȊ ȂǻǴǼȋȇǴǼǼȊǻǷ ǝǼǷ ǽǰǺǯdzǯȍȁ ǼǴǹǽȁǽǿȊǻ ǶǯǾǯȀǽǻ ǿǯǶǿǴȇǴǼǷȎ dzǺȎ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷȎ. ǞǿǷ ȂDZǴǺǷȆǴǼǷǷ ǻǯȀȇȁǯǰǯ ǷǶǽǰǿǯǵǴǼǷȎ dzǽ ǾǿǴdzǴǺǽDZ ǿǯǶǿǴȇǯȍȈǴǸ ȀǾǽȀǽǰǼǽȀȁǷ ǷǺǷ DZȊȇǴ DZȊ ǰȂdzǴȁǴ DZǷdzǴȁȋ ǺǷȇȋ ȆǯȀȁȋ ǿǷȀȂǼǹǯ ȁǴ ȁǽǺȋǹǽ ȃǿǯDzǻǴǼȁȊ ǾǿǴdzȀȁǯDZǺȎȍȈǷǴ DZǷdzǷǻȂȍ ȆǯȀȁȋ ǷǶǽǰǿǯǵǴǼǷȎ ǽǰǴȀǾǴȆǷDZǯȎ ȁǯǹǷǻ ǽǰǿǯǶǽǻ ȌǹǽǼǽǻǼǽǴ ǷȀǾǽǺȋǶǽDZǯǼǷǴ ǾǿǽǾȂȀǹǼǽDzǽ ǹǯǼǯǺǯ Ƿ Ȁǽ ǹǿǯȈǯȎ DZǿǴǻȎ ǶǯDzǿȂǶǹǷ ǓǿȂDzǽǸ ȌǹȀǾǽǿȁǷǿȂǴǻȊǸ ȃǯǸǺ ǰȂdzǴȁ ǼǯǶȊDZǯǴȁȀȎ dzc output.xml Ǒ ǼǴǻ ȀǽdzǴǿǵǯȁȀȎ DZȀǴ ȀDZǴdzǴǼǷȎ ǽ ȃǿǯDzǻǴǼȁǯȄ Ƿ ǷȄ ǾǽǺǽǵǴǼǷǷ ǽȁǼǽȀǷȁǴǺȋǼǽ ǽȀǼǽDZǼǽDzǽ ǷǶǽǰǿǯǵǴǼǷȎ ǝǼ ǰȂdzǴȁ ǿǯȀǾǽǺǯDzǯȁȋȀȎ DZ ǹǯȁǯǺǽDzǴ ȀǽǶdzǯǼǼǽǻ ǿǴdzǯǹȁǽǿǽǻ Deep Zoom DZ ǹǽȁǽǿǽǻ DZȊ ȁǯǹǵǴ ǼǯǸdzǴȁǴ ǿȎdz ǾǽdzǾǯǾǽǹ Ȁ ǷǶǽǰǿǯǵǴǼǷȎǻǷ
ǞǴǿDZȊǸ ǾǿǽǴǹȁ Deep Zoom ǦȁǽǰȊ ǷȀǾǽǺȋǶǽDZǯȁȋ Deep Zoom ȀǽǶdzǯdzǷǻ ǼǽDZǽǴ ǾǿǷǺǽǵǴǼǷǴ Silverlight ǞǿǴǵdzǴ ȆǴǻ dzǴǺǯȁȋ Ȇȁǽ-ǺǷǰǽ ǴȈǴ ǼǴǽǰȄǽdzǷǻǽ ȀǹǽǻǾǷǺǷǿǽDZǯȁȋ ǾǿǷǺǽǵǴǼǷǴ ǞǿǷ Ȍȁǽǻ ǰȂdzǴȁ ȀǽǶdzǯǼ ǹǯȁǯǺǽDz ClientBin DZ ǾǿǽǴǹȁǴ ǑǴǰǾǿǷǺǽǵǴǼǷȎ ǠdzǴǺǯDZ Ȍȁǽ ǶǯǹǿǽǸȁǴ ǿǴȇǴǼǷǴ ǡǴǾǴǿȋ DZ Windows Explorer ȀǹǽǾǷǿȂǸȁǴ ǹǯȁǯǺǽDz ȀǽdzǴǿǵǯȈǷǸ ȃǯǸǺ dzc output.xml Ƿ ǾǽdzǾǯǾǹǷ Ȁ ȃǿǯDz ǻǴǼȁǷǿǽDZǯǼǼȊǻǷ ǷǶǽǰǿǯǵǴǼǷȎǻǷ DZ ǾǯǾǹȂ ClientBin ǑǴǰ-ǾǿǷǺǽǵǴǼǷȎ ǠdzǴǺǯDZ Ȍȁǽ DZǼǽDZȋ ǽȁǹǿǽǸȁǴ ǿǴ ȇǴǼǷǴ Solution Explorer DZǯȇǴDzǽ ǾǿǽǴǹȁǯ ǰȂdzǴȁ DZȊDzǺȎdzǴȁȋ ǾǿǷǻǴǿǼǽ ȁǯǹ ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 11-25.
ǟǗǠ 11 25 ǓǽǰǯDZǺǴǼǷǴ dzǯǼǼȊȄ Deep Zoom DZ ǑǴǰ ǾǿǷǺǽǵǴǼǷǴ.
ǡǴǾǴǿȋ ȆȁǽǰȊ ȀȃǽǿǻǷǿǽDZǯȁȋ DZǷǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ȀǽdzǴǿǵǷǻǽDzǽ Deep Zoom ǼǴǽǰȄǽdzǷǻǽ ǾǿǽȀȁǽ dzǽǰǯDZǷȁȋ MultiScaleImage DZ Page.xaml Ƿ DZ ǹǯȆǴȀȁDZǴ ǶǼǯȆǴǼǷȎ ǴDzǽ ȀDZǽǸȀȁDZǯ Source Ƕǯdzǯȁȋ ǾȂȁȋ ǹ ȃǯǸǺȂ dzc output.xml DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ Ȍȁǽȁ ȃǯǸǺ ǿǯȀǾǽǺǯDzǯǴȁȀȎ DZ /dzcsample/dzc output.xml ǯ ȁǯǹǵǴ ǼǴǽǰ ȄǽdzǷǻȊǴ ȇǷǿǷǼȂ Ƿ DZȊȀǽȁȂ ǞǽȀǻǽȁǿǷǻ ǹǯǹ ǰȂdzǴȁ DZȊDzǺȎdzǴȁȋ DZǯȇ Page.xaml:
Ǘȁǯǹ ǾǿǷ DZȊǾǽǺǼǴǼǷǷ ȌȁǽDzǽ ǾǿǷǺǽǵǴǼǷȎ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ MultiScaleImage ǰȂdzǴȁ ȃǽǿǻǷǿǽDZǯȁȋ DZǷ ǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ DZǴǿȄǼǴDzǽ ȌǺǴǻǴǼȁǯ DZ SceneGraph ȂDZǴǺǷȆǷDZǯȎ ǴDzǽ ǽȁ ǽǿǷDzǷǼǯǺȋǼǽDzǽ ǻǯȀȇȁǯǰǯ ǷǶǽǰǿǯǵǴǼǷȎ dzǽ ǶǯdzǯǼǼȊȄ ȇǷǿǷǼȊ Ƿ DZȊȀǽȁȊ DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ 400 î 300).
234
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
Ǚǯǹ DZǷdzǷȁǴ DZ ǾǿǷǺǽǵǴǼǷǷ ǼǴȁ ǯDZȁǽǻǯȁǷȆǴȀǹǽǸ ǿǴǯǺǷǶǯȅǷǷ ȂǾǿǯDZǺǴǼǷȎ ǻȊȇȋȍ ǾǽȌȁǽǻȂ ǻȊ ǼǴ ǻǽǵǴǻ ǾǴǿǴǻǴȈǯȁȋȀȎ Ǿǽ ǷǶǽǰǿǯǵǴǼǷȍ ǷǺǷ ǻǴǼȎȁȋ ǴDzǽ ǻǯȀȇȁǯǰ Ǚǯǹ Ȍȁǽ dzǴǺǯǴȁȀȎ ǰȂdzǴȁ ǿǯȀȀǻǽȁǿǴǼǽ DZ ȀǺǴ dzȂȍȈǴǻ ǿǯǶdzǴǺǴ
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǻȊȇǷ Ƿ ǺǽDzǷȆǴȀǹǷȄ ǹǽǽǿdzǷǼǯȁ DZ Deep Zoom Ǚǯǹ Ƿ DZȀǴ ǽȀȁǯǺȋǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight, MultiScaleImage ǻǽǵǴȁ ǽǰȉȎDZǺȎȁȋ ȃȂǼǹȅǷǷ dzǺȎ ǽǰǿǯǰǽȁǹǷ ȀǽǰȊȁǷǸ ǜǯǾǿǷǻǴǿ dzǺȎ ǾǴǿǴǻǴȈǴǼǷȎ ǷǶǽǰǿǯǵǴǼǷȎ ǷȀǾǽǺȋǶȂȍȁȀȎ ǽǰȊȆǼȊǴ ȀǽǰȊȁǷȎ ǻȊ ȇǷ MouseLeftButtonDown, MouseLeftButtonUp Ƿ MouseMove, ² Ƿ ǽǰǿǯǰǯȁȊDZǯȍȁȀȎ ǽǼǷ ȁǯǹ ǵǴ ǹǯǹ Ȍȁǽ dzǴ ǺǯǴȁȀȎ ǾǿǷ ǾǴǿǴǻǴȈǴǼǷǷ ǺȍǰǽDzǽ ȌǺǴǻǴǼȁǯ ǻǴȁǽdzǽǻ ©drag-and-dropª ǠǼǯȆǯǺǯ, ǿǯȀȀǻǽȁǿǷǻ XAML dzǺȎ MultiScaleImage, ǽǾǿǴdzǴǺȎȍȈǷǸ ȌȁǷ ȀǽǰȊȁǷȎ:
Ǘ ȁǴǾǴǿȋ ǿǯȀȀǻǽȁǿǷǻ ǹǯǵdzȊǸ ǷǶ ȌȁǷȄ ǽǰǿǯǰǽȁȆǷǹǽDZ ȀǽǰȊȁǷǸ ǰǽǺǴǴ ǾǽdzǿǽǰǼǽ ǞǿǴǵdzǴ DZȀǴDzǽ ǴȀȁȋ ǹǽdz ǽǰȈǷǸ dzǺȎ ǼǷȄ DZȀǴȄ ǹǽȁǽǿȊǸ ǽǰǴȀǾǴȆǷDZǯǴȁ ǽȁȀǺǴǵǷDZǯǼǷǴ ȁǴǹȂȈǴDzǽ ȀǽȀȁǽȎǼǷȎ ǻȊȇǷ Ƿ ǾǿǽȀǻǯȁǿǷDZǯǴ ǻȊȄ DZ ǼǯȀȁǽȎȈǷǸ ǻǽǻǴǼȁ ǹǽǽǿdzǷǼǯȁ MultiScaleImage: bool dragging = false; double dx = 0; double dy = 0; Point p0; Point p1; Point pLast;
ǡǴǾǴǿȋ ǾǽȀǻǽȁǿǷǻ, Ȇȁǽ ǾǿǽǷȀȄǽdzǷȁ, ǹǽDzdzǯ ǾǽǺȋǶǽDZǯȁǴǺȋ ȈǴǺǹǯǴȁ ǷǶǽǰǿǯǵǴǼǷǴ ǹǼǽǾǹǽǸ ǻȊȇǷ: private void MultiScaleImage MouseLeftButtonDown( object sender, MouseButtonEventArgs e) { dragging = true; p0 = dz.ElementToLogicalPoint(new Point(0, 0)); p1 = dz.ElementToLogicalPoint(new Point(640, 480)); dx = 0; dy = 0; double x = e.GetPosition(null).X; double y = e.GetPosition(null).Y; pLast = dz.ElementToLogicalPoint(new Point(x, y)); }
ǞǿǴdzǾǽǺǯDzǯǴȁȀȎ Ȇȁǽ ǾǽǺȋǶǽDZǯȁǴǺȋ ȂdzǴǿǵǷDZǯǴȁ ǹǼǽǾǹȂ ǻȊȇǷ Ƿ dzDZǷDzǯǴȁ ǻȊȇȋȍ ǾǽȌȁǽǻȂ ǶǯdzǯǴǻ ǐȂǺǴ DZǽǻȂ ȀDZǽǸȀȁDZȂ dragging ǾǴǿǴȁȎDzǷDZǯǼǷǴ ǶǼǯȆǴǼǷǴ true ǡǴǾǴǿȋ ǼǴǽǰȄǽdzǷǻǽ ǾǽǺȂȆǷȁȋ ȁǴǹȂȈǷǴ ǹǽǽǿdzǷ ǼǯȁȊ DZǷdzǷǻǽǸ ȆǯȀȁǷ ǷǶǽǰǿǯǵǴǼǷȎ ǑȀǾǽǻǼǷǻ Ȇȁǽ dzǺȎ DZǴǿȄǼǴDzǽ ǷǶǽǰǿǯǵǴǼǷȎ ǶǯdzǯǼǯ ǾǽǶǷȅǷȎ ǷǺǷ x = 0 and y = 0, Ƿ ǴDzǽ DZȊȀǽȁǯ Ƿ ȇǷǿǷǼǯ ǶǯdzǯǼȊ ǿǯDZǼȊǻǷ Ǭȁǽ ǺǽDzǷȆǴȀǹǷǴ ǹǽǽǿdzǷǼǯȁȊ Ƿ ǺǽDzǷȆǴȀǹǷǴ ǿǯǶǻǴǿȊ Ǒ Silverlight ǺǽDzǷȆǴȀǹǷǴ ǹǽǽǿdzǷǼǯȁȊ DZǴǿȄǼǴDzǽ ǺǴDZǽDzǽ ȂDzǺǯ Ƿ ǼǷǵǼǴDzǽ ǾǿǯDZǽDzǽ ȂDzǺǯ ǽǹǼǯ ǻǽǵǼǽ ǾǽǺȂ ȆǷȁȋ Ȁ ǾǽǻǽȈȋȍ ǻǴȁǽdzǯ ElementToLogicalPoint (ǚǽDzǷȆǴȀǹǯȎ ȁǽȆǹǯ ȌǺǴǻǴǼȁǯ ǾǴǿǴdzǯDZ DZ ǼǴDzǽ ȃǷǶǷȆǴȀǹǷǴ ǹǽǽǿdzǷǼǯȁȊ Ǘȁǯǹ, ǾǿǴdzȀȁǯDZǷǻ, Ȇȁǽ ǷǶǽǰǿǯǵǴǼǷǴ ǰȊǺǽ ȂDZǴǺǷȆǴǼǽ Ƿ ǼǴǻǼǽDzǽ ǾǴǿǴdzDZǷǼȂȁǽ. ǡǴǾǴǿȋ ǴȀǺǷ DZȊǶDZǯȁȋ Ȍȁǽȁ API dzǺȎ ȃǷǶǷȆǴȀǹǽǸ ȁǽȆǹǷ ȁǴ DZǴǿȄǼǴDzǽ ǺǴDZǽDzǽ ȂDzǺǯ DZǷdzǷǻǽǸ DZ dzǯǼǼȊǸ ǻǽǻǴǼȁ ȆǯȀ ȁǷ ǷǶǽǰǿǯǵǴǼǷȎ ǰȂdzǴȁ DZǽǶDZǿǯȈǴǼǯ ǺǽDzǷȆǴȀǹǯȎ ȁǽȆǹǯ ǾǿǴdzȀȁǯDZǺȎȍȈǯȎ ǾǽǺǽǵǴǼǷǴ Ȍȁǽ ȁǽȆǹǷ Ǽǯ ǾǽǺ Ǽǽǻ ǷǶǽǰǿǯǵǴǼǷǷ ǦȁǽǰȊ ǾǽǺȂȆǷȁȋ ǹǽǽǿdzǷǼǯȁȊ ǼǷǵǼǴDzǽ ǾǿǯDZǽDzǽ ȂDzǺǯ dzǴǺǯǴǻ ȁǽ ǵǴ ȀǯǻǽǴ dzǺȎ ȁǽȆǹǷ ǹǽǽǿdzǷǼǯȁȊ ǹǽȁǽǿǽǸ ȀǽǽȁDZǴȁȀȁDZȂȍȁ ȇǷǿǷǼǴ Ƿ DZȊȀǽȁǴ ȃǷǶǷȆǴȀǹǽDzǽ ȌǹǿǯǼǯ DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ 640 î 480).
ǒǺǯDZǯ ǛȂǺȋȁǷǻǴdzǷǯ ǿȂǹǽǾǷȀǼȊǸ DZDZǽdz Ƿ 'HHS Zoom
235
ǛȊ ȄǽȁǷǻ ǽȁȀǺǴǵǷDZǯȁȋ ǷǶǻǴǼǴǼǷǴ ǿǯǶǻǴǿǽDZ ǽȁǼǽȀǷȁǴǺȋǼǽ ǽȀǴǸ Ȅ Ƿ Ȃ ǾǽȌȁǽǻȂ ǶǯdzǯǴǻ ǾǴǿǴǻǴǼǼȊǻ dx Ƿ dy ǶǼǯȆǴǼǷǴ ǖǯȆǴǻ Ȍȁǽ ȀdzǴǺǯǼǽ ȀȁǯǼǴȁ ǾǽǼȎȁǼǽ ȆǴǿǴǶ ǻDzǼǽDZǴǼǷǴ ǙǿǽǻǴ ȁǽDzǽ ǼǴǽǰȄǽdzǷǻǽ ǾǽǺȂȆǯȁȋ ǺǽDzǷȆǴȀǹǷǴ ǹǽǽǿdzǷǼǯȁȊ ǹȂǿȀǽǿǯ ǻȊȇǷ ǓǺȎ ȌȁǽDzǽ DZȊǶȊDZǯǴȁȀȎ API ElementToLogicalPoint DZ ǼǴDzǽ ǾǴǿǴdzǯǴȁȀȎ ȁǴǹȂȈǴǴ ǾǽǺǽǵǴǼǷǴ ǻȊȇǷ ǹǽȁǽǿǽǴ ǻǽǵǼǽ ǾǽǺȂȆǷȁȋ ǷǶ ǽǰȉ Ǵǹȁǯ MouseEventArgs ǾǴǿǴdzǯDZǯǴǻǽDzǽ DZ ȌȁȂ ȃȂǼǹȅǷȍ Ƿ DZǽǶDZǿǯȈǯǴǻȊǴ ǿǴǶȂǺȋȁǯȁȊ ȀǽȄǿǯǼȎȍȁȀȎ DZ ǾǴǿǴ ǻǴǼǼǽǸ pLast. Ǘȁǯǹ Ȇȁǽ ǾǿǽǷȀȄǽdzǷȁ ǹǽDzdzǯ ǾǽǺȋǶǽDZǯȁǴǺȋ ǼǯȆǷǼǯǴȁ ǾǴǿǴȁȎDzǷDZǯǼǷǴ ȂdzǴǿǵǷDZǯȎ ǹǼǽǾǹȂ ǻȊȇǷ ǼǯǵǯȁǽǸ" ǛȊ ȄǽȁǷǻ ǾǽǺȂȆǷȁȋ ȌȃȃǴǹȁ ǾǴǿǴǻǴȈǴǼǷȎ Ǿǽ ǷǶǽǰǿǯǵǴǼǷȍ Ǒǽȁ ǹǽdz ǿǴǯǺǷǶȂȍȈǷǸ Ȍȁǽ private void MultiScaleImage MouseMove( object sender, MouseEventArgs e) { if (dragging) { if (e!=null) { double x = e.GetPosition(null).X; double y = e.GetPosition(null).Y; Point pCurrent = dz.ElementToLogicalPoint(new Point(x, y)); if (pLast!=null) { dx += (pCurrent.X - pLast.X); dy += (pCurrent.Y - pLast.Y); Point origin = new Point(p0.X - dx, p0.Y - dy); dz.ViewportOrigin = origin; } pLast = pCurrent; } } }
ǠǽǰȊȁǷǴ MouseMove ȃǽǿǻǷǿȂǴȁȀȎ ǼǴǶǯDZǷȀǷǻǽ ǽȁ ȁǽDzǽ ȂdzǴǿǵǷDZǯǴȁȀȎ ǹǼǽǾǹǯ ǻȊȇǷ ǷǺǷ ǼǴȁ ǾǽȌȁǽǻȂ dzǺȎ ǽǰǽǶǼǯȆǴǼǷȎ ǾǴǿǴȁȎDzǷDZǯǼǷȎ ǷȀǾǽǺȋǶȂǴǻ ǾǴǿǴǻǴǼǼȂȍ dragging Ǘȁǯǹ ǴȀǺǷ ǾǽǺȋǶǽDZǯȁǴǺȋ DZȊǾǽǺǼȎǴȁ ǾǴǿǴȁȎDzǷDZǯǼǷǴ Ƿ MouseEventArgs ǼǴ null ǰȂdzǴȁ DZȊǾǽǺǼȎȁȋȀȎ DZǴȀȋ ǽȀȁǯǺȋǼǽǸ ǹǽdz Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ ǻȊ ǷǶDZǺǴǹǯǴǻ ȁǴǹȂȈǷǴ ǹǽǽǿdzǷǼǯȁȊ ǻȊȇǷ Ƿ ȀǽȄǿǯǼȎǴǻ ǷȄ ǺǽDzǷȆǴȀǹǷǴ ȌǹDZǷDZǯǺǴǼȁȊ (ǾǽǺȂȆǴǼǼȊǴ Ȁ ǾǽǻǽȈȋȍ ǻǴȁǽdzǯ ElementToLogicalPoint ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ DZ ȁǽȆǹǴ pCurrent ǡǴǾǴǿȋ ǴȀǺǷ pLast ǼǴ null ǶǼǯȆǷȁ ǾǽǺȋǶǽDZǯȁǴǺȋ DZȊǾǽǺǼȎǴȁ ǾǴǿǴȁȎDzǷDZǯǼǷǴ Ƿ ǻȊȇȋ ǾǴǿǴǻǴȀȁǷǺǯȀȋ ǽȁǼǽȀǷȁǴǺȋ Ǽǽ ǴǴ ǾǿǴdzȊdzȂȈǴDzǽ ǾǽǺǽǵǴǼǷȎ Ǘȁǯǹ ȆȁǽǰȊ ǾǽǺȂȆǷȁȋ ǷǶǻǴǼǴǼǷǴ ǺǽDzǷȆǴȀǹǷȄ ǹǽǽǿdzǷǼǯȁ ǾǿǽǷǶǽȇǴdz ȇǴǴ DZ ǿǴǶȂǺȋȁǯȁǴ ǾǴǿǴǻǴȈǴǼǷȎ ǻȊȇǷ ǷǶ ǾǿǴdzȊdzȂȈǴǸ ȁǽȆǹǷ DZ ȁǴǹȂȈȂȍ ǻȊ ǾǿǽȀȁǽ DZȊȆǷȀǺȎǴǻ ǿǯǶǼǷȅȂ dzǴǺȋȁȂ ǻǴǵdzȂ ǾǿǴdzȊdzȂȈǷǻǷ Ƿ ȁǴǹȂȈǷǻǷ ǹǽǽǿdzǷǼǯȁǯǻǷ ǽȁǼǽȀǷȁǴǺȋǼǽ ǽǰǴǷȄ ǽȀǴǸ Ȅ Ƿ Ȃ ǞǽȀǺǴ ȌȁǽDzǽ ǶǯdzǯǴǻ dzǺȎ ȀDZǽǸȀȁDZǯ Origin ǜǯȆǯǺǽ ǽȁȀȆǴȁǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ MultiScaleImage ǷȀȄǽdzǼȊǴ ǹǽǽǿdzǷǼǯ ȁȊ Ȁ ȂȆǴȁǽǻ dzǴǺȋȁǯ Ǿǽ Ȅ Ƿ Ȃ Ǭȁǽ ǽǰǴȀǾǴȆǷȁ ȌȃȃǴǹȁ ©ǾǴǿǴǻǴȈǴǼǷȎª ǷǶǽǰǿǯǵǴǼǷȎ ǾǿǷ ǾǴǿǴǻǴȈǴǼǷǷ ǻȊȇȋȍ ȄǽȁȎ ǻȊ Ǿǽ ȀȂȁǷ ǾǿǽȀȁǽ ǷǶǻǴǼȎǴǻ ǹǽǽǿdzǷǼǯȁȊ DZǴǿȄǼǴDzǽ ǺǴDZǽDzǽ ȂDzǺǯ ǽȁǽǰǿǯǵǯǴǻǽǸ ȆǯȀȁǷ ǷǶǽǰǿǯǵǴǼǷȎ Ǟǽ ǶǯDZǴǿȇǴǼǷǷ ǾǴǿǴǻǴȈǴǼǷȎ ǼǴǽǰȄǽdzǷǻǽ ǾǿǽȀȁǽ Ƕǯdzǯȁȋ ǾǽǺǽǵǴǼǷǴ Last ǞǽȀǺǴdzǼǷǸ ǹǯǹ Current ȆȁǽǰȊ ǹǽDzdzǯ ǾǽǺȋǶǽDZǯȁǴǺȋ DZǼǽDZȋ ǼǯȆǼǴȁ dzDZǷDzǯȁȋ ǻȊȇȋȍ DZȊȆǷȀǺǴǼǷȎ ǾǿǽǷǶDZǽdzǷǺǷȀȋ ǽȁ ǼǽȀǷȁǴǺȋǼǽ ȌȁǽǸ ȁǽȆǹǷ ǯ ǼǴ ȁǽǸ DZ ǹǽȁǽǿǽǸ ǾǽǺȋǶǽDZǯȁǴǺȋ ǼǯǵǻǴȁ ǹǼǽǾǹȂ ǻȊȇǷ ǜǯǹǽǼǴȅ ǼǴǽǰȄǽdzǷǻǽ ȆȁǽǰȊ ǾǽȀǺǴ ȁǽDzǽ ǹǯǹ ǾǽǺȋǶǽDZǯȁǴǺȋ ǽȁǾȂȀȁǷȁ ǹǼǽǾǹȂ ǻȊȇǷ DZȀǴ DZǴǿǼȂǺǽȀȋ DZ ǷȀ ȄǽdzǼǽǴ ȀǽȀȁǽȎǼǷǴ ǠdzǴǺǯȁȋ Ȍȁǽ dzǽDZǽǺȋǼǽ ǾǿǽȀȁǽ. ǟǯȀȀǻǽȁǿǷǻ ǹǽdz: private void MultiScaleImage MouseLeftButtonUp( object sender, MouseButtonEventArgs e) { dragging = false; p0 = new Point(); p1 = new Point(); pLast = new Point(); dx = 0; dy = 0; }
236
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
ǬȁǷ ȁǿǷ ǾǿǽȀȁȊǴ ȃȂǼǹȅǷǷ ǽǰǴȀǾǴȆǷDZǯȍȁ ǾǽǺȋǶǽDZǯȁǴǺȍ DZǽǶǻǽǵǼǽȀȁȋ ǾǴǿǴȁȎDzǷDZǯȁȋ ǷǶǽǰǿǯǵǴǼǷǴ Ƿ ǾǴ ǿǴǻǴȈǯȁȋȀȎ Ǿǽ ǼǴǻȂ ǼǴǶǯDZǷȀǷǻǽ ǽȁ ȀȁǴǾǴǼǷ ǴDzǽ ȂDZǴǺǷȆǴǼǷȎ Ǒ ȀǺǴdzȂȍȈǴǻ ǿǯǶdzǴǺǴ ǰȂdzǴȁ ǾǽǹǯǶǯǼǽ ǹǯǹ Ȁ ǾǽǻǽȈȋȍ ǹǽǺǴȀǯ ǻȊȇǷ ȂDZǴǺǷȆǷDZǯȁȋ Ƿ ȂǻǴǼȋȇǯȁȋ ǷǶǽǰǿǯǵǴǼǷǴ Ƿ ȁǯǹǷǻ ǽǰǿǯǶǽǻ ǽȁǹǿȊDZǯȁȋ ȆǯȀȁǷ ǷǶǽǰǿǯǵǴǼǷȎ ȀǹǿȊȁȊǴ ǾǿǷ dzǿȂDzǷȄ ȀȁǴǾǴǼȎȄ ȂDZǴǺǷȆǴǼǷȎ.
ǠǽǶdzǯǼǷǴ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁǷ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷȎ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǹǽǺǴȀǯ ǻȊȇǷ ǞǿǽǰǺǴǻǽǸ ǾǿǷ ȀǽǶdzǯǼǷǷ ǾǿǷǺǽǵǴǼǷǸ Deep Zoom ȎDZǺȎǴȁȀȎ ȁǽ Ȇȁǽ ȀȁǯǼdzǯǿȁǼȊǻ ȀǿǴdzȀȁDZǽǻ ǷǶǻǴǼǴǼǷȎ ǻǯȀȇȁǯǰǯ dzǴ ȃǯǹȁǽ ȎDZǺȎǴȁȀȎ ǹǽǺǴȀǽ ǻȊȇǷ Ǽǽ Silverlight Ƿ .NET ǼǴ ǽǰǿǯǰǯȁȊDZǯȍȁ ȀǽǰȊȁǷȎ ǹǽǺǴȀǯ ǻȊ ȇǷ Ǧȁǽ ǵǴ ǻǽǵǼǽ ȀdzǴǺǯȁȋ? ǠȂȈǴȀȁDZȂǴȁ dzDZǯ DZǯǿǷǯǼȁǯ. ǞǴǿDZȊǸ ² ǷȀǾǽǺȋǶǽDZǯȁȋ JavaScript DZǻǴȀȁǽ C# Ǿǽ ȁǽǻȂ Ȇȁǽ ǰǿǯȂǶǴǿ ǻǽǵǴȁ ǾǴǿǴȄDZǯȁȊDZǯȁȋ ǾǴǿǴǻǴȈǴǼǷȎ ǹǽǺǴȀǯ ǻȊȇǷ Ƿ ȃǽǿǻǷǿǽDZǯȁȋ ȀǽǰȊȁǷȎ DZ ǽȁDZǴȁ Ǽǯ ǴDzǽ ǾǿǽǹǿȂȆǷDZǯǼǷǴ ǑȁǽǿǽǸ DZǯǿǷǯǼȁ ² ǷȀǾǽǺȋǶǽDZǯȁȋ ǰǿǯȂǶǴǿ ǹǯǹ ǻǽȀȁ ǹ Silverlight ȁǴ ǰǿǯȂǶǴǿ dzǽǺǵǴǼ ǰȂdzǴȁ ǾǴǿǴȄDZǯȁȊDZǯȁȋ ȀǽǰȊȁǷǴ Ƿ ǶǯȁǴǻ ǷǼȃǽǿǻǷǿǽDZǯȁȋ .NET ǽǰ Ȍȁǽǻ ǑȀȎ dzǯǺȋǼǴǸȇǯȎ ǽǰǿǯǰǽȁǹǯ ǰȂdzǴȁ ǽȀȂȈǴȀȁDZǺȎȁȋȀȎ DZ .NET ǑȀǴ ǼǯǻǼǽDzǽ ǾǿǽȈǴ ȆǴǻ ǹǯǵǴȁȀȎ ǞǿǴǵdzǴ DZȀǴDzǽ ǼǴǽǰȄǽdzǷǻǽ ǽǰǴȀǾǴȆǷȁȋ DZǽǶǻǽǵǼǽȀȁȋ ǷȀǾǽǺȋǶǽDZǯǼǷȎ API ǰǿǯȂǶǴǿǯ DZ Silverlight, ǾǽȌȁǽǻȂ ǼǴ ǶǯǰȂdzȋȁǴ DZǹǺȍȆǷȁȋ DZ ǹǽdz ȀǺǴdzȂȍȈȂȍ ȀȁǿǽǹȂ using System.Windows.Browser;
ǖǯȁǴǻ DZ ǹǽǼȀȁǿȂǹȁǽǿǴ Page ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ dzǽǺǵǴǼ ǰȊȁȋ ǶǯǿǴDzǷȀȁǿǷǿǽDZǯǼ ǹǯǹ ǾǽdzdzǴǿǵǷDZǯȍȈǷǸ ȀȅǴǼǯǿǷǷ ǛǴȁǽdzȊ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ǽǰǽǶǼǯȆǴǼǼȊǴ ǹǯǹ ScriptableMember (ǢȆǯȀȁǼǷǹ ǾǽdzdzǴǿǵǷ DZǯȍȈǷǸ ȀȅǴǼǯǿǷǷ dzǽȀȁȂǾǼȊ ǷǶ JavaScript. Ǒǽȁ ǹǯǹ Ȍȁǽ dzǴǺǯǴȁȀȎ: public Page() { InitializeComponent(); HtmlPage.RegisterScriptableObject("MySilverlightObject", this); }
ǓǯǺǴǴ ȁǿǴǰȂǴȁȀȎ ǾǴǿǴȄDZǯȁȊDZǯȁȋ ȀǽǰȊȁǷȎ ǹǽǺǴȀǯ ǻȊȇǷ Ǽǯ ȌȁǽǸ ȀȁǿǯǼǷȅǴ ǓǺȎ ȌȁǽDzǽ ȀǼǯȆǯǺǯ dzǽǰǯDZǺȎǴǻ DZȊǶǽDZ handleLoad DZ ȁǴDz ȆȁǽǰȊ ǽǰǴȀǾǴȆǷȁȋ DZȊǾǽǺǼǴǼǷǴ JavaScript-ǹǽdzǯ ǾǿǷ ȃǽǿǻǷǿǽDZǯǼǷǷ DZǷ ǶȂǯǺȋǼǽDzǽ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ȀȁǿǯǼǷȅȊ ...
ǖǯȁǴǻ DZ JavaScript-ȃȂǼǹȅǷǷ handleLoad ǶǯdzǯǴȁȀȎ ȀǽǰȊȁǷǴ: function handleLoad() { window.onmousewheel = document.onmousewheel = onMouseWheel; if (window.addEventListener) { window.addEventListener('DOMMouseScroll', onMouseWheel, false); } }
ǡǴǻ ȀǯǻȊǻ ǽǾǿǴdzǴǺȎǴǻ Ȇȁǽ JavaScript-ȃȂǼǹȅǷȎ onMouseWheel ǞǿǷ ǾǿǽǹǿȂȆǷDZǯǼǷǷ ǹǽǺǴȀǯ ǻȊȇǷ ǰȂ dzǴȁ DZȊǾǽǺǼȎȁȋȀȎ ǾǿǷ Ǻȍǰǽǻ ǾǿǽǹǿȂȆǷDZǯǼǷǷ ǹǽǺǴȀǯ ǻȊȇǷ function onMouseWheel() { if(!event) { event = window.event; } var slPlugin = $get("Xaml1"); slPlugin.content.MySilverlightObject.dz_MouseWheel( event.clientX, event.clientY, event.wheelDelta); }
ǒǺǯDZǯ ǛȂǺȋȁǷǻǴdzǷǯ ǿȂǹǽǾǷȀǼȊǸ DZDZǽdz Ƿ 'HHS Zoom
237
Ǭȁǯ ȃȂǼǹȅǷȎ ǾǿǽȀȁǽ ǾǿǷǼǷǻǯǴȁ ȀȀȊǺǹȂ Ǽǯ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ ǾǿǷ ȀǽǶdzǯ ǼǷǷ ǴǻȂ ǾǿǷȀDZǯǷDZǯǴȁȀȎ ǷǻȎ Xaml1 Ƿ ǶǯȁǴǻ DZȊǶȊDZǯǴȁ ȃȂǼǹȅǷȍ DZȊdzǴǺǴǼǼǽDzǽ ǹǽdzǯ ǽǾǿǴdzǴǺǴǼǼȂȍ dzǺȎ ǼǴDzǽ ǓǺȎ DZȊǶǽDZǯ ǷȀǾǽǺȋǶȂǴȁȀȎ ȀǷǼȁǯǹȀǷȀ .content... ² Ȍȁǽ ǾǴǿǴǻǴǼǼǯȎ ǽǾǿǴdzǴǺǴǼǼǯȎ DZ JavaScript ǹǯǹ ȀȀȊǺǹǯ Ǽǯ ǽǰȉǴǹȁ Silverlight. ² Ȍȁǽ ǷǻȎ ǶǯdzǯǼǼǽǴ dzǺȎ ǽǰȉǴǹȁǯ ǾǿǷ ǴDzǽ ǿǴDzǷȀȁǿǯȅǷǷ ǴǴ ǻǽǵǼǽ ȂDZǷdzǴȁȋ DZ ǹǽǼȀȁǿȂǹ ȁǽǿǴ Page()). ² Ȍȁǽ ǷǻȎ DZȊǶȊDZǯǴǻǽǸ ȃȂǼǹȅǷǷ Ǭȁǯ ȃȂǼǹȅǷȎ dzǽǺǵǼǯ ǰȊȁȋ ȀǽǽȁDZǴȁȀȁDZȂȍ ȈǷǻ ǽǰǿǯǶǽǻ ǽǾǷȀǯǼǯ ȆȁǽǰȊ JavaScript ©DZǷdzǴǺª ǴǴ Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ DZȊǶȊDZǯǴȁȀȎ ȃȂǼǹȅǷȎ dz MouseWheel ǿǯȀȀǻǽȁǿǷǻ ǴǴ [ScriptableMember] public void dz MouseWheel(double x, double y, int delta) { double dZoomFactor=1.33; if (delta < 0) dZoomFactor= 1/1.33; Point pz = dz.ElementToLogicalPoint(new Point(x, y)); dz.ZoomAboutLogicalPoint(dZoomFactor, pz.X, pz.Y); }
ǞǿǴǵdzǴ DZȀǴDzǽ ǹǯǹ DZǷdzǷȁǴ ǽǼǯ ǽǰǽǶǼǯȆǴǼǯ ScriptableMember, ȁǴ JavaScript ǻǽǵǴȁ DZǷdzǴȁȋ Ƿ DZȊǶȊDZǯȁȋ ǴǴ ǣȂǼǹȅǷȎ JavaScript ǾǴǿǴdzǯǴȁ ȁǴǹȂȈǷǴ ǹǽǽǿdzǷǼǯȁȊ ǻȊȇǷ Ƿ dzǴǺȋȁǯ DZǽǶǼǷǹǯȍȈǷǴ DZ ǿǴǶȂǺȋȁǯȁǴ ǷǶǻǴǼǴ ǼǷȎ ǻǯȀȇȁǯǰǯ ǓǴǺȋȁǯ ǰȂdzǴȁ ǷǻǴȁȋ ǾǽǺǽǵǷȁǴǺȋǼǽǴ ǶǼǯȆǴǼǷǴ ǾǿǷ ǾǿǽǹǿȂȆǷDZǯǼǷǷ ǹǽǺǴȀǯ DZǾǴǿǴdz Ƿ ǽȁ ǿǷȅǯȁǴǺȋǼǽǴ ǶǼǯȆǴǼǷǴ ǾǿǷ ǾǿǽǹǿȂȆǷDZǯǼǷǷ ǼǯǶǯdz ǛǯȀȇȁǯǰǼȊǸ ǹǽȌȃȃǷȅǷǴǼȁ ǹǯǵdzǽDzǽ ǾǿǽǹǿȂȆǷDZǯǼǷȎ ǹǽǺǴȀǯ ǶǯdzǯǼ ǿǯDZǼȊǻ 33% (Ǽǽ ǽǼ ǻǽǵǴȁ ǰȊȁȋ Ǻȍ ǰȊǻ ȁǯǹǷǻ ǽǰǿǯǶǽǻ ǾǴǿǴǻǴǼǼǽǸ dZoomFactor ǛǯȀȇȁǯǰǼȊǸ ǹǽȌȃȃǷȅǷǴǼȁ ǶǯdzǯǴȁȀȎ ǶǼǯȆǴǼǷǴ 1.33 ǾǿǷ ȂDZǴǺǷȆǴǼǷǷ Ƿ 1/1.33 ǾǿǷ ȂǻǴǼȋȇǴǼǷǷ ǻǯȀȇȁǯǰǯ ǓǯǺǴǴ ȁǿǴǰȂǴȁȀȎ ȆȁǽǰȊ ǷǶǻǴǼǴǼǷǴ ǿǯǶǻǴǿǽDZ ǾǿǽǷȀȄǽdzǷǺǽ DZǽǹǿȂDz ȁǴǹȂȈǴDzǽ ǾǽǺǽǵǴǼǷȎ ǹȂǿȀǽǿǯ ǻȊȇǷ Ǽǯ ǷǶǽǰǿǯǵǴǼǷǷ Ǭȁǽ ǽȆǴǼȋ ǾǿǽȀȁǽ ȀdzǴǺǯȁȋ ǾǿǴǽǰǿǯǶǽDZǯDZ ǹǽǽǿdzǷǼǯȁȊ ǹȂǿȀǽǿǯ ǻȊȇǷ DZ ǺǽDzǷȆǴȀǹȂȍ ȁǽȆǹȂ Ȁ ǾǽǻǽȈȋȍ ǻǴȁǽdzǯ ElementToLogicalPoint ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ MultiScaleImage ǗǻǴȎ ǹǽǽǿdzǷǼǯ ȁȊ Ƿ ǹǽȌȃȃǷȅǷǴǼȁ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷȎ DZȊǶȊDZǯǴǻ ǻǴȁǽdz ZoomAboutLogicalPoint ǛǯȀȇȁǯǰǷǿǽDZǯǼǷǴ DZǽ ǹǿȂDz ǺǽDzǷȆǴȀǹǽǸ ȁǽȆǹǷ ȆȁǽǰȊ ǽǰǴȀǾǴȆǷȁȋ ǷǶǻǴǼǴǼǷǴ ǿǯǶǻǴǿǽDZ MultiScaleImage.
ǙǽǺǺǴǹȅǷǷ DZ Deep Zoom ǙǿǽǻǴ DZǽǶǻǽǵǼǽȀȁǷ ȂDZǴǺǷȆǴǼǷȎ Ƿ ȂǻǴǼȋȇǴǼǷȎ ǷǶǽǰǿǯǵǴǼǷȎ ǻǽǵǼǽ ȁǯǹǵǴ ȀǽǶdzǯDZǯȁȋ ǹǽǺǺǴǹȅǷǷ ǷǶǽ ǰǿǯǵǴǼǷǸ Ƿ ǿǯǰǽȁǯȁȋ Ȁ ǼǷǻǷ DZ ǻǯȀȇȁǯǰǷǿȂǴǻǽǸ ȀǿǴdzǴ ǑǽǶǻǽǵǼǽ DZȊ ǶǯǻǴȁǷǺǷ Ȇȁǽ ǾǿǷ ȌǹȀǾǽǿȁǴ ǷǶǽǰǿǯǵǴǼǷǸ ǷǶ ǿǴdzǯǹȁǽǿǯ Deep Zoom DZȀǴDzdzǯ ǾǿǴdzǺǯDzǯǺǯȀȋ ǽǾȅǷȎ Create Collection ǠǽǶdzǯȁȋ ǹǽǺǺǴǹȅǷȍ Ǚǯǹ ȀǺǴdzȂǴȁ ǷǶ ǴǴ ǷǻǴǼǷ Ȍȁǯ ǽǾȅǷȎ ǽǰǴȀǾǴȆǷDZǯǴȁ ȀǽǶdzǯ ǼǷǴ ǹǽǺǺǴǹȅǷǷ ǷǶǽǰǿǯǵǴǼǷǸ ǞǽȀǻǽȁǿǷǻ Ǽǯ ǿǷȀ 11- Ǚǯǹ DZǷdzǷȁǴ Ȏ ǿǯǶǻǴȀȁǷǺ DZ ǿǯǰǽȆǴǸ ǽǰǺǯȀȁǷ ǻǼǽǵǴȀȁDZǽ ǷǶǽǰǿǯǵǴǼǷǸ ǡǴǾǴǿȋ dzǯDZǯǸȁǴ ǾǽȀǻǽȁǿǷǻ ǹǯǹ ǷȄ ǻǽǵǼǽ ȌǹȀǾǽǿȁǷǿǽDZǯȁȋ DZ DZǷdzǴ ǹǽǺǺǴǹȅǷǷ ǓǺȎ ǿǯǰǽȁȊ Ȁ ǷǶǽǰǿǯǵǴǼǷȎǻǷ ǹǽǺǺǴǹȅǷǷ Silverlight ǾǿǴdzǺǯDzǯǴȁ ǹǽǺǺǴǹȅǷȍ SubImages ǛǼǽǵǴȀȁDZǽ ǷǶǽ ǰǿǯǵǴǼǷǸ ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ ǾǿǷ ȃǽǿǻǷǿǽDZǯǼǷǷ DZǷǶȂǯǺȋǼǽDzǽ ǾǿǴdzȀȁǯDZǺǴǼǷȎ ȀȁǿǯǼǷȅȊ ǾǽǺǼȊǸ Ǽǯǰǽǿ ǷǶǽǰǿǯǵǴǼǷǸ ǼǴ ǰȂdzǴȁ ǶǯDzǿȂǵǯȁȋȀȎ ǾǽȌȁǽǻȂ Ȍȁǯ ǹǽǺǺǴǹȅǷȎ ǰȂdzǴȁ ǾȂȀȁǽǸ DZ Ȍȁǽȁ ǻǽǻǴǼȁ ǦȁǽǰȊ ǷǻǴȁȋ DZǽǶǻǽǵǼǽȀȁȋ ǿǯǰǽȁǯȁȋ Ȁ ǹǽǺǺǴǹȅǷǴǸ ǼǴǽǰȄǽdzǷǻǽ ǽǾǷȀǯȁȋ ȀǽǰȊȁǷǴ ImageOpenSucceeded ǗǶǽ ǰǿǯǵǴǼǷǴ ǽȁǹǿȊȁǽ ȂȀǾǴȇǼǽ Ǭȁǽ ȀǽǰȊȁǷǴ ǰȂdzǴȁ ȃǽǿǻǷǿǽDZǯȁȋȀȎ DZ ȀǺȂȆǯǴ ȂȀǾǴȇǼǽǸ ǶǯDzǿȂǶǹǷ Ƿ ǽȁǽ ǰǿǯǵǴǼǷȎ
238
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
ǟǗǠ 11 26 ǠǽǶdzǯǼǷǴ ǹǽǺǺǴǹȅǷǷ Deep Zoom.
ǟǯȀȀǻǽȁǿǷǻ XAML:
Ǒ Ȍȁǽȁ ǻǽǻǴǼȁ ǹǽǺǺǴǹȅǷȎ SubImages ǰȂdzǴȁ ǶǯǾǽǺǼǴǼǯ Ƿ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ǿǯǰǽȁȊ Ȁ ǽȁdzǴǺȋǼȊ ǻǷ ǿǷȀȂǼǹǯǻǷ ǴǴ ȀǽȀȁǯDZǺȎȍȈǷǻǷ ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ ǷǶǻǴǼǴǼǷȎ ǻǴȀȁǽǿǯȀǾǽǺǽǵǴǼǷȎ ǷǶǽǰǿǯǵǴǼǷǸ private void dz ImageOpenSucceeded(object sender, RoutedEventArgs e) { int nImages = dz.SubImages.Count; for (int lp = 0; lp < nImages; lp++) { dz.SubImages[lp].ViewportOrigin = new Point(lp*0.1, lp*0.1); } }
Ǚǯǹ DZǷdzǷȁǴ ǾǿǽȅǴȀȀ ǯǰȀǽǺȍȁǼǽ ǯǼǯǺǽDzǷȆǴǼ ȁǽǻȂ ǹǽȁǽǿȊǸ ǷȀǾǽǺȋǶǽDZǯǺȀȎ ǿǯǼǴǴ dzǺȎ ǿǯǰǽȁȊ Ȁ ǽdzǼǷǻ ǿǷȀȂǼǹǽǻ Ǒ dzǯǼǼǽǻ ȀǺȂȆǯǴ ǹǯǵdzǽǴ ǷǶǽǰǿǯǵǴǼǷǴ ǾǴǿǴǻǴȈǯǴȁȀȎ ǾȂȁǴǻ ǷȀǾǽǺȋǶǽDZǯǼǷȎ SubImages[lp,], DzdzǴ lp ² Ȍȁǽ ǾǴǿǴǻǴǼǼǯȎ ȅǷǹǺǯ ǹǽȁǽǿǯȎ ǻǽǵǴȁ ǾǿǷǼǷǻǯȁȋ ǶǼǯȆǴǼǷȎ ǽȁ dzǽ ȆǷȀǺǯ ȀǽǽȁDZǴȁȀȁDZȂȍȈǴDzǽ ǹǽǺǷȆǴȀȁDZȂ ǷǶǽǰǿǯǵǴǼǷǸ DZ ǹǽǺǺǴǹȅǷǷ ǟǴǶȂǺȋȁǯȁȊ ǾǿǴdzȀȁǯDZǺǴǼȊ Ǽǯ ǿǷȀ 11- ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ǽǯ ǿǯǶǼǷȅȂ ǻǴǵdzȂ ȌȁǽǸ Ƿ ǷȀȄǽdzǼǽǸ ǹǽǻǾǽǼǽDZǹǯǻǷ ǹǽȁǽǿǯȎ ǾǿǴdzȀȁǯDZǺǴǼǯ Ǽǯ ǿǷȀ 11.26.
ǒǺǯDZǯ ǛȂǺȋȁǷǻǴdzǷǯ ǿȂǹǽǾǷȀǼȊǸ DZDZǽdz Ƿ 'HHS Zoom
239
ǟǗǠ 11 27 ǙǽǻǾǽǼǽDZǹǯ ǹǽǺǺǴǹȅǷǷ ǷǶǽǰǿǯǵǴǼǷǸ.
ǖǯǹǺȍȆǴǼǷǴ Ǒ ȌȁǽǸ dzǺǷǼǼǽǸ DzǺǯDZǴ ǾǿǴdzȀȁǯDZǺǴǼȊ ȁǿǷ ǼǯǷǰǽǺǴǴ ǻǽȈǼȊȄ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǾǿǴdzǺǯDzǯǴǻȊǴ Silverlight 2 ǠǼǯȆǯǺǯ ǰȊǺ ǾǽdzǿǽǰǼǽ ǿǯȀȀǻǽȁǿǴǼ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ MediaElement Ƿ ȁǽ ǹǯǹ ǻǽǵǼǽ ǷȀǾǽǺȋ ǶǽDZǯȁȋ Silverlight dzǺȎ DZǽȀǾǿǽǷǶDZǴdzǴǼǷȎ Ƿ ȁǿǯǼȀȃǽǿǻǯȅǷǷ DZǷdzǴǽ- ǷǷǺǷ ǯȂdzǷǽȀǽdzǴǿǵǷǻǽDzǽ DZǹǺȍȆǯȎ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ ǾǿǽǶǿǯȆǼǽȀȁǷ ǻǯǿǹǴǿȊ dzǷǼǯǻǷȆǴȀǹǷǴ ǻǯǿǹǴǿȊ Ƿ ȁdz ǖǯȁǴǻ DZȊ ǾǽǶǼǯǹǽǻǷǺǷȀȋ Ȁ ǿȂǹǽǾǷȀǼȊǻǷ ǾǿǷǻǴȆǯǼǷȎǻǷ Ƿ ȂȀȁǿǽǸȀȁDZǯǻǷ ǾǽdzdzǴǿǵǷDZǯȍȈǷǻǷ ǷȄ ǯ ȁǯǹǵǴ ȁǴǻ ǹǯǹ Silverlight ǻǽǵǴȁ ǽǰǴȀǾǴȆǷȁȋ ǾǽdzdzǴǿǵǹȂ ǿȂǹǽǾǷȀǼǽDzǽ DZDZǽdzǯ Ǽǯ ǑǴǰ-ȀȁǿǯǼǷȅǯȄ ǜǯǹǽǼǴȅ DZǯȇǴǻȂ DZǼǷǻǯǼǷȍ ǰȊǺǯ ǾǿǴdz ȀȁǯDZǺǴǼǯ ȁǴȄǼǽǺǽDzǷȎ Deep Zoom Ƿ ǿǴǯǺǷǶǯȅǷȎ ȌȁǽǸ ǼǽDZǽǸ DZǽǶǻǽǵǼǽȀȁǷ DZ Silverlight ǑȊ ǼǯȂȆǷǺǷȀȋ ȀǽǶ dzǯDZǯȁȋ ȀȅǴǼȊ Ƿ ǹǽǺǺǴǹȅǷǷ ǿǯȀȇǷǿǴǼǼȊǴ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁȋȍ DzǺȂǰǽǹǽDzǽ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷȎ
ǒǺǯDZǯ 12
ǠȁǷǺǷ Ƿ ȇǯǰǺǽǼȊ DZ Silverlight 2 Silverlight ǾǿǴdzǺǯDzǯǴȁ ǻǼǽǵǴȀȁDZǽ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǽǼǷ ǰȊǺǷ ǿǯȀȀǻǽȁǿǴǼȊ DZ ǼǴȀǹǽǺȋǹǷȄ ǾǿǴdzȊ dzȂȈǷȄ DzǺǯDZǯȄ ǯ ȁǯǹǵǴ DZǽǶǻǽǵǼǽȀȁȋ ȀǽǶdzǯǼǷȎ ȀǽǰȀȁDZǴǼǼȊȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǑȀǴ ǾǽȀȁǯDZǺȎǴǻȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight ȂǵǴ Ǿǽ ȂǻǽǺȆǯǼǷȍ DZȊDzǺȎdzȎȁ DzǯǿǻǽǼǷȆǼǽ Ƿ ǼǯȀȊȈǴǼǼǽ Ǽǽ ǴȀǺǷ DZǽǶ ǼǷǹǼǴȁ ǼǴǽǰȄǽdzǷǻǽȀȁȋ ǷǶǻǴǼǷȁȋ ǷȄ ȀȁǯǼdzǯǿȁǼȊǸ DZǷdz ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ ȀǽǰȀȁDZǴǼǼǽǻȂ dzǷǶǯǸǼȂ Silverlight 2 ǾǿǴdzǺǯDzǯǴȁ ǻǽȈǼȊǴ DZǽǶǻǽǵǼǽȀȁǷ ȀȁǷǺǴDZǽDzǽ ǽȃǽǿǻǺǴǼǷȎ Ƿ ȇǯǰǺǽǼǽDZ ǹǽȁǽǿȊǴ ǻǽDzȂȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ǷǶǻǴǼǴǼǷȎ ǾǿǴdzȀȁǯDZǺǴǼǷȎ DZǯȇǴDzǽ ǾǿǷǺǽǵǴǼǷȎ
ǞǽǼǷǻǯǼǷǴ ȀȁǷǺǴDZǽDzǽ ǽȃǽǿǻǺǴǼǷȎ ǦȁǽǰȊ ǾǽǼȎȁȋ Ȇȁǽ ȁǯǹǽǴ ȀȁǷǺǴDZǽǴ ǽȃǽǿǻǺǴǼǷǴ ǿǯȀȀǻǽȁǿǷǻ ǾǿǽȀȁǽǸ ǾǿǷǻǴǿ ǷȀǾǽǺȋǶǽDZǯǼǷȎ ǹǼǽǾǹǷ DZ Silverlight-ǾǿǷǺǽǵǴǼǷǷ ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ XAML dzǺȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Button:
Ǭȁǽ ǽǰǴȀǾǴȆǷȁ ǽȁǽǰǿǯǵǴǼǷǴ ǹǼǽǾǹǷ DZ ȀȁǯǼdzǯǿȁǼǽǻ ȀȁǷǺǴ Silverlight ȀǴǿǴǰǿǷȀȁǽDzǽ ȅDZǴȁǯ ǹǯǹ ǰȂdzȁǽ Ȁ ǾǽdzȀDZǴȁǹǽǸ ȀDZǴǿȄȂ ǹǯǹ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 12-1.
ǟǗǠ 12 1 ǐǯǶǽDZǯȎ ǹǼǽǾǹǯ Silverlight.
Ǚǯǹ ǰȊǺǽ ǾǽǹǯǶǯǼǽ DZ ǒǺǯDZǴ ©ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǾǿǴdzȀȁǯDZǺǴǼǷȎ Ƿ ǹǽǻǾǽǼǽDZǹǷª Ƿ DZ ǒǺǯ DZǴ ©ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight: ǿǯȀȇǷǿǴǼǼȊǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎª ǻǼǽDzǷǴ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZ ǺǴǼǷȎ Silverlight DZǹǺȍȆǯȎ Button, ȎDZǺȎȍȁȀȎ ȌǺǴǻǴǼȁǯǻǷ ȂǾǿǯDZǺǴǼǷȎ Ȁ ȀǽdzǴǿǵǷǻȊǻ ȁǴ ǻǽDzȂȁ ȃǽǿǻǷ ǿǽDZǯȁȋ DZǷǶȂǯǺȋǼǽǴ ǾǿǴdzȀȁǯDZǺǴǼǷǴ XAML-ȀǽdzǴǿǵǷǻǽDzǽ Ǒ ȀǺȂȆǯǴ Ȁ Button Ȍȁǽ ǽǶǼǯȆǯǴȁ Ȇȁǽ ǽǼ ǻǽǵǴȁ DZǹǺȍȆǯȁȋ ǹǽǴ-Ȇȁǽ ǰǽǺǴǴ ǷǼȁǴǿǴȀǼǽǴ ȆǴǻ ǾǿǽȀȁǽ Ȁȁǿǽǹǯ ©Click Me!ª ǨǴǺǹǼǷ ǻǴǼȎ Ƿ Ȇȁǽ DZ ǼǴDzǽ ǻǽǵ Ǽǽ dzǽǰǯDZǺȎȁȋ ǼǴǹǽȁǽǿȂȍ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁȋ ǽǰǴȀǾǴȆǷDZǯȍȈȂȍ ǾǽǺȋǶǽDZǯȁǴǺȍ ǰǽǺǴǴ ȇǷǿǽǹǷǴ DZǽǶǻǽǵ ǼǽȀȁǷ ǾǿǷ DZǶǯǷǻǽdzǴǸȀȁDZǷǷ Ȁ ȌȁǷǻ ȌǺǴǻǴǼȁǽǻ ȂǾǿǯDZǺǴǼǷȎ ǜǯǾǿǷǻǴǿ ȀǽǶdzǯdzǷǻ ǹǼǽǾǹȂ Ȁ ǷǶǽǰǿǯǵǴǼǷǴǻ ǓǺȎ ȌȁǽDzǽ ǷȀǾǽǺȋǶȂǴǻ ǷǶǽǰǿǯǵǴǼǷǴ ǹǯǹ ȀǽdzǴǿǵǷǻǽǴ ǹǼǽǾǹǷ ǜǯǾǿǷǻǴǿ:
Ǚǯǹ Ȍȁǽ DZȊDzǺȎdzǷȁ Ǽǯ ȌǹǿǯǼǴ ǾǿǴdzȀȁǯDZǺǴǼǽ Ǽǯ ǿǷȀ 12-2.
ǒǺǯDZǯ ǠȁǷǺǷ Ƿ ȇǯǰǺǽǼȊ DZ Silverlight 2
241
ǟǗǠ 12 2 ǙǼǽǾǹǯ ǷȀǾǽǺȋǶȂȍȈǯȎ XAML ȀǽdzǴǿǵǷǻǽǴ.
ǑǯȀ ǼǴ ȂȀȁǿǯǷDZǯǴȁ ȀȁǯǼdzǯǿȁǼȊǸ ȇǿǷȃȁ Ƿ ȅDZǴȁ ǼǯdzǾǷȀǷ Ǽǯ ǹǼǽǾǹǴ Ƿ DZȊ ȄǽȁǷȁǴ ǴȈǴ ǰǽǺȋȇǴ ǷǶǻǴǼǷȁȋ ǴǴ DZǼǴȇǼǷǸ DZǷdz" ǠdzǴǺǯȁȋ Ȍȁǽ DZ XAML dzǽDZǽǺȋǼǽ ǾǿǽȀȁǽ. ǛǽǵǼǽ Ƕǯdzǯȁȋ ȀDZǽǸȀȁDZǯ DZǹǺȍȆǯȍȈǷǴ ȀǴǻǴǸȀȁDZǽ ȇǿǷȃȁǽDZ ǿǯǶǻǴǿ ǼǯȀȊȈǴǼǼǽȀȁȋ Ƿ ȁdz ǼǯȀȁǿǯǷDZǯȍȈǷǴ DZǼǴȇǼǷǸ DZǷdz ǹǼǽǾǹǷ ǜǯǾǿǷǻǴǿ, ǾǽȀǻǽȁǿǷǻ Ǽǯ ǽǰǼǽDZǺǴǼǼȊǸ TextBlock:
ǡǯǹǵǴ dzǽǰǯDZǷǻ ǼǴȀǹǽǺȋǹǽ dzǿȂDzǷȄ ǿǴǯǺǷǶǯȅǷǸ ǹǼǽǾǹǷ Ǒ XAML Ȍȁǽ ȀdzǴǺǯȁȋ dzǽDZǽǺȋǼǽ ǾǿǽȀȁǽ ǾǽȁǽǻȂ Ȇȁǽ ǻǽǵǼǽ ǾǿǽȀȁǽ ȀǹǽǾǷǿǽDZǯȁȋ ǾǴǿDZȂȍ ǹǼǽǾǹȂ ǯ ǶǯȁǴǻ Ƕǯdzǯȁȋ ȀDZǽǸȀȁDZǯ ǿǯȀǾǽǺǽǵǴǼǷȎ ǞǿǷǻǴǿ ǾǿǴdzȀȁǯDZ ǺǴǼ Ǽǯ ǿǷȀ 12-3.
ǟǗǠ 12 3 ǜǴȀǹǽǺȋǹǽ ȌǹǶǴǻǾǺȎǿǽDZ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Button.
ǑȊDzǺȎdzǷȁ ȀǺǯDZǼǽ Ƿ ǽȆǴǼȋ ǾǿǽȀȁǽ ǿǴǯǺǷǶȂǴȁȀȎ Ǽǽ ǷȀǾǽǺȋǶǽDZǯǼǷǴ ȁǯǹǽDzǽ ǾǽdzȄǽdzǯ ǾǿǷDZǴdzǴȁ ǹ ǿǯǶǿǯȀȁǯ ǼǷȍ XAML Ƿ Ȇȁǽ ǴȈǴ ȄȂǵǴ ǰǽǺȋȇǽǻȂ ǹǽǺǷȆǴȀȁDZȂ ǾǽDZȁǽǿȎȍȈǴDzǽȀȎ ǹǽdzǯ Ȇȁǽ ȂȀǺǽǵǼǷȁ ǾǿǽDZǴǿǹȂ ǽȁ ǺǯdzǹȂ ǽǰȀǺȂǵǷDZǯǼǷǴ Ƿ ǽǰǼǽDZǺǴǼǷǴ ǾǿǷǺǽǵǴǼǷȎ ǑǽǶȋǻǴǻ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ TextBlock. ǓǺȎ ǹǯǵdzǽDzǽ ǷǶ ǼǷȄ ȎDZǼǽ ǽǰȉȎDZǺǴǼȊ ȀDZǽǸȀȁDZǯ FontFamily, Foreground Ƿ FontSize ǼǴȀǻǽȁǿȎ Ǽǯ ȁǽ Ȇȁǽ DZȀǴǻ Ƿǻ ǶǯdzǯǼǽ ǽdzǼǽ Ƿ ȁǽ ǵǴ ǶǼǯȆǴǼǷǴ Ǐ Ȇȁǽ ǴȀǺǷ ȁǿǴǰȂǴȁȀȎ ǷǶǻǴǼǷȁȋ ǹǯǹǽǴ-ȁǽ ǷǶ ȌȁǷȄ ǶǼǯȆǴǼǷǸ ǞǿǷdzǴȁȀȎ ǾǿǽȀǻǯȁǿǷDZǯȁȋ ǹǯǵdzȊǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǽdzǷǼ Ƕǯ dzǿȂDzǷǻ ȆȁǽǰȊ ǽǰǼǽDZǷȁȋ ǷȄ DZȀǴ Ǒǽȁ DzdzǴ DZǽǶǼǷǹǯǴȁ ǼǴǽǰȄǽdzǷǻǽȀȁȋ DZ ȀȁǷǺȎȄ ǓǯDZǯǸȁǴ ǿǯȀȀǻǽȁǿǷǻ ǹǯǹ DZȊǼǴȀȁǷ ǼǴǹǽȁǽǿȊǴ ǷǶ ȌȁǷȄ dzǯǼ ǼȊȄ DZ ȀȁǷǺȋ
ǠǽǶdzǯǼǷǴ ȀȁǷǺȎ ǠȁǷǺȋ ȀǽǶdzǯǴȁȀȎ DZ ǿǯǶdzǴǺǴ ǟǴȀȂǿȀȊ ǹǽǼȁǴǸǼǴǿǯ ǖdzǴȀȋ ǻǽǵǴȁ ǰȊȁȋ ȀǽǶdzǯǼ ǽdzǷǼ ǷǺǷ ǰǽǺǴǴ ȀȁǷǺǴǸ dzǺȎ ǹǽȁǽǿȊȄ ǶǯdzǯǴȁȀȎ ǷǻȎ ȀȁǷǺȎ Ƿ ȁǷǾ ǽǰȉǴǹȁǯ ǹ ǹǽȁǽǿǽǻȂ ǰȂdzǴȁ ǾǿǷǻǴǼȎȁȋȀȎ ȀȁǷǺȋ ǜǯǾǿǷǻǴǿ ȆȁǽǰȊ ȀǽǶdzǯȁȋ ȀȁǷǺȋ TextBlockStyle ǠȁǷǺȋ ȁǴǹȀȁǽDZǽDzǽ ǰǺǽǹǯ dzǺȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ TextBlock ǷȀǾǽǺȋ ǶȂǴȁȀȎ ȁǯǹǽǸ XAML:
242
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
ǓǺȎ ȀȁǷǺȎ ǶǯdzǯǴȁȀȎ ȁǷǾ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǹ ǹǽȁǽǿǽǻȂ ǽǼ ǻǽǵǴȁ ǾǿǷǻǴǼȎȁȋȀȎ ǝdzǼǯǹǽ ȁǽ Ȇȁǽ Ȍȁǽȁ ȀȁǷǺȋ ǾǿǴdzǾǽǺǯDzǯǴȁȀȎ dzǺȎ TextBlock ǼǴ ǽǶǼǯȆǯǴȁ Ȇȁǽ DZȀǴ ȌǹǶǴǻǾǺȎǿȊ TextBlock ǰȂdzȂȁ ǷȀǾǽǺȋǶǽDZǯȁȋ ǴDzǽ ǑȊ ǼǴ ǽDzǿǯǼǷȆǴǼȊ ǽdzǼǷǻ ȀȁǷǺǴǻ dzǺȎ ǽdzǼǽDzǽ ȁǷǾǯ Ǒ ȀȁǷǺǴ dzǽǺǵǴǼ ǰȊȁȋ ǶǯdzǯǼ ȁǷǾ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴ ǼǷȎ dzǺȎ ǹǽȁǽǿǽDzǽ ǾǿǴdzǼǯǶǼǯȆǴǼ ȀȁǷǺȋ Ƿ Key ǙǺȍȆ ȀȁǷǺȎ ǡǯǹǷǻ ǽǰǿǯǶǽǻ ǻǽǵǼǽ ǷǻǴȁȋ ǻǼǽǵǴȀȁDZǽ ǿǯǶǼȊȄ ǽǾǷȀǯǼǷǸ ȀȁǷǺǴǸ dzǺȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ TextBlock Ȁ ǿǯǶǼȊǻǷ Key ǡǽDzdzǯ ǶǯdzǯDZǯȎ ȀDZǽǸȀȁDZǽ Style ǠȁǷǺȋ dzǺȎ ǿǯǶǼȊȄ TextBlock DZȊ ǾǿǽȀȁǽ DZȊǰǷǿǯǴȁǴ ȁǽȁ ȀȁǷǺȋ ǹǽȁǽǿȊǸ ǵǴǺǯǴȁǴ ǾǿǷǻǴǼǷȁȋ ǹ ȁǽǻȂ ǷǺǷ ǷǼǽǻȂ TextBlock Ǿǽ ǷǻǴǼǷ Ǭȁǽ ǰȂdzǴȁ ǾǿǽdzǴǻǽǼȀȁǿǷǿǽDZǯǼǽ ȆǴǿǴǶ ǻDzǼǽDZǴǼǷǴ Ǽǽ ȀǼǯȆǯǺǯ ǿǯȀȀǻǽȁ ǿǷǻ ǼǯȀȁǿǽǸǹȂ ȀȁǷǺȎ ȀDZǽǸȀȁDZ TextBlock. Ǭȁǽ DZȊǾǽǺǼȎǴȁȀȎ Ȁ ǾǽǻǽȈȋȍ Setter (ǢȀȁǯǼǽDZȈǷǹ). Setter ² Ȍȁǽ ȁǴDz XAML ǽǾǿǴdzǴǺȎȍȈǷǸ ȀDZǽǸȀȁDZǽ Ƿ ǶǼǯȆǴǼǷǴ ǹǽȁǽǿǽǴ ǼǴǽǰȄǽdzǷǻǽ Ƕǯdzǯȁȋ ȌȁǽǻȂ ȀDZǽǸȀȁDZȂ ǓǯǺǴǴ ǾǿǴdzȀȁǯDZǺǴǼ XAML ǷȀǾǽǺȋǶȂǴǻȊǸ ǿǯǼǴǴ dzǺȎ ǶǯdzǯǼǷȎ ȀDZǽǸȀȁDZ Text, FontFamily, Foreground Ƿ FontSize ȌǺǴǻǴǼȁǯ TextBlock:
Ǘ DZǽȁ ȁǴǾǴǿȋ ȀȁǷǺȋ ǹǽȁǽǿȊǸ dzǴǺǯǴȁ ȁǽ ǵǴ ȀǯǻǽǴ:
ǞǿǷǻǴǼȎǴȁȀȎ Ȍȁǽȁ ȀȁǷǺȋ ǹ TextBlock ǾǽȀǿǴdzȀȁDZǽǻ ȀDZǽǸȀȁDZǯ Style ǞǽȀǹǽǺȋǹȂ ȀȁǷǺȋ ǽǾǿǴdzǴǺǴǼ ǹǯǹ ǿǴȀȂǿȀ dzǺȎ ǶǯdzǯǼǷȎ ǷǻǴǼǷ ȀȁǷǺȎ ǷȀǾǽǺȋǶȂǴȁȀȎ ȀǷǼȁǯǹȀǷȀ Ȁ ǹǺȍȆǴDZȊǻ ȀǺǽDZǽǻ StaticResource ǠȁǯȁǷȆǴȀǹǷǸ ǿǴ ȀȂǿȀ
Ǘ ȁǴǾǴǿȋ DZȀǴ ȀDZǽǸȀȁDZǯ ǾǿǷǻǴǼȎǴǻȊǴ ǹ ȌǺǴǻǴǼȁǯǻ ȂǾǿǯDZǺǴǼǷȎ TextBlock ǹǼǽǾǹǷ ǶǯdzǯȍȁȀȎ DZ ǽdzǼǽǻ ǻǴȀ ȁǴ Ȇȁǽ ǶǼǯȆǷȁǴǺȋǼǽ ȂǾǿǽȈǯǴȁ ǽǰȀǺȂǵǷDZǯǼǷǴ Ƿ dzǴǺǯǴȁ XAML ȂdzǽǰǼȊǻ dzǺȎ DZǽȀǾǿǷȎȁǷȎ Ƿ ǾǽǼǷǻǯǼǷȎ ǚȍǰǽǴ ǷǶ ȀDZǽǸȀȁDZ ǽǾǿǴdzǴǺǴǼǼȊȄ ȀȁǷǺǴǻ ǻǽǵǼǽ ǾǴǿǴǽǾǿǴdzǴǺǷȁȋ ǾǿǽȀȁǽ ǶǯdzǯDZǯȎ ǴDzǽ DZ Ȁǯǻǽǻ ǽǰȉǴǹȁǴ ǜǯǾǿǷǻǴǿ ȁǿǴǰȂǴȁȀȎ ǾǴǿǴǽǾǿǴdzǴǺǷȁȋ ȀDZǽǸȀȁDZǽ Foreground ǶǯdzǯǼǼǽǴ ȀȁǷǺǴǻ MediumBlue (ǠDZǴȁǺǽȀǷǼǷǸ ǠdzǴǺǯȁȋ Ȍȁǽ ǽȆǴǼȋ ǾǿǽȀȁǽ ǹǯǹ ǾǽǹǯǶǯǼǽ DZ ǾǿǷǻǴǿǴ
Ǒ Ȍȁǽǻ ȀǺȂȆǯǴ, ǶǯdzǯǼǼǽǴ ǶdzǴȀȋ ȀDZǽǸȀȁDZǽ Foreground ǾǴǿǴǽǾǿǴdzǴǺȎǴȁ ǼǯȀȁǿǽǸǹȂ ȀȁǷǺȎ, Ƿ ȁǴǾǴǿȋ dzǺȎ ȁǴǹ Ȁȁǯ TextBlock ǰȂdzǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ȆǴǿǼȊǸ ȅDZǴȁ. ǡǯǹǵǴ ǽǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ ȄǽȁȎ ȀȁǷǺȋ DZ dzǯǼǼǽǻ ǾǿǷǻǴǿǴ ǽǾǿǴdzǴǺǴǼ dzǺȎ TextBlock ǿǯȀǾǽǺǯDzǯȍȈǴ DzǽȀȎ DZ ǹǼǽǾǹǴ Ȁ ǷǶǽǰǿǯǵǴǼǷǴǻ ǽǼ ǻǽǵǴȁ ǾǿǷǻǴǼȎȁȋȀȎ ǹ ǺȍǰǽǻȂ TextBlock DZ dzǯǼǼǽǻ Canvas.
ǗǶǻǴǼǴǼǷǴ ǽǰǺǯȀȁǷ dzǴǸȀȁDZǷȎ ȀȁǷǺȎ Ǒ ǾǿǷǻǴǿǴ ǷǶ ǾǿǴdzȊdzȂȈǴDzǽ ǿǯǶdzǴǺǯ ȀȁǷǺȋ ȀǽǶdzǯDZǯǺȀȎ DZ Canvas ȀǽdzǴǿǵǯȈǴǻ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Ǭȁǽ ǽDzǿǯǼǷȆǷDZǯǴȁ ǽǰǺǯȀȁȋ dzǴǸȀȁDZǷȎ ȌȁǽDzǽ ȀȁǷǺȎ dzǯǼǼȊǻ Canvas ǞǽȌȁǽǻȂ ǴȀǺǷ DZ ǾǿǷǺǽǵǴǼǷǷ ǷǻǴǴȁȀȎ ǼǴȀǹǽǺȋǹǽ ȀȁǿǯǼǷȅ ǾǿǷȇǺǽȀȋ ǰȊ ǽǾǿǴdzǴǺȎȁȋ ȀȁǷǺǷ Ǽǯ ǹǯǵdzǽǸ ȀȁǿǯǼǷȅȊ Ȇȁǽ DZǴȀȋǻǯ ǼǴȌȃȃǴǹȁǷDZǼǽ Ǚ ȀȆǯȀȁȋȍ Silverlight ǾǽǶDZǽǺȎǴȁ ǽǾǷȀȊDZǯȁȋ ȀȁǷǺǷ dzǺȎ DZȀǴDzǽ ǾǿǷǺǽǵǴǼǷȎ ǶǯdzǯDZǯȎ ǷȄ DZ App.xaml. Ǒ ȀȁǯǼ dzǯǿȁǼǽǻ ȃǯǸǺǴ App.xaml ȀǽǶdzǯDZǯǴǻǽǻ ȇǯǰǺǽǼǽǻ Visual Studio ȂǵǴ ǽǾǿǴdzǴǺǴǼ ǿǯǶdzǴǺ Resources!
ǒǺǯDZǯ ǠȁǷǺǷ Ƿ ȇǯǰǺǽǼȊ DZ Silverlight 2
243
Ǘȁǯǹ ǿǯǶǻǴȈǴǼǼȊǴ ǶdzǴȀȋ ǽǾǷȀǯǼǷȎ ȀȁǷǺǴǸ ǰȂdzȂȁ dzǽȀȁȂǾǼȊ DZȀǴǻȂ ǾǿǷǺǽǵǴǼǷȍ ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ:
ǞǿǷǻǴǼȎȎ Ȍȁǽȁ ȀȁǷǺȋ ǻǽǵǼǽ ǶǯdzǯDZǯȁȋ ȀȁǷǺȋ ǺȍǰǽDzǽ TextBlock DZ ǾǿǷǺǽǵǴǼǷǷ ǷȀǾǽǺȋǶȂȎ ǽdzǷǼ Ƿ ȁǽȁ ǵǴ ȀǷǼȁǯǹȀǷȀ ǡǽȆǼǽ ȁǯǹ ǵǴ ǻǽǵǼǽ ǾǴǿǴǽǾǿǴdzǴǺǷȁȋ ǺȍǰǽǴ ǷǶ ȀDZǽǸȀȁDZ Style ǶǯdzǯDZǯȎ ǷȄ dzǺȎ ǹǽǼǹǿǴȁǼǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ
ǧǯǰǺǽǼȊ Ǒ ǾǿǴdzȊdzȂȈǴǻ ǿǯǶdzǴǺǴ ǰȊǺǯ ȀǽǶdzǯǼǯ ǹǼǽǾǹǯ Ȁ ǷǶǽǰǿǯǵǴǼǷǴǻ Ƿ ǷȀǾǽǺȋǶǽDZǯǼ ȃǯǹȁ Ȇȁǽ ǹǼǽǾǹǯ ȎDZǺȎǴȁȀȎ ȌǺǴǻǴǼȁǽǻ ȂǾǿǯDZǺǴǼǷȎ Ȁ ȀǽdzǴǿǵǷǻȊǻ Ǭȁǽ ǾǽǶDZǽǺǷǺǽ ȀǽǶdzǯȁȋ ǼǴ ǾǿǽȀȁǽ ǹǼǽǾǹȂ Ȁ ǼǯdzǾǷȀȋȍ ǯ DZǹǺȍ ȆǷȁȋ DZ ǼǴǴ XAML ǽǾǷȀȊDZǯȍȈǷǸ StackPanel Ȁ ǷǶǽǰǿǯǵǴǼǷǴǻ Image Ƿ ȁǴǹȀȁǽDZȊǻ ǰǺǽǹǽǻ TextBlock ǖǯ ȁǴǻ DZȊ ǼǯȂȆǷǺǷȀȋ Ȁ ǾǽǻǽȈȋȍ ȀȁǷǺǴǸ ȌȃȃǴǹȁǷDZǼǽ ǾǿǷǻǴǼȎȁȋ ǴdzǷǼǽǽǰǿǯǶǼȊǴ ǼǯȀȁǿǽǸǹǷ ǹ ȀDZǽǸȀȁDZǯǻ ǼǴȀǹǽǺȋǹǷȄ ȌǺǴǻǴǼȁǽDZ TextBlock. ǠǺǴdzȂȍȈǷǸ ǺǽDzǷȆǴȀǹǷǸ ȇǯDz ² ǽǾǿǴdzǴǺǴǼǷǴ ȀȁǷǺȎ ȀǿǯǶȂ DZȀǴDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ȀǽȀȁǽȎȈǴDzǽ ǷǶ Button Ƿ ǽǰǿǯǶȂȍȈǷȄ ǴDzǽ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ȁǴ StackPanel, Image Ƿ TextBlock Ǒǽȁ DzdzǴ ȇǯǰǺǽǼȊ ȀȁǯǼǽ DZȎȁȀȎ ǽȀǼǽDZǼȊǻǷ ȀǿǴdzȀȁDZǯǻǷ ǼǯȀȁǿǽǸǹǷ DZǼǴȇǼǴDzǽ DZǷdzǯ DZǯȇǷȄ Silverlight-ǾǿǷǺǽǵǴǼǷǸ ǧǯǰǺǽǼȊ dzǴǸȀȁDZȂȍȁ ǯǰȀǽǺȍȁǼǽ ǯǼǯǺǽDzǷȆǼǽ ȀȁǷǺȎǻ ǿǯǶǻǴȈǯȍȁȀȎ DZ ǿǯǶdzǴǺǴ Resources Ƿ ǽǾǷȀȊDZǯȍȁȀȎ Ȁ ǾǽǻǽȈȋȍ Setter ǦȁǽǰȊ ȀǽǶdzǯȁȋ Template ǧǯǰǺǽǼ ǶǯdzǯǴȁȀȎ ȀDZǽǸȀȁDZǽ Template Ƿ ǶǯȁǴǻ Ȁ ǾǽǻǽȈȋȍ ǽǾǿǴdzǴǺȎǴȁȀȎ ControlTemplate dzǺȎ ǶǯdzǯǼǼǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǞǿǽȈǴ DZ Ȍȁǽǻ ǿǯǶǽǰǿǯȁȋȀȎ DZǶDzǺȎǼȂDZ Ǽǯ ǹǽdz:
244
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
ǖdzǴȀȋ ȀǽǶdzǯǴȁȀȎ ȀȁǷǺȋ ImageButton DZ ǹǽȁǽǿǽǻ ǷȀǾǽǺȋǶȂǴȁȀȎ Setter dzǺȎ ȀDZǽǸȀȁDZǯ Template Ǒ ǼǴǻ ȀǽdzǴǿ ǵǷȁȀȎ ControlTemplate ǽǾǷȀȊDZǯȍȈǷǸ Button ǹǽȁǽǿȂȍ ǻȊ DZǷdzǴǺǷ ǿǯǼǴǴ DZǹǺȍȆǯȍȈȂȍ StackPanel Ȁ Image Ƿ TextBlock. ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ ǶdzǴȀȋ ȁǯǹǵǴ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ ȀȀȊǺǹǯ Ǽǯ ȀȁǷǺȋ ǾǽȁǽǻȂ Ȇȁǽ dzǺȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ TextBlock ǷȀǾǽǺȋǶȂǴǻǽDzǽ DZ ȇǯǰǺǽǼǴ ǶǯdzǯǼ ȀǽǶdzǯǼǼȊǸ ǿǯǼǴǴ ȀȁǷǺȋ TextBlockStyle. ǡǴǾǴǿȋ XAML dzǺȎ ǽǰȉȎDZǺǴǼǷȎ ǹǼǽǾǽǹ ȀȁǯǺ ǴȈǴ ǾǿǽȈǴ
ǓǺȎ ǹǯǵdzǽǸ ǹǼǽǾǹǷ DZ ǹǯȆǴȀȁDZǴ ǶǼǯȆǴǼǷȎ Style ǶǯdzǯǼ ǿǴȀȂǿȀ ImageButton ǹǽȁǽǿȊǸ DZ ȀDZǽȍ ǽȆǴǿǴdzȋ ǽǾ ǿǴdzǴǺȎǴȁ ȇǯǰǺǽǼ dzǺȎ DZȀǴDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǜǯ ǿǷȀ 12- ǾǽǹǯǶǯǼ ǿǴǶȂǺȋȁǯȁ DZȊǾǽǺǼǴǼǷȎ ȌȁǽDzǽ XAML.
ǟǗǠ 12 4 ǙǼǽǾǹǷ, ǶǯdzǯǼǼȊǴ ȇǯǰǺǽǼǽǻ.
Ǟǽ-ǼǯȀȁǽȎȈǴǻȂ ǶǯǻǴȆǯȁǴǺȋǼǽǴ ȀDZǽǸȀȁDZǽ ȇǯǰǺǽǼǽDZ DZ ȁǽǻ Ȇȁǽ DZ ȇǯǰǺǽǼǴ ǼǴ ǽǰȎǶǯȁǴǺȋǼǽ ǾǿǷȀȂȁȀȁDZǷǴ ȁǷǾǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ȇǯǰǺǽǼ ǹǽȁǽǿǽDzǽ ȀǽǶdzǯǴȁȀȎ ǑǴǿǽȎȁǼǽ ǶDZȂȆǷȁ ǼǴǻǼǽDzǽ ǶǯǾȂȁǯǼǼǽ ǾǽȌȁǽǻȂ ǿǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ ȆȁǽǰȊ ǿǯǶǽǰǿǯȁȋȀȎ DZǽ DZȀǴǻ ǑȊȇǴ DZ Ȍȁǽǻ ǿǯǶdzǴǺǴ ǰȊǺ ǽǾǿǴdzǴǺǴǼ ȇǯǰǺǽǼ dzǺȎ ǹǼǽǾǹǷ Ȁ ȀǽdzǴǿǵǷǻȊǻ ǹǽȁǽǿǽǴ dzǴǺǯǴȁ ǴǴ ǾǿǽȀȁǽǸ ǹǼǽǾǹǽǸ Ȁ ǷǶǽǰǿǯǵǴǼǷǴǻ ǜǽ ȆȁǽǰȊ ȀǽǶdzǯȁȋ ȇǯǰ ǺǽǼ ǹǼǽǾǹǷ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Button Ǿǽ ȀȂȁǷ ǼǴ ǼȂǵǴǼ ǛǽǵǼǽ ǰǴǶ ȁǿȂdzǯ ȀǽǶdzǯȁȋ ǹǼǽǾǹǷ Ȁ ǷǶǽǰǿǯ ǵǴǼǷǴǻ Ƿ ȁǴǹȀȁǽǻ ǼǴ ǰǴǿȎ Ƕǯ ǽȀǼǽDZȂ ȀȁǯǼdzǯǿȁǼȊǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Button ǟǯȀȀǻǽȁǿǷǻ ȇǯǰǺǽǼ:
ǒǺǯDZǯ ǠȁǷǺǷ Ƿ ȇǯǰǺǽǼȊ DZ Silverlight 2
245
ǡǯǹǷǻ ǽǰǿǯǶǽǻ ǻȊ ǾǽǺȂȆǷǺǷ ȇǯǰǺǽǼ ǶǯdzǯǼǼȊǸ Ȁ ǾǽǻǽȈȋȍ TargetType DZǽǽǰȈǴ ǰǴǶ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZ ǺǴǼǷȎ Button Ǽǽ Silverlight ǰȂdzǴȁ ǷǼȁǴǿǾǿǴȁǷǿǽDZǯȁȋ ǴDzǽ ǹǯǹ ǹǼǽǾǹȂ DZǹǺȍȆǯȎ DZȀǴ ȀǽǽȁDZǴȁȀȁDZȂȍȈǷǴ ȀDZǽǸȀȁDZǯ Ƿ ȀǽǰȊȁǷȎ ǜǯǾǿǷǻǴǿ ǴȀǺǷ ǾǿǷǻǴǼǷȁȋ Ȍȁǽȁ ȇǯǰǺǽǼ ǰǴȀǹǼǽǾǽȆǼȊǸ ǾǿǷ DZȊǾǽǺǼǴǼǷǷ ǾǿǷǺǽ ǵǴǼǷȎ Ǽǯ ȌǹǿǯǼǴ ǻǽǵǼǽ ǰȂdzǴȁ ȂDZǷdzǴȁȋ ǾǿǷǻǴǿǼǽ ȀǺǴdzȂȍȈǴǴ ǿǷȀ 12-5).
ǟǗǠ 12 5 ǐǴȀǹǼǽǾǽȆǼȊǴ ȇǯǰǺǽǼȊ dzǺȎ ǹǼǽǾǹǷ.
ǢǰǴdzǷȁȋȀȎ DZ ȁǽǻ Ȇȁǽ Ȍȁǽ ǼǯȀȁǽȎȈǷǴ ǹǼǽǾǹǷ ǻǽǵǼǽ ǾǽǾǿǽǰǽDZǯDZ ǼǯǾǷȀǯȁȋ ǹǽdz dzǺȎ ǼǷȄ ǜǯǾǿǷǻǴǿ ǽǼǷ ǷǻǴȍȁ ǾǽǺǼȂȍ ǾǽdzdzǴǿǵǹȂ IntelliSense ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Button DZ Microsoft Visual Studio Ǭȁǽ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 12- DzdzǴ ǾǿǴdzȀȁǯDZǺǴǼǽ ǼǯǾǷȀǯǼǷǴ ǹǽdzǯ dzǺȎ ȀǽǰȊȁǷȎ Click.
ǟǗǠ 12 6 ǜǯǾǷȀǯǼǷǴ ǹǽdzǯ dzǺȎ ǹǼǽǾǹǷ ȀǽǶdzǯDZǯǴǻǽǸ Ǿǽ ȇǯǰǺǽǼȂ.
ǞǽȀǹǽǺȋǹȂ ȇǯǰǺǽǼȊ ² Ȍȁǽ ǾǿǽȀȁǽ ǽȀǽǰȊǴ ȀȁǷǺǷ ǷȄ ȁǽǵǴ ǻǽǵǼǽ ǽǾǷȀȊDZǯȁȋ DZ App.xaml ȆȁǽǰȊ ȀdzǴǺǯȁȋ dzǽȀȁȂǾǼȊǻǷ dzǺȎ ǾǿǷǻǴǼǴǼǷȎ Ǽǯ ǻǼǽDzǷȄ ȀȁǿǯǼǷȅǯȄ XAML
ǖǯǹǺȍȆǴǼǷǴ Ǒ dzǯǼǼǽǸ DzǺǯDZǴ ǻȊ ǾǽǶǼǯǹǽǻǷǺǷȀȋ Ȁǽ ȀȁǷǺȎǻǷ Ƿ ȇǯǰǺǽǼǯǻǷ Ǭȁǽ ǽȆǴǼȋ DZǯǵǼȊǴ DZǽǶǻǽǵǼǽȀȁǷ Silverlight ǾǽȁǽǻȂ Ȇȁǽ ǽǼǷ ǾǽǶDZǽǺȎȍȁ ȂǼǷȃǷȅǷǿǽDZǯȁȋ Ƿ ǼǯȀȁǿǯǷDZǯȁȋ DZǼǴȇǼǷǸ DZǷdz Ƿ ǾǽDZǴdzǴǼǷǴ DZȀǴȄ ȀǽǶdzǯDZǯǴǻȊȄ DZǯǻǷ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ ǑȊ ǼǯȂȆǷǺǷȀȋ ǽǰȉȎDZǺȎȁȋ ȀȁǷǺȋ Ƿ ǷȀǾǽǺȋǶǽDZǯȁȋ ǴDzǽ ǹǯǹ ȀȁǯȁǷ ȆǴȀǹǷǸ ǿǴȀȂǿȀ StaticResource ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǖǯȁǴǻ ǰȊǺǽ ǾǽǹǯǶǯǼǽ ǹǯǹ ǷȀǾǽǺȋǶǽDZǯȁȋ ȀȁǷǺȋ DZǽ DZȀǴǻ ǾǿǷǺǽǵǴǼǷǷ ǶǯdzǯDZǯȎ ǴDzǽ DZ App.xaml. ǜǯǹǽǼǴȅ DZȊ ȂDZǷdzǴǺǷ ǹǯǹ Ȍȁǯ DZǽǶǻǽǵǼǽȀȁȋ ǻǽǵǴȁ ǰȊȁȋ ǿǯȀȇǷǿǴǼǯ Ȁ ǾǽǻǽȈȋȍ ȇǯǰǺǽǼǽDZ ǧǯǰǺǽǼȊ ǯǼǯǺǽDzǷȆǼȊ ȀȁǷǺȎǻ Ǽǽ ǾǽǶDZǽǺȎȍȁ ǽǾǷȀǯȁȋ ȀȁǷǺȋ DZȀǴDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǐȊǺ ǾǿǽdzǴǻǽǼȀȁǿǷǿǽDZǯǼ ImageButton ȀǽǶdzǯǼǼȊǸ ǰǴǶ ǷȀǾǽǺȋǶǽDZǯǼǷȎ Button Ǽǽ DZȀǴ ǿǯDZǼǽ ǽǰǺǯdzǯȍȈǷǸ DZȀǴǻǷ ȀDZǽǸȀȁDZǯǻǷ ǻǴȁǽ dzǯǻǷ Ƿ ȀǽǰȊȁǷȎǻǷ Button ǰǺǯDzǽdzǯǿȎ ǽǰȉȎDZǺǴǼǷȍ ControlTemplate dzǺȎ ǼǴDzǽ. Ǒ ȀǺǴdzȂȍȈǴǸ DzǺǯDZǴ ǰȂdzǴȁ ǾǿǴdzȀȁǯDZǺǴǼ ǴȈǴ ǽdzǷǼ ǯȀǾǴǹȁ Silverlight 2 Ƿ ǰǽǺǴǴ ǾǽdzǿǽǰǼǽ ǿǯȀȀǻǽȁǿǴǼȊ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ASP.NET ǾǿǴdzǺǯDzǯǴǻȊǴ DZ Silverlight SDK.
ǒǺǯDZǯ 13
ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight DZ ASP.NET Software Development Kit (SDK) dzǺȎ Silverlight 2 DZǹǺȍȆǯǴȁ dzDZǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ASP.NET ǹǽȁǽǿȊǴ ǻǽDzȂȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ǾǽȀȁǯDZǹǷ Silverlight-ǾǿǷǺǽǵǴǼǷǸ DZ ASP.NET ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ Silverlight ǻǽǵǼǽ ǷȀǾǽǺȋǶǽDZǯȁȋ DZ ASP.NET Ƿ ǰǴǶ ȌȁǷȄ ȌǺǴǻǴǼȁǽDZ ȂǾǿǯDZǺǴǼǷȎ Ǽǽ ǼǴȀǽǻǼǴǼǼǽ ǽǼǷ ǼǯǻǼǽDzǽ ȂǾǿǽȈǯȍȁ ǶǯdzǯȆȂ Ǿǽ ȂǾǿǯDZǺǴǼǷȍ Ƿ dzǽȀȁǯDZǹǴ Silverlight-ȀǽdzǴǿǵǷǻǽDzǽ ǜǯȆǼǴǻ Ȁ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǝǼ ǽǰǴȀǾǴȆǷDZǯǴȁ DZǽǶǻǽǵǼǽȀȁȋ ǷȀǾǽǺȋǶǽDZǯȁȋ ǽǰȉȎDZǺǴǼǷǴ ASP.NET Ǽǯ ȀǴǿDZǴǿǴ Ȇȁǽ ȀǽǶdzǯȀȁ ǼǴǽǰȄǽdzǷǻȊǴ ȁǴDzǷ Ƿ DZ ǰǿǯȂǶǴǿǴ ǾǽǶDZǽǺȎȎ ǷȀ ǾǽǺȋǶǽDZǯȁȋ ǾǯǿǯdzǷDzǻȂ ǽǰǿǯǰǽȁǹǷ Ǽǯ ȀȁǽǿǽǼǴ ȀǴǿDZǴǿǯ Ȅǽǿǽȇǽ ǶǼǯǹǽǻȂȍ ǿǯǶǿǯǰǽȁȆǷǹǯǻ ASP.NET. ǑȁǽǿǽǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ² MediaPlayer ǹǽȁǽǿȊǸ ȁǽǵǴ ǽǰǴȀǾǴȆǷDZǯǴȁ ǻǽdzǴǺȋ ǽǰȉȎDZǺǴǼǷȎ ASP.NET, Ǽǽ ǾǽȀȁǯDZǺȎǴȁ ǼǴ ȂǼǷDZǴǿȀǯǺȋǼȊǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǯ ǾǿǷǺǽǵǴǼǷǴ Silverlight-ǻǴdzǷǯǾǺǴǴǿǯ Ȁǽ DZȀǴǻǷ ǴDzǽ ȌǺǴǻǴǼȁǯǻǷ ȂǾǿǯDZǺǴǼǷȎ Ƿ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁȋȍ Ǒ dzǯǼǼǽǸ DzǺǯDZǴ ǻȊ ǿǯȀȀǻǽȁǿǷǻ ǽǰǯ ȌȁǷȄ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Ƿ ȀDZǽǸȀȁDZǯ ǻǴȁǽdzȊ Ƿ ȀǽǰȊȁǷȎ ǹǽȁǽǿȊǴ ǽǼǷ ǾǿǴdzǺǯDzǯȍȁ ǿǯǶǿǯǰǽȁȆǷǹǯǻ ǞǽdzȀǹǯǶǹǯ ǞǿǴǵdzǴ ȆǴǻ ǷȀǾǽǺȋǶǽDZǯȁȋ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ ASP.NET Silverlight DZ ȀDZǽǴǸ ǑǴǰ-ȃǽǿǻǴ ǼǴǽǰ ȄǽdzǷǻǽ ǶǯǿǴDzǷȀȁǿǷǿǽDZǯȁȋ ȀǰǽǿǹȂ DZ ǹǽȁǽǿȂȍ ǽǼǷ DZȄǽdzȎȁ ǝǰȊȆǼǽ dzǺȎ ȌȁǽDzǽ ǷȀǾǽǺȋǶȂǴȁȀȎ ȀǺǴdzȂȍȈǷǸ ǹǽdz DZ ǼǯȆǯǺǴ ǿǯǶǻǴȁǹǷ ȀȁǿǯǼǷȅȊ:
ǠǴǿDZǴǿǼȊǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǼǯȄǽdzǷȁȀȎ DZ ǾǿǽȀȁǿǯǼȀȁDZǴ ǷǻǴǼ System.Web.UI.SilverlightControls.Silverlight. ǖǯǻǴȁȋȁǴ, ȆȁǽǰȊ ǷȀǾǽǺȋǶǽDZǯȁȋ ǴDzǽ Ǽǯ ȀȁǿǯǼǷȅǴ, Ǽǯ ǼǴǸ dzǽǺǵǴǼ ǾǿǷȀȂȁȀȁDZǽDZǯȁȋ ScriptManager. ǞǿǷ ȀǽǶdzǯǼǷǷ Silverlight-ǾǿǷǺǽǵǴǼǷȎ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ȇǯǰǺǽǼǯ Microsoft Visual Studio ȁǯǹǵǴ ȀǽǶdzǯǴȁ ȀȎ ȀȁǿǯǼǷȅǯ ASPX dzǺȎ ǿǯǶǻǴȈǴǼǷȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ASP.NET Silverlight. ǡǴDz dzǽǺǵǴǼ DZȊDzǺȎdzǴȁȋ ǾǿǷ ǻǴǿǼǽ ȁǯǹ:
Ǚǯǹ DZǷdzǷȁǴ ǷȀǾǽǺȋǶȂǴȁȀȎ ǽǰȊȆǼȊǸ ȀǷǼȁǯǹȀǷȀ ASP.NET ȁǴ ȀDZǽǸȀȁDZǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ǶǯdzǯȍȁȀȎ Ǿǽ ȀǿǴdzȀȁDZǽǻ ǯȁǿǷǰȂȁǽDZ XML.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀȆǴȁȆǷǹǯ ȆǯȀȁǽȁȊ ǹǯdzǿǽDZ ǏȁǿǷǰȂȁ EnableFrameRateCounter ǾǽǶDZǽǺȎǴȁ DZǷdzǴȁȋ ȆǯȀȁǽȁȂ ǹǯdzǿǽDZ ǽǰǴȀǾǴȆǷDZǯǴǻȂȍ DZ ǼǯȀȁǽȎȈǷǸ ǻǽ ǻǴǼȁ Silverlight ǡǯǹ ǽȆǴǼȋ ȂdzǽǰǼǽ ǹǽǼȁǿǽǺǷǿǽDZǯȁȋ ǾǿǽǷǶDZǽdzǷȁǴǺȋǼǽȀȁȋ ǾǿǷǺǽǵǴǼǷȎ ǽȀǽǰǴǼǼǽ ǾǿǷ DZȊǾǽǺǼǴǼǷǷ ǰǽǺȋȇǽDzǽ ǹǽǺǷȆǴȀȁDZǯ ǯǼǷǻǯȅǷǸ ǜǯǾǿǷǻǴǿ, ǿǯȀȀǻǽȁǿǷǻ ȀǺǴdzȂȍȈǴǴ ǾǿǷǺǽǵǴǼǷǴ XAML. Ǒ ǼǴǻ DZȊǾǽǺǼȎǴȁȀȎ ǯǼǷǻǯȅǷȎ ǺǷǼǷǷ: ǴǴ ǿǯǶDZǽ ǿǽȁ Ǽǯ 360 DzǿǯdzȂȀǽDZ:
ǓǺȎ Button ǽǾǷȀǯǼǽ ȀǽǰȊȁǷǴ Click. Ǚǽdz ǽǰǿǯǰǽȁǹǷ ȀǽǰȊȁǷȎ Click ǾǿǽȀȁǽ ǶǯǾȂȀǹǯǴȁ ǯǼǷǻǯȅǷȍ Storyboard: private void btnStart Click(object sender, RoutedEventArgs e) { Storyboard1.Begin(); }
ǦȁǽǰȊ ȂDZǷdzǴȁȋ ȆǯȀȁǽȁȂ ǹǯdzǿǽDZ ǯǹȁǷDZǷǿȂǸȁǴ ȀȆǴȁȆǷǹ ȆǯȀȁǽȁȊ ǹǯdzǿǽDZ DZ ȌǺǴǻǴǼȁǴ ȂǾǿǯDZǺǴǼǷȎ ASP.NET Silverlight:
ǞǿǷ DZȊǾǽǺǼǴǼǷǷ ǾǿǷǺǽǵǴǼǷȎ Ǿǽ ǼǯǵǯȁǷȍ ǹǼǽǾǹǷ ǶǯǾȂȀǹǯǴȁȀȎ ǯǼǷǻǯȅǷȎ ǞǿǷ Ȍȁǽǻ DZ ȀȁǿǽǹǴ ȀǽȀȁǽȎǼǷȎ ǰǿǯȂǶǴǿǯ ǰȂdzǴȁ ǽȁǽǰǿǯǵǯȁȋȀȎ ȆǯȀȁǽȁǯ ǹǯdzǿǽDZ Ǭȁǽ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 13-1.
248
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2 ǟǗǠ 13 1 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȆǯȀȁǽȁȊ ǹǯdzǿǽDZ dzǺȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight.
ǟǴǹǽǻǴǼdzȂǴȁȀȎ ǷȀǾǽǺȋǶǽDZǯȁȋ ȌȁȂ DZǽǶǻǽǵǼǽȀȁȋ ȁǽǺȋǹǽ DZǽ DZǿǴǻȎ ǽȁǺǯdzǹǷ ǽȁǹǺȍȆǷȁǴ ǴǴ dzǺȎ ǿǯǰǽȆǷȄ ǾǿǷǺǽǵǴǼǷǸ.
ǖǯdzǯǼǷǴ ǻǯǹȀǷǻǯǺȋǼǽǸ ȆǯȀȁǽȁȊ ǹǯdzǿǽDZ Ǟǽ ȂǻǽǺȆǯǼǷȍ ȆǯȀȁǽȁǯ ȀǻǴǼȊ ǹǯdzǿǽDZ DZ Silverlight ȀǽȀȁǯDZǺȎǴȁ ǹǯdzǿǽDZ DZ ȀǴǹȂǼdzȂ Ǭȁǽ ǽǶǼǯȆǯǴȁ Ȇȁǽ DZȀǴ ǯǼǷǻǯȅǷǷ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ DZǿǴǻǴǼǼǽǸ ȇǹǯǺȊ ǿǯǶdzǴǺȎȍȁȀȎ Ǽǯ ǾǿǷǿǯȈǴǼǷȎ ȀDZǽǸȀȁDZ ȁǯǹ Ȇȁǽ ȀDZǽǸȀȁDZǽ ǻǴǼȎǴȁȀȎ ǿǯǶ DZ ȀǴǹȂǼdzȂ ǜǯǾǿǷǻǴǿ ȆȁǽǰȊ ǿǯǶDZǴǿǼȂȁȋ ǺǷǼǷȍ Ǽǯ DzǿǯdzȂȀǽDZ Ƕǯ ȀǴǹȂǼdzȂ ǯǼǷǻǯȅǷȎ ǰȊǺǯ ǰȊ ǿǯǶdzǴǺǴǼǯ Ǽǯ ǿǯDZǼȊȄ ǽǾǴǿǯȅǷǸ ǹǯǵdzǯȎ ǷǶ ǹǽȁǽǿȊȄ ǽȀȂȈǴȀȁDZǺȎǺǯ ǰȊ ǿǯǶDZǽǿǽȁ Ǽǯ DzǿǯdzȂ ȀǽDZ Ǭȁǽ ǻǽǵǴȁ ȀǽǶdzǯDZǯȁȋ ǰǽǺȋȇȂȍ DZȊȆǷȀǺǷȁǴǺȋǼȂȍ ǼǯDzǿȂǶǹȂ ǾǽȌȁǽǻȂ ǽǰȈȂȍ ǾǿǽǷǶDZǽdzǷȁǴǺȋǼǽȀȁȋ ǻǽǵǼǽ ǾǽDZȊȀǷȁȋ ȀǼǷǶǷDZ ȆǯȀȁǽȁȂ ǹǯdzǿǽDZ ǷǺǷ Ǽǯǽǰǽǿǽȁ ǴȀǺǷ ǾǿǽǷǶDZǽdzǷȁǴǺȋǼǽȀȁȋ ǼǴ ǾǿǽǰǺǴǻǯ Ƿ ǼǴǽǰ ȄǽdzǷǻǽ ǾǽDZȊȀǷȁȋ ǾǺǯDZǼǽȀȁȋ ǯǼǷǻǯȅǷǷ ǾǿǷǺǽǵǴǼǷȎ ǻǽǵǼǽ ȂDZǴǺǷȆǷȁȋ ȆǯȀȁǽȁȂ ǹǯdzǿǽDZ ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ DZ ǹǽȁǽǿǽǻ ǾǽǹǯǶǯǼǽ ǹǯǹ ǷǶǻǴǼǷȁȋ ȆǯȀȁǽȁȂ ǹǯdzǿǽDZ dzǽ ǹǯdzǿǽDZ DZ ȀǴǹȂǼdzȂ
ǔȀǺǷ DZȊǾǽǺǼǷȁȋ ǽǰȀȂǵdzǯǴǻȂȍ ǿǯǼǴǴ ǯǼǷǻǯȅǷȍ Ȁ DZǿǯȈǴǼǷǴǻ DZȊ ǶǯǻǴȁǷȁǴ Ȇȁǽ dzDZǷǵǴǼǷǴ ǺǷǼǷǷ ȀȁǯǺǽ ǼǴ ȁǯǹǷǻ ǾǺǯDZǼȊǻ ǹǯǹ ǿǯǼǴǴ ǡǯǹǵǴ ǾǽǹǯǶǯǼǷȎ ȆǯȀȁǽȁȊ ǹǽǺǷȆǴȀȁDZǽ ǹǯdzǿǽDZ DZ ȀǴǹȂǼdzȂ frames per second, fps ǽǾȂȀȁǷǺǷȀȋ dzǽ ǽȁǻǴȁǹǷ ǹǯdzǿǽDZ DZ ȀǴǹȂǼdzȂ ǿǷȀ 13-2).
ǟǗǠ 13 2 ǠǽǹǿǯȈǴǼǷǴ ȆǯȀȁǽȁȊ ǹǯdzǿǽDZ.
ǝǰǴȀǾǴȆǴǼǷǴ dzǽȀȁȂǾǯ ǹ HTML Ǡ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ EnableHtmlAccess ǻǽǵǼǽ ǾǽǺȂȆǷȁȋ ǷǺǷ Ƕǯdzǯȁȋ dzǺȎ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight dzǽȀȁȂǾ ǹ DOM HTML Ǟǽ ȂǻǽǺȆǯǼǷȍ Ȍȁǽ ȀDZǽǸȀȁDZǽ ǷǻǴǴȁ ǶǼǯȆǴǼǷǴ true Ȇȁǽ ǯǹȁǷDZǷǿȂǴȁ dzǽȀȁȂǾ ǹ DOM. ǓǺȎ ǿǯǰǽȁȊ Ȁ DOM ǰǿǯȂǶǴǿǯ DZ ǾǿǷǺǽǵǴǼǷǷ ǷȀǾǽǺȋǶȂǴȁȀȎ ǾǿǽȀȁǿǯǼȀȁDZǽ ǷǻǴǼ System.Windows.Browser. Ǭȁǽ ǽǰǴȀǾǴȆǷDZǯǴȁ DZǯǻ dzǽȀȁȂǾ ǹ ǹǺǯȀȀǯǻ ȁǯǹǷǻ ǹǯǹ HtmlPage ǷȀǾǽǺȋǶȂǴǻȊǻ dzǺȎ ǶǯǾǿǽȀǯ ǻǴȁǯdzǯǼǼȊȄ ȀȁǿǯǼǷȅȊ Ǽǯ ǹǽȁǽǿǽǸ ǿǯȀǾǽǺǯDzǯǴȁȀȎ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǯ ȁǯǹǵǴ DZǽǶǻǽǵǼǽȀȁȋ ǾǽǷȀǹǯ ǽǾǿǴ dzǴǺǴǼǼǽDzǽ ȌǺǴǻǴǼȁǯ DZ dzǽǹȂǻǴǼȁǴ ǬǺǴǻǴǼȁȊ HTML ǻǽDzȂȁ ǰȊȁȋ ǾǿǴdzȀȁǯDZǺǴǼȊ DZ .NET ǹǺǯȀȀǽǻ HtmlElement (HTML-ȌǺǴǻǴǼȁ). ǜǯǾǿǷǻǴǿ ǴȀǺǷ DZ HTML ǷǻǴǴȁȀȎ ȌǺǴǻǴǼȁ Ǿǽdz ǷǻǴǼǴǻ testDiv ǹ ǼǴǻȂ ǻǽǵǼǽ ǽǰǿǯȈǯȁȋȀȎ Ƿ ǷǶ ǻǴǼȎȁȋ ǷǶ ǹǽdzǯ Silverlight ȀǺǴdzȂȍȈǷǻ ǽǰǿǯǶǽǻ HtmlElement testDiv = HtmlPage.Document.GetElementById("testDiv"); testDiv.SetAttribute("innerText", "This is the testDiv");
ǝȆǴǼȋ ǾǽǺǴǶǼȊǸ ǹǺǯȀȀ ² HtmlPage.BrowserInformation, ǽǼ ǾǿǴdzǽȀȁǯDZǺȎǴȁ ǻǴȁǯdzǯǼǼȊǴ, ȁǯǹǷǴ ǹǯǹ Browser Version (ǑǴǿȀǷȎ ǰǿǯȂǶǴǿǯ), Sub Version (ǓǽǾǽǺǼǷȁǴǺȋǼǯȎ DZǴǿȀǷȎ), Name (ǗǻȎ), Platform (ǞǺǯȁȃǽǿǻǯ), User Agent (ǏDzǴǼȁ ǾǽǺȋǶǽDZǯȁǴǺȎ) Ƿ DZǹǺȍȆǴǼǯ ǾǽdzdzǴǿǵǹǯ cookie ǷǺǷ ǼǴȁ. Ǒǽȁ ǾǿǷǻǴǿ ǴDzǽ ȀǽdzǴǿǵǷǻǽDzǽ DZǽ DZǿǴǻȎ DZȊǾǽǺǼǴǼǷȎ:
ǒǺǯDZǯ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight DZ $63NET
249
? HtmlPage.BrowserInformation {System.Windows.Browser.BrowserInformation} BrowserVersion: {4.0} CookiesEnabled: true Name: "Microsoft Internet Explorer" Platform: "Win32" UserAgent: "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; InfoPath.2; .NET CLR 3.5.21022; MS-RTC LM 8)" ? HtmlPage.BrowserInformation.BrowserVersion {4.0} Build: -1 Major: 4 Minor: 0 Revision: -1
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǾǴǿǴǿǷȀǽDZȊDZǯǴǻȊȄ ǽǰǺǯȀȁǴǸ ǓǿȂDzǽǸ ǼǯDzǺȎdzǼȊǸ ǾǿǷǻǴǿ, ǹǽȁǽǿȊǸ ǾǽǻǽǵǴȁ ǾǽǼȎȁȋ ǿǯǰǽȁȂ ǾǿǷǺǽǵǴǼǷȎ Silverlight, ² ǹǽǼȅǴǾȅǷȎ ǾǴǿǴ ǿǷȀǽDZȊDZǯǴǻǽǸ ǽǰǺǯȀȁǷ (Redraw Region). Ǭȁǽ DZǷǶȂǯǺȋǼȊǸ ǷǼdzǷǹǯȁǽǿ ȂǹǯǶȊDZǯȍȈǷǸ Ǽǯ ȆǯȀȁǷ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǹǽȁǽǿȊǴ ǾǴǿǴǿǷȀǽDZȊDZǯȍȁȀȎ Ǡ ǾǽǻǽȈȋȍ ǯȁǿǷǰȂȁǯ EnableRedrawRegions ǶǯdzǯDZǯȎ ǴǻȂ ǶǼǯȆǴǼǷǴ true DZǻǴȀȁǽ ǷȀǾǽǺȋǶȂǴǻǽDzǽ Ǿǽ ȂǻǽǺȆǯǼǷȍ false ǻǽǵǼǽ DZǹǺȍȆǷȁȋ ȌȁǷ ǻǯǿǹǴǿȊ Ǘȁǯǹ ǴȀǺǷ DZǴǿǼȂȁȋȀȎ ǹ ǾǿǷǻǴǿȂ Ȁ DZǿǯȈǯȍȈǴǸȀȎ ǺǷǼǷǴǸ Ƿ ǷǶǻǴǼǷȁȋ ǿǯǶǻǴȁǹȂ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ASP.NET ǹǯǹ ǾǽǹǯǶǯǼǽ DZ ȀǺǴdzȂȍȈǴǻ ǹǽdzǴ ǷǼdzǷǹǯȅǷȎ ǾǴǿǴǿǷȀǽDZȊDZǯǴǻȊȄ ǽǰǺǯȀȁǴǸ ǰȂdzǴȁ DZǹǺȍȆǴǼǯ
ǜǯ ǿǷȀ 13-3 ǾǽǹǯǶǯǼ ȀǽǶdzǯDZǯǴǻȊǸ ȌȁǷǻ ǹǽdzǽǻ ȌȃȃǴǹȁ; ǾǴǿǴǿǷȀǽDZȊDZǯǴǻȊǴ ǽǰǺǯȀȁǷ DZȊdzǴǺǴǼȊ.
ǟǗǠ 13 3 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǾǴǿǴǿǷȀǽDZȊDZǯǴǻȊȄ ǽǰǺǯȀȁǴǸ.
Ǚǯǹ Ƿ Ȁ ȆǯȀȁǽȁǽǸ ǹǯdzǿǽDZ ȌȁȂ DZǽǶǻǽǵǼǽȀȁȋ ǿǴǹǽǻǴǼdzȂǴȁȀȎ ǷȀǾǽǺȋǶǽDZǯȁȋ ȁǽǺȋǹǽ dzǺȎ ǽȁǺǯdzǹǷ ǾǿǷǺǽǵǴ ǼǷǸ Ƿ DZȊǹǺȍȆǯȁȋ ǾǿǷ ǾǴǿǴȄǽdzǴ ǹ ǾǿǽǷǶDZǽdzȀȁDZǴǼǼǽǸ ȌǹȀǾǺȂǯȁǯȅǷǷ.
ǖǯdzǯǼǷǴ ȀDZǽǸȀȁDZǯ PluginBackground Ǡ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ PluginBackground ǣǽǼ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ ǻǽǵǼǽ ǶǯdzǯDZǯȁȋ ȅDZǴȁ ȃǽǼǯ Ǿǽdz ǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ ǑȀǾǽǻǼǷǻ Ȇȁǽ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ASP.NET DZȊǾǽǺǼȎǴȁȀȎ Ǽǯ ȀǴǿDZǴǿǴ Ƿ ȃǽǿǻǷǿȂǴȁ ǿǯǶǻǴȁǹȂ Ȇȁǽ ǾǽǶDZǽǺȎǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋ ȀDZǽǸȀȁDZǯ System.Color DZǹǺȍȆǯȎ ǼǴǹǽȁǽǿȊǴ ȀǷȀȁǴǻǼȊǴ ȅDZǴȁǯ ȁǯ ǹǷǴ ǹǯǹ Window ǷǺǷ ActiveBorder Ƿ ȁǯǹǵǴ ǷǻǴǼǽDZǯǼǼȊǴ ȀǷȀȁǴǻǼȊǴ ȅDZǴȁǯ Ǚǯǹ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 13-4, Visual Studio IntelliSense ǾǽǶDZǽǺȎǴȁ DZȊǰǷǿǯȁȋ ȀǷȀȁǴǻǼȊǴ Ƿ ǷǻǴǼǽDZǯǼ ǼȊǴ ȅDZǴȁǯ dzǺȎ ȃǽǼǯ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ
250
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
ǟǗǠ 13 4 ǖǯdzǯǼǷǴ ȅDZǴȁǯ ȃǽǼǯ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ.
ǜǯ ǿǷȀ 13- ǾǽǹǯǶǯǼǽ ǹǯǹ ǰȂdzǴȁ DZȊDzǺȎdzǴȁȋ ȀǽdzǴǿǵǷǻǽǴ Silverlight ǹǽDzdzǯ ȀDZǽǸȀȁDZȂ PluginBackground Ƕǯ dzǯǼǽ ǶǼǯȆǴǼǷǴ WindowFrame ǖǯǻǴȁȋȁǴ Ȇȁǽ DZǯǻ ǾǿǷdzǴȁȀȎ ǷǶǻǴǼǷȁȋ ȃǽǼ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Grid DZ XAML ǷǺǷ ǽǼ ǾǴǿǴǽǾǿǴdzǴǺǷȁ Ȍȁǽ ǶǼǯȆǴǼǷǴ ǔȀǺǷ DZȊ ȄǽȁǷȁǴ ȆȁǽǰȊ ȅDZǴȁ ȃǽǼǯ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ ǿǯȀǾǿǽȀȁǿǯǼȎǺȀȎ Ǽǯ DZȀǴ ȌǺǴǻǴǼȁȊ ǻǽǵǼǽ ǾǿǽȀȁǽ ȂdzǯǺǷȁȋ Ȍȁǽ ȀDZǽǸȀȁDZǽ DZ dzǿȂDzǷȄ ȌǺǴǻǴǼȁǯȄ.
ǟǗǠ 13 5 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȀǷȀȁǴǻǼǽDzǽ ȅDZǴȁǯ DZ ǹǯȆǴȀȁDZǴ ȅDZǴȁǯ ȃǽǼǯ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ.
ǔȀǺǷ ȀǴǸȆǯȀ DZǶDzǺȎǼȂȁȋ Ǽǯ ǷȀȄǽdzǼȊǸ ǹǽdz ȀȁǿǯǼǷȅȊ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ȇȁǽ ǶǼǯȆǴǼǷǴ ǾǯǿǯǻǴȁǿǯ Background ǽǰȉǴǹȁǯ Grid Ȁ ǷǻǴǼǴǻ LayoutRoot ǵǴȀȁǹǽ ǶǯdzǯǼǽ DZ ǹǽdzǴ Ǒ ǾǿǷǻǴǿǴ ǾǿǴdzȀȁǯDZǺǴǼǼǽǻ Ǽǯ ǿǷȀ 13- dzǺȎ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ ǶǯdzǯǼ ȅDZǴȁ ȃǽǼǯ #FF646464.
ǢǾǿǯDZǺǴǼǷǴ ȂȀȁǯǼǽDZǹǽǸ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ ǔȀǺǷ DZ ȀǷȀȁǴǻǴ ǹǺǷǴǼȁǯ ǼǴ ȂȀȁǯǼǽDZǺǴǼ Silverlight ǾǿǷ ǾǴǿǴȄǽdzǴ Ǽǯ ȀȁǿǯǼǷȅȂ DZǹǺȍȆǯȍȈȂȍ ȀǽdzǴǿǵǷǻǽǴ Silverlight ǾǽǺȋǶǽDZǯȁǴǺȋ ȂDZǷdzǷȁ ȀȁǯǼdzǯǿȁǼȊǸ ǶǼǯȆǽǹ ȂȀȁǯǼǽDZǹǷ Silverlight ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 13-6.
ǟǗǠ 13 6 ǠȁǯǼdzǯǿȁǼȊǸ ǶǼǯȆǽǹ ȂȀȁǯǼǽDZǹǷ.
ǞǴǿǴǽǾǿǴdzǴǺǷȁȋ Ȍȁǽ ǾǽDZǴdzǴǼǷǴ ǻǽǵǼǽ ȀǾǴȅǷǯǺȋǼȊǻ HTML-ȇǯǰǺǽǼǽǻ Ǭȁǽȁ HTML ǰȂdzǴȁ ǽȁǽǰǿǯǵǯȁȋȀȎ DZǻǴȀȁǽ ǶǼǯȆǹǯ ȂȀȁǯǼǽDZǹǷ ǾǽȌȁǽǻȂ ǽǼ dzǽǺǵǴǼ ȀǽdzǴǿǵǯȁȋ ȀȀȊǺǹȂ Ǽǯ ǿǴȀȂǿȀ ǶǯDzǿȂǶǹǷ Microsoft ǾǿǴdzǺǯ DzǯǴȁ ȂdzǽǰǼȊǸ URL ǹǽȁǽǿȊǸ ǽǾǿǴdzǴǺȎǴȁ ǷȀǾǽǺȋǶȂǴǻȊǴ ǰǿǯȂǶǴǿ Ƿ ǝǠ Ƿ ǽǰǴȀǾǴȆǷDZǯǴȁ ȀǽǽȁDZǴȁȀȁDZȂȍȈǷǸ ȃǯǸǺ dzǺȎ ǶǯDzǿȂǶǹǷ Ǭȁǽȁ URL ² http://www.microsoft.com/silverlight/handlers/getsilverlight.ashx?v=2.0.
ǒǺǯDZǯ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight DZ $63NET
251
Ǘȁǯǹ ǷǶǻǴǼǷȁȋ ȀȄǴǻȂ ȂȀȁǯǼǽDZǹǷ dzǺȎ Silverlight ǻǽǵǼǽ Ȁ ǾǽǻǽȈȋȍ dzǽȆǴǿǼǴDzǽ ȁǴDzǯ (ǧǯǰǺǽǼ ǾǽdzǹǺȍȆǯǴǻȊǸ ǻǽdzȂǺȋ ǼǴ ȂȀȁǯǼǽDZǺǴǼ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ASP.NET Silverlight. ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ: If you want to install the Silverlight control, you can click here! 1
ǖdzǴȀȋ ǷȀǾǽǺȋǶȂǴȁȀȎ DzǷǾǴǿȀȀȊǺǹǯ (ȁǴDz ) Ǽǯ DZȊȇǴȂǾǽǻȎǼȂȁȊǸ UR/ Ǿǽ ǹǽȁǽǿǽǻȂ ǿǯȀǾǽǺǯDzǯǴȁȀȎ ȌǺǴ ǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight Ƿ ȁǯǹǵǴ ǶǯdzǯǴȁȀȎ ǼǴǹǽȁǽǿȊǸ dzǽǰǿǽǵǴǺǯȁǴǺȋǼȊǸ ȁǴǹȀȁ ǙǽǼǴȆǼǽ ǻǽǵǼǽ ǾǿǴdzǽȀȁǯDZǷȁȋ ǾǽǺȋǶǽDZǯȁǴǺȎǻ Ȇȁǽ-ȁǽ ǼǯǻǼǽDzǽ ǰǽǺǴǴ DZȊȆȂǿǼǽǴ Ǽǽ ǶdzǴȀȋ ǻȊ ǾǿǽȀȁǽ dzǴǻǽǼȀȁǿǷǿȂǴǻ DZǽǶǻǽǵǼǽȀȁǷ ǞǽǾǯdzǯȎ Ǽǯ DZǯȇȂ ȀȁǿǯǼǷȅȂ ǾǽǺȋǶǽDZǯȁǴǺȋ ǼǴ ǷǻǴȍȈǷǸ Silverlight ǰȂdzǴȁ DZǷdzǴȁȋ ȀǽdzǴǿ ǵǷǻǽǴ ǹǽȁǽǿǽǴ ǾǽǹǯǵǴȁ ǹǯǹ ȂȀȁǯǼǽDZǷȁȋ Silverlight ǔȀǺǷ Silverlight Ȃ ǾǽǺȋǶǽDZǯȁǴǺȎ ȂȀȁǯǼǽDZǺǴǼ ǽǼ ǰȂdzǴȁ DZǷdzǴȁȋ Silverlight-ȀǽdzǴǿǵǷǻǽǴ.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǿǴǵǷǻǯ Stretch ǞǽǺȋǶǽDZǯȁǴǺȋ ǻǽǵǴȁ ǻǴǼȎȁȋ ǿǯǶǻǴǿ ǰǿǯȂǶǴǿǯ ǾǿǷ Ȍȁǽǻ ǵǴǺǯȁǴǺȋǼǽ ȆȁǽǰȊ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǻǴǼȎǺȀȎ ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ Ǭȁǽ ǻǽǵǼǽ ǿǴǯǺǷǶǽDZǯȁȋ DZ ǹǽdzǴ ǾǴǿǴȄDZǯȁȊDZǯȎ ȀǽǰȊȁǷȎ ǷǶǻǴǼǴǼǷȎ ǿǯǶ ǻǴǿǽDZ ǷǺǷ ǯDZȁǽǻǯȁǷȆǴȀǹǷ Ȁ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ ScaleMode ǟǴǵǷǻ ǻǯȀȇȁǯǰǷǿǽDZǯǼǷȎ ǠȂȈǴȀȁDZȂǴȁ ȁǿǷ DZǽǶǻǽǵǼȊȄ ǶǼǯȆǴǼǷȎ ȌȁǽDzǽ ȀDZǽǸȀȁDZǯ: x
None ǠǽdzǴǿǵǷǻǽǴ ǰȂdzǴȁ ǽȀȁǯDZǯȁȋȀȎ ǹǯǹ ǴȀȁȋ, ǾǽȌȁǽǻȂ dzǯǵǴ ǾǿǷ ǷǶǻǴǼǴǼǷǷ ǿǯǶǻǴǿǯ ǰǿǯȂǶǴǿǯ ǿǯǶǻǴǿȊ ȀǽdzǴǿǵǷǻǽDzǽ ǰȂdzȂȁ ǽȀȁǯDZǯȁȋȀȎ ǼǴǷǶǻǴǼǼȊǻǷ.
x
Stretch Silverlight-ȀǽdzǴǿǵǷǻǽǴ ǰȂdzǴȁ ǻǴǼȎȁȋ ǿǯǶǻǴǿȊ ǾǿǷ ǷǶǻǴǼǴǼǷǷ ǿǯǶǻǴǿǯ ǰǿǯȂǶǴǿǯ Ƿ ǻǴǼȎȁȋ ǾǿǽǾǽǿȅǷǷ ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ.
x
Zoom Silverlight-ȀǽdzǴǿǵǷǻǽǴ ǰȂdzǴȁ ǻǴǼȎȁȋ ǿǯǶǻǴǿȊ ǾǿǷ ǷǶǻǴǼǴǼǷǷ ǿǯǶǻǴǿǯ ǰǿǯȂǶǴǿǯ Ǽǽ ǰȂdzǴȁ ȀǽȄǿǯǼȎȁȋ ȀDZǽǷ ǾǿǽǾǽǿȅǷǷ.
ǟǷȀ. 13- Ƿ -8 dzǴǻǽǼȀȁǿǷǿȂȍȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴ Stretch Ƿ Zoom, ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ.
1ǔȀǺǷ
ȄǽȁǷȁǴ ȂȀȁǯǼǽDZǷȁȋ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ȈǴǺǹǼǷȁǴ ǶdzǴȀȋ ǾǿǷǻ ǾǴǿǴDZǽdzȆǷǹǯ)
252
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
ǟǗǠ 13 7 Stretch ǻǴǼȎǴȁ ǾǿǽǾǽǿȅǷǷ.
ǟǗǠ 13 8 Zoom ǻǴǼȎǴȁ ǿǯǶǻǴǿ ȀǽdzǴǿǵǷǻǽDzǽ, Ǽǽ ǼǴ ǾǿǽǾǽǿȅǷǷ.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǿǴǵǷǻǯ Windowless Ǟǽ ȂǻǽǺȆǯǼǷȍ Silverlight ǾǴǿǴǹǿȊDZǯǴȁ DZȀǴ ȀǽdzǴǿǵǷǻǽǴ HTML-ȀȁǿǯǼǷȅȊ ǾǽǾǯdzǯȍȈǴǴ DZ ǽǰǺǯȀȁȋ ǴDzǽ ǽȁǽǰǿǯǵǴǼǷȎ ǗȀǾǽǺȋǶȂȎ ǿǴǵǷǻ Windowless ǻǽǵǼǽ ǽǰǴȀǾǴȆǷȁȋ ǽǰǿǯȁǼǽǴ ǾǽDZǴdzǴǼǷǴ ȁǴ HTMLȀǽdzǴǿǵǷǻǽǴ ǰȂdzǴȁ ǽȁǽǰǿǯǵǯȁȋȀȎ ǾǽDZǴǿȄ ȀǽdzǴǿǵǷǻǽDzǽ Silverlight Ǭȁǽ ǾǽǺǴǶǼǽ ǴȀǺǷ ȁǿǴǰȂǴȁȀȎ ȂǺȂȆ ȇǷȁȋ ȀȂȈǴȀȁDZȂȍȈǷǴ ǾǿǷǺǽǵǴǼǷȎ Ȁ ǾǽǻǽȈȋȍ Silverlight. ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ HTML ǷǺǷ dzǿȂDzǽǸ HTML ȀǽǶdzǯDZǯǴǻȊǸ ASP.NET, JSP ǷǺǷ dzǿȂDzǷǻǷ ȀǴǿDZǴǿǯǻǷ ǻǽDzȂȁ ǾǿǽȀȁǽ ǽȁǽǰǿǯǵǯȁȋȀȎ ǾǽDZǴǿȄ ȀǽdzǴǿ ǵǷǻǽDzǽ Silverlight ǜǯǾǿǷǻǴǿ ǴȀȁȋ ȌǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ dzǽȀȁȂǾǼȊǴ DZ HTML Ƿ ǼǴdzǽȀȁȂǾǼȊǴ Ǿǽǹǯ DZ Silverlight, ȁǯǹǷǴ ǹǯǹ ǿǴdzǯǹȁǽǿ Rich Text Box ǜǯȀȊȈǴǼǼǽǴ ȁǴǹȀȁǽDZǽǴ ǾǽǺǴ ǷǺǷ DZǽǶǻǽǵǼǽ DZȊ ȄǽȁǷȁǴ ǷȀ ǾǽǺȋǶǽDZǯȁȋ dzǿȂDzǽǸ Input Method Editor (IME) ǽȁǺǷȆǼȊǸ ǽȁ ǾǿǴdzǺǯDzǯǴǻǽDzǽ Silverlight. Ǒ ȌȁǷȄ ȀǺȂȆǯȎȄ ǴȀ ǺǷ ȀȂȈǴȀȁDZȂȍȁ dzǽȀȁȂǾǼȊǴ ȌǺǴǻǴǼȁȊ ǰǿǯȂǶǴǿǯ ǽǰǴȀǾǴȆǷDZǯȍȈǷǴ ȁǿǴǰȂǴǻǽǴ ǾǽDZǴdzǴǼǷǴ ǻǽǵǼǽ ǶǯǾǷ Ȁǯȁȋ ǷȄ ȀǽdzǴǿǵǷǻǽǴ ǾǽDZǴǿȄ ȀǽdzǴǿǵǷǻǽDzǽ Silverlight.
ǒǺǯDZǯ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight DZ $63NET
253
ǟǯȀȀǻǽȁǿǷǻ ǾǿǷǻǴǿ:
ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ dzǺȎ ȌǺǴǻǴǼȁǽDZ DZǹǺȍȆǯȍȈǷȄ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ HTML TextArea ǡǴǹ ȀȁǽDZǯȎ ǽǰǺǯȀȁȋ Ƿ Silverlight-ȀǽdzǴǿǵǷǻǽDzǽ ǶǯdzǯǼǯ ǯǰȀǽǺȍȁǼǯȎ ǾǽǶǷȅǷȎ ǾǷǹȀǴǺǽDZ ǽȁ DZǴǿȄǼǴǸ DzǿǯǼǷȅȊ ǡǯǹǷǻ ǽǰǿǯǶǽǻ ǽǼǷ ǰȂdzȂȁ ǼǯȄǽdzǷȁȋȀȎ DZ ǽdzǼǽǻ Ƿ ȁǽǻ ǵǴ ǻǴȀȁǴ Ǽǯ ȌǹǿǯǼǴ ǔȀǺǷ ǰȊ ǾǯǿǯǻǴȁǿȂ Windowless ǼǴ ǰȊǺǽ ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ true ǻȊ DZǷdzǴǺǷ ǰȊ ȁǽǺȋǹǽ Silverlight-ȀǽdzǴǿǵǷǻǽǴ ǝdzǼǯǹǽ ǹǽDzdzǯ Windowless ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ true, HTML-ȀǽdzǴǿǵǷǻǽǴ ǽȁǽǰǿǯǵǯǴȁȀȎ ȀDZǴǿȄȂ ǿǷȀ 13-9).
ǟǗǠ 13 9 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ǿǴǵǷǻǯ Windowless DZ Silverlight.
ǟǴǵǷǻ Windowless ȀǺǴdzȂǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋ ǯǹǹȂǿǯȁǼǽ ǾǽȁǽǻȂ Ȇȁǽ ǽǼ ǻǽǵǴȁ ǽǹǯǶȊDZǯȁȋ ǼǴDzǯȁǷDZǼǽǴ DZǺǷȎ ǼǷǴ Ǽǯ ǾǿǽǷǶDZǽdzǷȁǴǺȋǼǽȀȁȋ ǽȀǽǰǴǼǼǽ ǾǿǷ ǰǽǺȋȇǽǻ ǹǽǺǷȆǴȀȁDZǴ ǯǼǷǻǯȅǷǸ.
ǠǽǰȊȁǷȎ ȀǴǿDZǴǿǼǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǠǴǿDZǴǿǼȊǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ȁǯǹǵǴ ǾǿǴdzǽȀȁǯDZǺȎǴȁ ǿȎdz ȀǽǰȊȁǷǸ ǹǽȁǽǿȊǴ ǻǽDzȂȁ ǾǴǿǴȄDZǯȁȊDZǯȁȋȀȎ ǽǰǿǯǰǽȁȆǷǹǯǻǷ ȀǽǰȊȁǷǸ JavaScript Ǚ ǼǷǻ ǽȁǼǽȀȎȁȀȎ x
OnPluginError ǝȇǷǰǹǯ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ ǝǾǿǴdzǴǺȎǴȁ ȃȂǼǹȅǷȍ JavaScript, ǹǽȁǽǿǯȎ ǰȂdzǴȁ DZȊǶȊDZǯȁȋȀȎ ǾǿǷ DZǽǶǼǷǹǼǽDZǴǼǷǷ ǺȍǰǽǸ ǽȇǷǰǹǷ DZ ǾǿǷǺǽǵǴǼǷǷ Silverlight. Ǭȁǽ ǾǽdzǿǽǰǼǽ ǽǰȀȂǵdzǯǴȁ ȀȎ DZ ǒǺǯDZǴ 5, ©ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷǻǯȅǷȎ DZ XAMLª.
x
OnPluginFullScreenChanged (ǞǴǿǴȄǽdz ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ ǹ ǾǽǺǼǽȌǹǿǯǼǼǽǻȂ ǿǴǵǷǻȂ) ǝǾǿǴdzǴǺȎǴȁ ȃȂǼǹȅǷȍ JavaScript, ǹǽȁǽǿǯȎ ǰȂdzǴȁ DZȊǶȊDZǯȁȋȀȎ ǾǿǷ ǾǴǿǴȄǽdzǴ ǹ ǾǽǺǼǽȌǹǿǯǼǼǽǻȂ ǿǴǵǷ ǻȂ. ǜǴ ȀȂȈǴȀȁDZȂǴȁ ȀǾǽȀǽǰǯ ǾǴǿǴȄǽdzǯ ǹ ǾǽǺǼǽȌǹǿǯǼǼǽǻȂ ǿǴǵǷǻȂ ǯDZȁǽǻǯȁǷȆǴȀǹǷ, Ǽǽ ȌǺǴǻǴǼȁ ȂǾǿǯDZ ǺǴǼǷȎ ǷǻǴǴȁ ȀDZǽǸȀȁDZǽ (isFullScreen) ǹǽȁǽǿǽǴ ǻǽǵǴȁ ǻǴǼȎȁȋȀȎ Ǽǯ ǽȀǼǽDZǯǼǷǷ dzǴǸȀȁDZǷȎ ǾǽǺȋǶǽDZǯȁǴǺȎ. ǔȀǺǷ ȁǿǴǰȂǴȁȀȎ ǿǴǯDzǷǿǽDZǯȁȋ Ǽǯ Ȍȁǽ ȀǽǰȊȁǷǴ, DZǽǶǻǽǵǼǽ, ǷǶǻǴǼȎȎ ǹǽǻǾǽǼǽDZǹȂ ȌǹǿǯǼǯ Ȍȁǽ ǻǽǵǼǽ dzǴ Ǻǯȁȋ DZ ǽǰǿǯǰǽȁȆǷǹǴ ȀǽǰȊȁǷǸ ǽǾǿǴdzǴǺǴǼǼǽǻȂ OnPluginFullScreeenChanged.
254
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
x
OnPluginLoaded (ǞǽdzǹǺȍȆǯǴǻȊǸ ǻǽdzȂǺȋ ǶǯDzǿȂǵǴǼ) ǝǾǿǴdzǴǺȎǴȁ ȃȂǼǹȅǷȍ JavaScript, ǹǽȁǽǿǯȎ ǰȂdzǴȁ DZȊǶȊDZǯȁȋȀȎ Ǿǽ ǶǯDZǴǿȇǴǼǷǷ ǶǯDzǿȂǶǹǷ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ. ǐǽǺǴǴ ǾǽdzǿǽǰǼǽ Ȍȁǽ ǽǰȀȂǵdzǯǴȁ ȀȎ DZ ǒǺǯDZǴ 5.
x
OnPluginResized (ǗǶǻǴǼǴǼǷǴ ǿǯǶǻǴǿǯ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ) ǝǾǿǴdzǴǺȎǴȁ ȃȂǼǹȅǷȍ JavaScript, ǹǽȁǽǿǯȎ ǰȂdzǴȁ DZȊǶȊDZǯȁȋȀȎ ǾǿǷ ǹǯǵdzǽǻ ǷǶǻǴǼǴǼǷǷ ǿǯǶǻǴǿǽDZ ǾǽdzǹǺȍȆǯǴǻǽDzǽ ǻǽdzȂǺȎ, Ȇȁǽ ǽǰȊȆǼǽ ǾǿǽǷȀȄǽdzǷȁ ǴȀǺǷ DZ ǹǯȆǴȀȁDZǴ ǿǴǵǷǻǯ ǿǯȀȁȎǵǴǼǷȎ ǶǯdzǯǼ Stretch ǷǺǷ Zoom (ǽǰȀȂǵdzǯǴȁȀȎ ǿǯǼǴǴ DZ dzǯǼ ǼǽǸ DzǺǯDZǴ), Ƿ ǾǽǺȋǶǽDZǯȁǴǺȋ ǻǴǼȎǴȁ ǿǯǶǻǴǿȊ ǰǿǯȂǶǴǿǯ.
ǡǯǹǷǻ ǽǰǿǯǶǽǻ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ASP.NET ǾǽǶDZǽǺȎǴȁ ǶǯdzǯDZǯȁȋ DZȀǴ ǼǴǽǰȄǽdzǷǻǽǴ ǽǰȉǴǹȁȂ DZȊǾǽǺ ǼȎȍȈǴǻȂȀȎ Ǽǯ ȀȁǽǿǽǼǴ ǹǺǷǴǼȁǯ ǡǽ ǴȀȁȋ ǻǽǵǼǽ dzǴǺǯȁȋ DZȀǴ ȁǽ ǵǴ ȀǯǻǽǴ Ȇȁǽ DZȊ dzǴǺǯǺǷ Ȁ ǾǽǻǽȈȋȍ ȁǴDzǯ Ƿ ǾǿǷ ǾǽǻǽȈǷ ASP.NET!
ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ MediaPlayer DZ ASP.NET ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ MediaPlayer ǽǰǴȀǾǴȆǷDZǯǴȁ dzǽȀȁǯDZǹȂ ǾǽǺǼǽȃȂǼǹȅǷǽǼǯǺȋǼǽDzǽ SilverlightǻǴdzǷǯǾǺǴǴǿǯ DZǷdzǴǽ ǷǷǺǷ ǯȂdzǷǽ Ǽǯ ȀȁǿǯǼǷȅȂ ǝǼ ǾǿǴdzǽȀȁǯDZǺȎǴȁ ǿȎdz ȇǯǰǺǽǼǽDZ ǽȃǽǿǻǺǴǼǷȎ ǹǽȁǽǿȊǴ ǼǴ ȁǽǺȋǹǽ ǽǰǴȀǾǴȆǷDZǯȍȁ ǾǿǴdzȀȁǯDZǺǴǼǷǴ ǻǴdzǷǯǾǺǴǴǿǯ Ǽǽ ȁǯǹǵǴ ǾǽǺǼȂȍ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁȋ ȂǾǿǯDZǺǴǼǷȎ DZǽȀǾǿǽǷǶDZǴdzǴǼǷǴǻ ǽȀȁǯǼǽDZǹǽǸ ǾǿǷǽȀȁǯǼǽDZǹǽǸ ǻǯǿǹǴǿǯǻǷ ǶDZȂǹǽǻ ǾǴǿǴȄǽdzǽǻ DZ ǾǽǺǼǽȌǹǿǯǼǼȊǸ ǿǴ ǵǷǻ Ƿ ǻǼǽDzǽǴ dzǿȂDzǽǴ ǡǯǹǵǴ ȄǽȆȂ ǽǰǿǯȁǷȁȋ DZǼǷǻǯǼǷǴ Ȇȁǽ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ASP.NET MediaPlayer ǷǻǴǴȁ DZȀǴ ȀDZǽǸȀȁDZǯ ǻǴȁǽdzȊ Ƿ ȀǽǰȊȁǷȎ ȁǷǾǽDZǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǹǽȁǽǿȊǸ ǽǰȀȂǵdzǯǺȀȎ DZ ǾǴǿDZǽǸ ȆǯȀȁǷ dzǯǼǼǽǸ DzǺǯDZȊ ǡǯǹǷǻ ǽǰǿǯǶǽǻ DZȀǴ Ȇȁǽ ǰȊǺǽ ȀǹǯǶǯǼǽ ǽ ǼǴǻ ǶdzǴȀȋ DZǹǺȍȆǯȎ ǼǯȀȁǿǽǸǹȂ Windowless ǷǺǷ dzǿȂDzǷȄ ȀDZǽǸȀȁDZ ȁǯǹǵǴ ǻǽǵǴȁ ǾǿǷǻǴǼȎȁȋȀȎ ǹ MediaPlayer. ǟǯǰǽȁǯȁȋ Ȁ ȌǺǴǻǴǼȁǽǻ ȂǾǿǯDZǺǴǼǷȎ MediaPlayer ǽȆǴǼȋ ǺǴDzǹǽ ǼǴǽǰȄǽdzǷǻǽ ǾǿǽȀȁǽ dzǽǰǯDZǷȁȋ ǴDzǽ ȌǹǶǴǻǾ ǺȎǿ Ǽǯ ǿǯǰǽȆȂȍ ǾǽDZǴǿȄǼǽȀȁȋ ǑǴǰ-ȃǽǿǻȊ ASP.NET Ǒ DZǴǿȄǼǴǻ ǾǿǯDZǽǻ ȂDzǺȂ ǷǻǴǴȁȀȎ ǹǼǽǾǹǯ ǽȁǹǿȊDZǯȍ ȈǯȎ ǾǽǻǽȈǼǷǹ MediaPlayer Tasks ǖǯdzǯǼǷȎ MediaPlayer ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 13-10.
ǟǗǠ 13 10 ǗȀǾǽǺȋǶǽDZǯǼǷǴ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ MediaPlayer.
ǜǯȀȁǿǽǸǹǯ ǾǿǷ ǾǽǻǽȈǷ MediaPlayer Tasks ǞǽǻǽȈǼǷǹ MediaPlayer Tasks ǾǽǻǽǵǴȁ Ƕǯdzǯȁȋ ǽȀǼǽDZǼȊǴ ȀDZǽǸȀȁDZǯ ǹǽȁǽǿȊǴ ǽǰǴȀǾǴȆǯȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴ ǻǴdzǷǯǾǺǴǴǿǯ Ǽǯ DZǯȇǴǻ ȀǯǸȁǴ x
ǜǯȀȁǿǽǸǹǯ Player Skin (ǧǯǰǺǽǼ ǽȃǽǿǻǺǴǼǷȎ ǾǺǴǴǿǯ ǾǽǶDZǽǺȎǴȁ ǶǯdzǯDZǯȁȋ DZǼǴȇǼǷǸ DZǷdz Ƿ ǾǽDZǴdzǴǼǷǴ DZǯȇǴDzǽ ǾǺǴǴǿǯ ǗǼȀȁǿȂǻǴǼȁȊ ASP.NET Silverlight ǾǽȀȁǯDZǺȎȍȁȀȎ Ȁ Ǽǯǰǽǿǽǻ ȇǯǰǺǽǼǽDZ ǯ ȁǯǹǵǴ ǻǽǵ Ǽǽ ȀǽǶdzǯDZǯȁȋ ȀǽǰȀȁDZǴǼǼȊǴ ȇǯǰǺǽǼȊ DZ Expression Blend. ǗȄ ǿǯǶǿǯǰǽȁǹǯ DZȊȄǽdzǷȁ Ƕǯ ǿǯǻǹǷ ǿǯȀȀǻǽȁ ǿǴǼǷȎ dzǯǼǼǽǸ ǹǼǷDzǷ Ǽǽ Ǽǯ ȀǯǸȁǴ http://www.silverlight.net ǻǽǵǼǽ ǼǯǸȁǷ ȀǽǽȁDZǴȁȀȁDZȂȍȈǷǴ ȂȆǴǰǼȊǴ ǾǽȀǽǰǷȎ dzǺȎ ȌȁǽDzǽ ǨǴǺǹǼǷȁǴ ȀȀȊǺǹȂ Import Skin (ǗǻǾǽǿȁǷǿǽDZǯȁȋ ȇǯǰǺǽǼ ǽȃǽǿǻǺǴǼǷȎ), ȆȁǽǰȊ ǷǻǾǽǿȁǷǿǽDZǯȁȋ ǽdzǷǼ ǷǶ ǾǿǴdzǽȀȁǯDZǺȎǴǻȊȄ ȇǯǰǺǽǼǽDZ. Ǟǽ ȂǻǽǺȆǯǼǷȍ ǽǼǷ ȄǿǯǼȎȁȀȎ DZ ǹǯȁǯǺǽDzǴ C:\Program Files\Microsoft SDKs\Silverlight \v2.0 \Libraries \Server \MediaPlayerSkins.
ǒǺǯDZǯ ǬǺǴǻǴǼȁȊ ȂǾǿǯDZǺǴǼǷȎ Silverlight DZ $63NET
255
x
Media Source (ǗȀȁǽȆǼǷǹ ǻȂǺȋȁǷǻǴdzǷǯ) ² Ȍȁǽ ǻǴȀȁǽǾǽǺǽǵǴǼǷǴ ǻǴdzǷǯȃǯǸǺǯ, ǹǽȁǽǿȊǸ ǾǿǴdzǾǽǺǯDzǯǴȁȀȎ DZǽȀǾǿǽǷǶDZǽdzǷȁȋ.
x
Placeholder Image (ǖǯȀȁǯDZǹǯ) ² ǷǶǽǰǿǯǵǴǼǷǴ, ǹǽȁǽǿǽǴ ǰȂdzǴȁ ǽȁǽǰǿǯǵǯȁȋȀȎ ǾǴǿǴdz ǷǺǷ ǾǽȀǺǴ DZǽȀǾǿǽ ǷǶDZǴdzǴǼǷȎ ǻȂǺȋȁǷǻǴdzǷǯ. Ǭȁǽ dzǽǺǵǼǽ ǰȊȁȋ ǷǶǽǰǿǯǵǴǼǷǴ DZ ȃǽǿǻǯȁǴ JPG ǷǺǷ PNG.
x
Volume (ǒǿǽǻǹǽȀȁȋ) ² ǶǼǯȆǴǼǷǴ DZ dzǷǯǾǯǶǽǼǴ ǻǴǵdzȂ 0 Ƿ 1, ǽǰǽǶǼǯȆǯȍȈǴǴ DzǿǽǻǹǽȀȁȋ Ǿǽ ȂǻǽǺȆǯǼǷȍ Ȁ ǹǽȁǽǿǽǸ ǰȂdzǴȁ DZȊǾǽǺǼȎȁȋȀȎ DZǽȀǾǿǽǷǶDZǴdzǴǼǷǴ.
x
ǙǽDzdzǯ ȃǺǯǵǽǹ Muted (ǐǴǶ ǶDZȂǹǯ) ȂȀȁǯǼǽDZǺǴǼ, DZǽȀǾǿǽǷǶDZǴdzǴǼǷǴ ǰȂdzǴȁ DZȊǾǽǺǼȎȁȋȀȎ Ǽǽ ǶDZȂǹǯ ǼǴ ǰȂdzǴȁ ȀǺȊȇǼǽ ǼǴǶǯDZǷȀǷǻǽ ǽȁ ǶǯdzǯǼǼǽǸ DzǿǽǻǹǽȀȁǷ.
x
ǙǽDzdzǯ ȃǺǯǵǽǹ Auto-Play (ǏDZȁǽDZǽȀǾǿǽǷǶDZǴdzǴǼǷǴ) ȂȀȁǯǼǽDZǺǴǼ, DZǽȀǾǿǽǷǶDZǴdzǴǼǷǴ ǻȂǺȋȁǷǻǴdzǷǯ ǼǯȆǷ ǼǯǴȁȀȎ ǹǯǹ ȁǽǺȋǹǽ ǽǼǽ ȀȁǯǼǽDZǷȁȀȎ dzǽȀȁȂǾǼȊǻ Ǟǽ ȂǻǽǺȆǯǼǷȍ ǶǼǯȆǴǼǷǴ Auto-Play ² false (ȃǺǯǵǽǹ ǼǴ ȂȀȁǯǼǽDZǺǴǼ).
ǔȀǺǷ DZǼǷǻǯȁǴǺȋǼǴǸ ǾǽȀǻǽȁǿǴȁȋ Ǽǯ ǿǷȀ 13- ǻǽǵǼǽ ǶǯǻǴȁǷȁȋ Ȇȁǽ ǾǽǺǶȂǼǽǹ DzǿǽǻǹǽȀȁǷ ȂȀȁǯǼǽDZǺǴǼ Ǿǽ ȀǴǿǴdzǷǼǴ ǾǽȁǽǻȂ Ȇȁǽ ǶǼǯȆǴǼǷǴ DzǿǽǻǹǽȀȁǷ Ǿǽ ȂǻǽǺȆǯǼǷȍ DZ ǾǽǻǽȈǼǷǹǴ MediaPlayer Tasks (ǿǷȀ 13-10) ² Ǭȁǽ dzǴǻǽǼȀȁǿǷǿȂǴȁ DzǷǰǹǽȀȁȋ dzǯǼǼǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ DZȊ ǻǽǵǴȁǴ ǼǯȀȁǿǯǷDZǯȁȋ ǻǴdzǷǯǾǺǴǴǿ ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ ǹǽǼǹǿǴȁǼȊǻ ǼȂǵdzǯǻ ȀDZǽǴDzǽ ǾǿǷǺǽǵǴǼǷȎ
ǟǗǠ 13 11 ǛǴdzǷǯǾǺǴǴǿ ǾǽȀȁǯDZǺȎǴǻȊǸ MediaControl.
ǠȂȈǴȀȁDZȂǴȁ ǿȎdz dzǿȂDzǷȄ ȀDZǽǸȀȁDZ ǹǽȁǽǿȊǴ ǼǴ ǾǿǴdzȀȁǯDZǺǴǼȊ DZ ǾǽǻǽȈǼǷǹǴ MediaPlayer Tasks ǜǯǾǿǷǻǴǿ ȀDZǽǸȀȁDZǽ AutoLoad ǏDZȁǽǶǯDzǿȂǶǹǯ ǙǽDzdzǯ ǴǻȂ ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ true ǻȂǺȋȁǷǻǴdzǷǯ ǯDZȁǽǻǯȁǷȆǴȀǹǷ ǶǯDzǿȂ ǵǯǴȁȀȎ DZ ǰǯǶǽDZȊǸ ȌǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǼǴȀǻǽȁǿȎ Ǽǯ dzǴǸȀȁDZǷȎ ǾǽǺȋǶǽDZǯȁǴǺȎ ǙǽDzdzǯ AutoLoad ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ false ǻȂǺȋȁǷǻǴdzǷǯ ǼǴ ǰȂdzǴȁ ǶǯDzǿȂǵǯȁȋȀȎ dzǽ ȁǴȄ Ǿǽǿ Ǿǽǹǯ ǾǽǺȋǶǽDZǯȁǴǺȋ ǷǺǷ ǾǿǽDzǿǯǻǻǯ ǼǴ ǼǯȆǼȂȁ DZǽȀǾǿǽǷǶDZǴdzǴǼǷǴ ǠDZǽǸȀȁDZǽ EnableCaptions (ǑǹǺȍȆǷȁȋ ȁǷȁǿȊ) ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ DZǹǺȍȆǴǼǷȎ/DZȊǹǺȍȆǴǼǷȎ ȀǹǿȊȁȊȄ ȁǷȁǿǽDZ, ǴȀǺǷ ǽǼǷ ǹǽdzǷǿǽDZǯǼȊ DZ ǾǽȁǽǹǴ.
ǑǶǯǷǻǽdzǴǸȀȁDZǷǴ Ȁ ǻȂǺȋȁǷǻǴdzǷǯ ǞǿǴǵdzǴ ȆǴǻ ǾǿǽdzǽǺǵǷȁȋ Ǽǯȇ ǿǯǶDzǽDZǽǿ ǼǴ ǾǽǻǴȇǯǺǽ ǰȊ ǼǯǸȁǷ ǾǽdzȄǽdzȎȈǷǸ ǻǴdzǷǯȃǯǸǺ ȀǽdzǴǿǵǯȈǷǸ ǻǯǿǹǴǿȊ ǤǽǿǽȇǷǸ ǾǿǷǻǴǿ ȁǽDzǽ ǹǯǹ Ȍȁǽ ǻǽǵǼǽ ȀdzǴǺǯȁȋ ǾǿǴdzȀȁǯDZǺǴǼ DZ ǒǺǯDZǴ ©ǛȂǺȋȁǷǻǴdzǷǯ ǿȂǹǽ ǾǷȀǼȊǸ DZDZǽdz Ƿ Deep Zoomª ǔȀǺǷ DZ DZǷdzǴǽǾǽȁǽǹǴ ǹǽdzǷǿǽDZǯǼȊ ǻǯǿǹǴǿȊ ǻǽǵǼǽ ǼǯǾǷȀǯȁȋ ǹǽdz ǿǴǯDzǷǿȂȍȈǷǸ Ǽǯ ǼǷȄ Ƿ ȌǺǴǻǴǼȁ ǻȂǺȋ ȁǷǻǴdzǷǯ Silverlight ǰȂdzǴȁ ȃǽǿǻǷǿǽDZǯȁȋ ȀǽǰȊȁǷȎ ǾǿǷ DZȀȁǿǴȆǴ Ȁ ȌȁǷǻǷ ǻǯǿǹǴǿǯǻǷ ǞǿǷ ǷȀǾǽǺȋǶǽDZǯǼǷǷ ȀǴǿDZǴǿǼǽDzǽ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ASP.NET ǼǴǽǰȄǽdzǷǻ ȀǾǽȀǽǰ ǯȀȀǽȅǷǷǿǽDZǯȁȋ ȌȁǷ ǻǯǿǹǴǿȊ Ȁ ȃȂǼǹȅǷȎ ǻǷ-ǽǰǿǯǰǽȁȆǷǹǯǻǷ ǟǯdz ȀǽǽǰȈǷȁȋ Ȇȁǽ ȀȂȈǴȀȁDZȂȍȁ ǯȁǿǷǰȂȁȊ ǾǽǶDZǽǺȎȍȈǷǴ ȀdzǴǺǯȁȋ Ȍȁǽ ǜǯǾǿǷǻǴǿ, OnClientChapterStarted (ǜǯȆǯǺǽ ǿǯǶdzǴǺǯ) ǽǾǿǴdzǴǺȎǴȁ ȃȂǼǹȅǷȍ JavaScript ǹǽȁǽǿǯȎ ǰȂdzǴȁ DZȊǶȊDZǯȁȋȀȎ DZ ǼǯȆǯǺǴ ǹǯǵdzǽDzǽ ǼǽDZǽDzǽ ǿǯǶdzǴǺǯ DZǷdzǴǽ ǟǯǶdzǴǺȊ ǽǾǿǴdzǴǺȎȍȁȀȎ DZ Expression Encoder Ƿ ǹǽdzǷǿȂȍȁȀȎ DZ DZǷ dzǴǽ ǷǺǷ ǶǯdzǯȍȁȀȎ DZ ǿǯǶǻǴȁǹǴ ASP.NET Ǒǽȁ ǾǿǷǻǴǿ DZȁǽǿǽDzǽ DZǯǿǷǯǼȁǯ
256
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
Ǟǽ dzǽȀȁǷǵǴǼǷǷ ǽȆǴǿǴdzǼǽDzǽ ǿǯǶdzǴǺǯ ǰȂdzǴȁ DZȊǶȊDZǯȁȋȀȎ JavaScript-ȃȂǼǹȅǷȎ ǽǾǿǴdzǴǺǴǼǼǯȎ DZ OnClientChapterStarted. Ǡ ǾǽǻǽȈȋȍ ȀDZǽǸȀȁDZǯ currentState ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ MediaElement ǻǽǵǼǽ ǽȁȀǺǴǵǷDZǯȁȋ Ȇȁǽ ǾǿǽǷȀ ȄǽdzǷȁ Ȁ ǻȂǺȋȁǷǻǴdzǷǯ Ǭȁǽ ǿǯȀȀǻǯȁǿǷDZǯǴȁȀȎ DZ ǒǺǯDZǴ ǓǯǼǼǽǴ ȀDZǽǸȀȁDZǽ DZǽǶDZǿǯȈǯǴȁ ǶǼǯȆǴǼǷȎ ǾǿǴdz ȀȁǯDZǺȎȍȈǷǴ ȁǴǹȂȈǴǴ ȀǽȀȁǽȎǼǷǴ DZǽȀǾǿǽǷǶDZǴdzǴǼǷȎ ǻȂǺȋȁǷǻǴdzǷǯ ȁǯǹǷǴ ǹǯǹ ©playingª DZǽȀǾǿǽǷǶDZǴdzǴǼǷǴ ©bufferingª ǰȂȃǴǿǷǶǯȅǷȎ ©pausedª ǾǿǷǽȀȁǯǼǽDZǺǴǼǽ Ƿ ȁdz ǔȀǺǷ ǼǴǽǰȄǽdzǷǻǽ ǼǯȀȁǿǽǷȁȋ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ ǼǯǾǿǷǻǴǿ ȀǽǰȊȁǷȎ ǹǽȁǽǿǽǴ ȃǽǿǻǷǿȂǴȁȀȎ ǾǿǷ ǷǶǻǴǼǴǼǷǷ ȀǽȀȁǽȎǼǷȎ ǷȀǾǽǺȋǶȂǴȁȀȎ ǯȁǿǷǰȂȁ OnCurrentStateChanged ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ASP.NET ǽǾǿǴdzǴǺȎȍȈǷǸ ǼǴǽǰȄǽdzǷǻȂȍ JavaScriptȃȂǼǹȅǷȍ ǛǯǿǹǴǿȊ ǾǽdzǽǰǼȊ ǿǯǶdzǴǺǯǻ Ȁ ȁǽǸ ȁǽȆǹǷ ǶǿǴǼǷȎ Ȇȁǽ ǽǼǷ ȁǽǵǴ ȎDZǺȎȍȁȀȎ ȃǿǯDzǻǴǼȁǯǻǷ ǻǴȁǯdzǯǼǼȊȄ ǹǽ dzǷǿǽDZǯǼǼȊǻǷ DZ DZǷdzǴǽǾǽȁǽǹ Ǟǽ ȂǻǽǺȆǯǼǷȍ DZȀǴ ǻǯǿǹǴǿȊ ǽǾǿǴdzǴǺǴǼȊ ǹǯǹ ǿǯǶdzǴǺȊ Ǡ ǾǽǻǽȈȋȍ ǯȁǿǷ ǰȂȁǯ OnMarkerReached (Ǟǽ dzǽȀȁǷǵǴǼǷǷ ǻǯǿǹǴǿǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ASP.NET ǻǽǵǼǽ Ƕǯdzǯȁȋ JavaScript-ȃȂǼǹȅǷȍ ǹǽȁǽǿǯȎ ǰȂdzǴȁ DZȊǶȊDZǯȁȋȀȎ ǾǿǷ DZȀȁǿǴȆǴ Ȁ ǻǯǿǹǴǿǽǻ ǙǿǽǻǴ ȁǽDzǽ, ǻǽǵǼǽ Ƕǯdzǯȁȋ dzǴǸȀȁDZǷȎ, DZȊǾǽǺǼȎȍȈǷǴȀȎ ǾǿǷ ǽȁǹǿȊȁǷǷ, ǶǯǹǿȊȁǷǷ Ƿ ȀǰǽǴ ǻȂǺȋȁǷǻǴdzǷǯ, ǷȀ ǾǽǺȋǶȂȎ ǯȁǿǷǰȂȁȊ OnMediaOpened ǞǿǷ ǽȁǹǿȊȁǷǷ ǻȂǺȋȁǷǻǴdzǷǯ , OnMediaEnded ǞǿǷ ǶǯǹǿȊȁǷǷ ǻȂǺȋȁǷ ǻǴdzǷǯ Ƿ OnMediaFailed ǞǿǷ ȀǰǽǴ ǻȂǺȋȁǷǻǴdzǷǯ , ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ.
ǖǯǹǺȍȆǴǼǷǴ Ǒ dzǯǼǼǽǸ DzǺǯDZǴ ǿǯȀȀǻǽȁǿǴǼȊ dzDZǯ ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ ASP.NET ǾǽȀȁǯDZǺȎǴǻȊȄ Ȁ Silverlight SDK. ǬǺǴ ǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ Silverlight ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ ȂǾǿǯDZǺǴǼǷȎ Ƿ ǿǯǶDZǴǿȁȊDZǯǼǷȎ Silverlight-ȀǽdzǴǿǵǷǻǽDzǽ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ ǾǯǿǯdzǷDzǻȊ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ Ǽǯ ȀȁǽǿǽǼǴ ȀǴǿDZǴǿǯ ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ MediaPlayer ǷȀǾǽǺȋǶȂǴȁȀȎ dzǺȎ dzǽȀȁǯDZǹǷ ǹǺǷǴǼȁǯǻ ǻǴdzǷǯȀǽdzǴǿǵǷǻǽDzǽ Ȁ ǿǯǶǼȊǻ ȀȁǷǺǴDZȊǻ ǽȃǽǿǻǺǴǼǷǴǻ Ǭȁǽ ȆǿǴǶ DZȊȆǯǸǼǽ ǾǽǺǴǶǼȊǴ Ȁ ȁǽȆǹǷ ǶǿǴǼǷȎ ǾǿǽǷǶDZǽdzǷȁǴǺȋǼǽȀȁǷ ȀǿǴdzȀȁDZǯ DZ ȀǺȂȆǯǴ ǷȀǾǽǺȋǶǽDZǯǼǷȎ ASP.NET dzǺȎ dzǽȀȁǯDZǹǷ Silverlight ȀǯǸȁǯ Ƿ ǽǼǷ ǰǴǶȂȀǺǽDZǼǽ ǶǯȀǺȂǵǷDZǯȍȁ DZǿǴǻǴǼǷ ǾǽȁǿǯȆǴǼǼǽDzǽ Ǽǯ ǷȄ ǷǶȂȆǴǼǷǴ Ǒ ȀǺǴdzȂȍȈǴǸ DzǺǯDZǴ ǿǯȀȀǻǯȁǿǷDZǯǴȁ ǼǽDZǽǴ ǶǯȄDZǯȁȊDZǯȍȈǴǴ dzǽǾǽǺǼǴǼǷǴ Silverlight 2 ² ǾǽdzdzǴǿǵǹǯ dzǷǼǯǻǷ ȆǴȀǹǷȄ ȎǶȊǹǽDZ
ǒǺǯDZǯ 14
ǗȀǾǽǺȋǶǽDZǯǼǷǴ dzǷǼǯǻǷȆǴȀǹǷȄ ȎǶȊǹǽDZ DZ Silverlight 2 Ǒ Silverlight 2 DZDZǽdzǷȁȀȎ ǾǽdzdzǴǿǵǹǯ dzǷǼǯǻǷȆǴȀǹǷȄ ȎǶȊǹǽDZ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ ǓǷǼǯǻǷȆǴȀǹǷǻǷ ǼǯǶȊDZǯ ȍȁ ȎǶȊǹǷ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ ǹǽȁǽǿȊǴ ǿǴǯǺǷǶȂȍȁ ǻǼǽDzǷǴ ȃȂǼǹȅǷǷ DZǽ DZǿǴǻȎ DZȊǾǽǺǼǴǼǷȎ DZ ȁǽ DZǿǴǻȎ ǹǯǹ DZ dzǿȂDzǷȄ ȎǶȊǹǯȄ ǼǯǾǿǷǻǴǿ C#, Ȍȁǽ ǾǿǽǷȀȄǽdzǷȁ DZǽ DZǿǴǻȎ ǹǽǻǾǷǺȎȅǷǷ ǓǷǼǯǻǷȆǴȀǹǽǴ ǾǽDZǴdzǴǼǷǴ DZǹǺȍȆǯǴȁ ǿǯȀȇǷǿǴǼǷǴ ǽǰȉǴǹȁǽDZ Ƿ ǽǾǷȀǯǼǷǸ ǷǶǻǴǼǴǼǷǴ ȀǷȀȁǴǻȊ ȁǷǾǽDZ Ƿ ǻǼǽDzǽǴ dzǿȂDzǽǴ Ǭȁǽ ǽǰǴȀǾǴ ȆǷDZǯǴȁ dzǷǼǯǻǷȆǴȀǹǷǻ ȎǶȊǹǯǻ ǾǿǽȀȁǽǸ ǾǽdzȄǽdz ǹ ǿǯǶǿǯǰǽȁǹǴ ȆǴǿǴǶ ȅǷǹǺ ©DZȊǾǽǺǼǴǼǷǴ-DZȊȆǷȀǺǴǼǷǴDZȊDZǽdzª Ȁ ǾǿǷǻǴǼǴǼǷǴǻ ǻǴȁǽdzǯ Ǿǿǽǰ Ƿ ǽȇǷǰǽǹ Silverlight 2 ǾǽdzdzǴǿǵǷDZǯǴȁ ȁǿǷ ȀǯǻȊȄ ǿǯȀǾǿǽȀȁǿǯǼǴǼǼȊȄ dzǷǼǯǻǷȆǴȀǹǷȄ ȎǶȊǹǯ: Ruby, Python Ƿ Dynamic JavaScript. ǓǯǼǼǯȎ ǹǼǷDzǯ ǼǯǾǷȀǯǼǯ dzǺȎ ȀǾǴȅǷȃǷǹǯȅǷǷ Silverlight 2, DZ ǹǽȁǽǿȂȍ ǼǴ DZǹǺȍȆǴǼ ȇǯǰǺǽǼ Ǿǿǽ Ǵǹȁǯ Microsoft Visual Studio 2008, Ǽǽ SDK ǾǿǴdzǽȀȁǯDZǺȎǴȁ ǷǼȀȁǿȂǻǴǼȁ, Chiron.exe, dzǺȎ ǿǯǰǽȁȊ Ȁ dzǷǼǯǻǷȆǴ ȀǹǷǻǷ ȎǶȊǹǯǻǷ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ. ǞǽdzdzǴǿǵǹǯ dzǷǼǯǻǷȆǴȀǹǷȄ ȎǶȊǹǽDZ ȎDZǺȎǴȁȀȎ ǷǼǷȅǷǯȁǷDZǽǸ Microsoft Ȁ ǽȁǹǿȊȁȊǻ ǷȀȄǽdzǼȊǻ ǹǽdzǽǻ Ƿ dzǽȀ ȁȂǾǼǯ Ǽǯ ǑǴǰ-ȀǯǸȁǴ CodePlex Ǿǽ ǯdzǿǴȀȂ http://www.codeplex.com/sdlsdk Ǒ dzǯǼǼǽǸ DzǺǯDZǴ ǰȂdzǴȁ ǿǯȀȀǻǽȁ ǿǴǼǽ ǾǽȀȁǿǽǴǼǷǴ ǰǯǶǽDZȊȄ ǾǿǷǺǽǵǴǼǷǸ dzǺȎ Silverlight 2 Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ dzǷǼǯǻǷȆǴȀǹǷȄ ȎǶȊǹǽDZ ǖdzǴȀȋ ǼǴ ȀȁǯDZǷȁȀȎ ǶǯdzǯȆǯ ǷǶȂȆǴǼǷȎ ȀǯǻǷȄ ȎǶȊǹǽDZ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ Ƿ ǷȀǾǽǺȋǶȂȍȁȀȎ ǽȆǴǼȋ ǾǿǽȀȁȊǴ Ǿǿǽ DzǿǯǻǻȊ ǹǽȁǽǿȊǴ ǰȂdzȂȁ ǾǽǼȎȁǼȊ dzǯǵǴ ǺȍdzȎǻ ǼǴ ȎDZǺȎȍȈǷǻȀȎ ȌǹȀǾǴǿȁǯǻǷ DZ ǹǯǹǽǻ-ȁǽ ǹǽǼǹǿǴȁǼǽǻ ȎǶȊ ǹǴ Ǭȁǯ DzǺǯDZǯ ȎDZǺȎǴȁȀȎ ȁǽǺȋǹǽ ǺǷȇȋ DZDZǴdzǴǼǷǴǻ DZ dzǷǼǯǻǷȆǴȀǹǷǴ ȎǶȊǹǷ Ƿ ǷȄ ǷȀǾǽǺȋǶǽDZǯǼǷǴ DZ Silverlight. ǐǽǺȋȇǯȎ ǴǴ ȆǯȀȁȋ ǾǽȀDZȎȈǴǼǯ ǿǯȀȀǻǽȁǿǴǼǷȍ Visual Studio Ƿ DZǽǶǻǽǵǼǽȀȁǴǸ ǴǴ ǾǿǷǻǴǼǴǼǷȎ dzǺȎ ȀǽǶdzǯǼǷȎ ǾǿǷǺǽǵǴǼǷǸ Ǽǯ IronPython, IronRuby Ƿ ȂǾǿǯDZǺȎǴǻǽǻ JavaScript DZ Silverlight ǯ ȁǯǹǵǴ ǷǼȁǴDzǿǷǿǽDZǯǼǷȍ Chiron.exe DZ Visual Studio. Ǐ ǼǯǾǽȀǺǴdzǽǹ DZȊ ȀǽDZǴǿȇǷȁǴ ȁȂǿ Ǿǽ ǶǼǯǻǴǼǷȁǽǻȂ ǾǿǷǻǴǿȂ Silverlight Ȁ ȆǯȀǯǻǷ Ƿ ȂǶǼǯǴȁǴ ǹǯǹ ǽǼ ǿǴǯǺǷǶǽDZǯǼ Ǽǯ Ruby.
ǑǯȇǴ ǾǴǿDZǽǴ Silverlight-ǾǿǷǺǽǵǴǼǷǴ Ǽǯ IronPython Ǡ ǷǼȀȁǿȂǻǴǼȁǽǻ Chiron ǾǿǽȈǴ DZȀǴDzǽ ǿǯǰǽȁǯȁȋ ǴȀǺǷ ǼǯȀȁǿǽǷȁȋ ȀǾǴȅǷǯǺȋǼȂȍ ȀȁǿȂǹȁȂǿȂ ǹǯȁǯǺǽDzǽDZ dzǺȎ ȀDZǽǴDzǽ ǾǿǷǺǽǵǴǼǷȎ Ǒ dzǯǼǼǽǻ ǿǯǶdzǴǺǴ ǰȂdzǴȁ ǾǽȌȁǯǾǼǽ ǿǯȀȀǻǽȁǿǴǼǽ ǹǯǹ Ȍȁǽ ȀdzǴǺǯȁȋ ǞǿǴǵdzǴ DZȀǴDzǽ ǼǴǽǰȄǽdzǷǻǽ ȀǽǶdzǯȁȋ ǾȂȀȁǽǸ ǑǴǰ-ȀǯǸȁ ǓǺȎ ȌȁǽDzǽ ǶǯǾȂȀȁǷǻ Visual Studio Ƿ DZȊǰǴǿǴǻ DZ ǻǴ Ǽȍ File ǾȂǼǹȁ New Web Site ǜǽDZȊǸ ǑǴǰ-ȀǯǸȁ ǝǾȅǷȎ Empty Web Site ǞȂȀȁǽǸ ǑǴǰ-ȀǯǸȁ ǾǿǴdzǺǯDzǯǴȁȀȎ DZ dzǷǯǺǽDzǽDZǽǻ ǽǹǼǴ New Web Site ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 14-1.
ǟǗǠ 14 1 ǓǷǯǺǽDzǽDZǽǴ ǽǹǼǽ New Web Site.
258
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
Ǭȁǽ ǽǰǴȀǾǴȆǷȁ ȀǽǶdzǯǼǷǴ ǾȂȀȁǽDzǽ ǹǯȁǯǺǽDzǯ ǹǽȁǽǿȊǸ dzǺȎ Visual Studio ǰȂdzǴȁ ȎDZǺȎȁȋȀȎ ǹǽǿǼǴDZȊǻ ǹǯȁǯǺǽ Dzǽǻ ǑǴǰ-ȀǯǸȁǯ ǓǺȎ ȀǽǶdzǯǼǷȎ ȀǯǸȁǯ ǰȂdzǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ Chiron Ǽǽ DZȊ ȂDZǷdzǷȁǴ Ȇȁǽ ȀǽǶdzǯDZǯȁȋ ȀȁǿǯǼǷ ȅȊ ǹǽdz Ƿ ȁdz ǾǿǽȈǴ DZ Visual Studio. Ǒ Solution ȈǴǺǹǼǷȁǴ ǾǿǯDZǽǸ ǹǼǽǾǹǽǸ Ǽǯ ǾǯǾǹǴ ǾǿǽǴǹȁǯ Ƿ DZȊǰǴǿǷȁǴ Add New Item ǝȁǹǿǽǴȁȀȎ dzǷǯǺǽDzǽ DZǽǴ ǽǹǼǽ Add New Item ǹǽȁǽǿǽǴ ǻǽǵǴȁ ǷȀǾǽǺȋǶǽDZǯȁȋȀȎ dzǺȎ ȀǽǶdzǯǼǷȎ ǼǽDZǽǸ HTML-ȀȁǿǯǼǷȅȊ ǑȊǰǴǿǷȁǴ ǽǾȅǷȍ HTML page (HTML-ȀȁǿǯǼǷȅǯ Ƿ ǾǿǷȀDZǽǸȁǴ ǴǸ ǷǻȎ Default.html ǿǷȀ 14-2).
ǟǗǠ 14 2 ǓǽǰǯDZǺǴǼǷǴ ǼǽDZǽDzǽ ȌǺǴǻǴǼȁǯ Ǽǯ ȀǯǸȁ.
Ǭȁǽ ǽǰǴȀǾǴȆǷȁ DZǯǻ ǰǯǶǽDZȂȍ HTML-ȀȁǿǯǼǷȅȂ ǔǴ ǼǴǽǰȄǽdzǷǻǽ ǽȁǿǴdzǯǹȁǷǿǽDZǯȁȋ Ƿ ǾǿǴDZǿǯȁǷȁȋ DZ ȀȁǿǯǼǷȅȂ Ǽǯ ǹǽȁǽǿǽǸ ǰȂdzǴȁ ǿǯȀǾǽǺǯDzǯȁȋȀȎ ǾǿǷǺǽǵǴǼǷǴ Silverlight ǟǯȀȀǻǽȁǿǷǻ ǹǽdz ȁǯǹǽǸ ȀȁǿǯǼǷȅȊ: Dynamic Silverlight Test Page html, body { height: 100%; overflow: auto; } body { padding: 0; margin: 0; } #silverlightControlHost { height: 100%; }
ǓǺȎ ǿǯǶǻǴȈǴǼǷȎ Silverlight Ǽǯ ȀȁǿǯǼǷȅǴ ǷȀǾǽǺȋǶȂǴȁȀȎ ȁǴDz Ǭȁǽ ǽȆǴǼȋ ȂǾǿǽȈǴǼǼȊǸ ǾǿǷǻǴǿ Ƿ ǽǼ ǼǴ DZǹǺȍȆǯǴȁ ǹǽdz dzǺȎ ȂȀȁǯǼǽDZǹǷ Silverlight ǴȀǺǷ ǴDzǽ ǼǴȁ DZ ȀǷȀȁǴǻǴ ǐǽǺǴǴ ǾǽdzǿǽǰǼǽ ǽǰ Ȍȁǽǻ ǿǯȀȀǹǯ ǶȊDZǯǴȁȀȎ DZ ǒǺǯDZǴ ©ǬǺǴǻǴǼȁ ȂǾǿǯDZǺǴǼǷȎ ǰǿǯȂǶǴǿǯ Silverlightª ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ǽǯ ǾǯǿǯǻǴȁǿ source ǹǽȁǽǿǽǻȂ ǶǯdzǯǼǽ ǶǼǯȆǴǼǷǴ app.xap. Chiron ȀǽǶdzǯȀȁ ǴDzǽ ǯDZȁǽǻǯ ȁǷȆǴȀǹǷ ǹǯǹ ǻȊ ȂDZǷdzǷǻ ȆǴǿǴǶ ǻDzǼǽDZǴǼǷǴ ǦȁǽǰȊ [DS-ȃǯǸǺȂ ǰȊǺǽ ǾǿǷȀDZǽǴǼǽ ȁǯǹǽǴ ǷǻȎ DZǯȇ ȃǯǸǺ ǹǽdzǯ dzǽǺǵǴǼ ǼǯǶȊDZǯȁȋȀȎ app. ǠǼǯȆǯǺǯ ǿǯȀȀǻǽȁǿǷǻ ǹǯǹ ȀǽǶdzǯDZǯȁȋ ǾǿǷǺǽǵǴǼǷǴ Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ IronPython Ƿ ȃǯǸǺǯ app.py ǯ ǶǯȁǴǻ ǿǴǯǺǷǶȂǴǻ ȁȂ ǵǴ ȃȂǼǹȅǷǽǼǯǺȋǼǽȀȁȋ Ǽǯ IronRuby Ƿ Dynamic JavaScript.
ǒǺǯDZǯ ǗȀǾǽǺȋǶǽDZǯǼǷǴ dzǷǼǯǻǷȆǴȀǹǷȄ ȎǶȊǹǽDZ DZ Silverlight 2
259
ǓǯǺǴǴ ȀǽǶdzǯdzǷǻ ǹǯȁǯǺǽDz app DZ DZǯȇǴǻ ǑǴǰ-ȀǯǸȁǴ ǓǺȎ ǼǴDzǽ Ȁ ǾǽǻǽȈȋȍ Add New Item DZȊǰǴǿǴǻ ȇǯǰǺǽǼ XML File (XML-ȃǯǸǺ Ƿ ǼǯǶǽDZǴǻ app.xaml. Ǒǽȁ ǾǿǷǻǴǿ ǾǿǽȀȁǽDzǽ XAML ǹǽȁǽǿȊǸ ǻǽǵǼǽ ǾǽǻǴȀȁǷȁȋ DZ Ȍȁǽȁ ȃǯǸǺ:
x:Class="System.Windows.Controls.UserControl"
ǖdzǴȀȋ ǽǾǷȀȊDZǯǴȁȀȎ ǽǰȉǴǹȁ UserControl DZǹǺȍȆǯȍȈǷǸ TextBlock Ǿǽdz ǷǻǴǼǴǻ txtMessage ǓǯǼǼȊǸ ȀǽdzǴǿ ǵǷȁ ȁǴǹȀȁ ©Hello World,ª ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ǽǯ ǶǯǾȎȁȂȍ DZ ǹǽǼȅǴ ȃǿǯǶȊ ǾǽȆǴǻȂ ǽǼǯ ȁǯǻ ǼǯȄǽdzǷȁȀȎ ȀȁǯǼǴȁ ǾǽǼȎȁǼǽ ȆǴǿǴǶ ǻDzǼǽDZǴǼǷǴ ǡǴǾǴǿȋ dzǽǰǯDZǷǻ ȃǯǸǺ ǹǽdzǯ IronPython ǝǾȎȁȋ ǵǴ ȈǴǺǹǼǷȁǴ ǾǿǯDZǽǸ ǹǼǽǾǹǽǸ Ǽǯ ǾǯǾǹǴ app ǑǴǰ-ȀǯǸȁǯ Ƿ DZȊǰǴǿǷȁǴ Add New Item. Ǒ dzǷǯǺǽDzǽDZǽǻ ǽǹǼǴ DZȊǰǴǿǷȁǴ Text File ǡǴǹȀȁǽDZȊǸ ȃǯǸǺ Ƿ ǼǯǶǽDZǷȁǴ ǴDzǽ app.py (py ² ǿǯȀȇǷǿǴǼǷǴ ǷȀǾǽǺȋǶȂǴǻǽǴ dzǺȎ Python). ǜǯ ǿǷȀ 14-3 ǾǿǴdzȀȁǯDZǺǴǼǽ ǹǯǹ dzǽǺǵǼǽ DZȊDzǺȎdzǴȁȋ DZǯȇǴ ǿǴȇǴǼǷǴ Ǽǯ dzǯǼǼȊǸ ǻǽǻǴǼȁ.
ǟǗǠ 14 3 ǠȁǿȂǹȁȂǿǯ ǿǴȇǴǼǷȎ.
ǡǴǾǴǿȋ ǻǽǵǼǽ ǾǿǷȀȁȂǾǯȁȋ ǹ ǿǴdzǯǹȁǷǿǽDZǯǼǷȍ ȃǯǸǺǯ ǹǽdzǯ Python ȆȁǽǰȊ ȀdzǴǺǯȁȋ Ȇȁǽ-ȁǽ ǰǽǺǴǴ ǷǼȁǴǿǴȀ ǼǽǴ ǟǯȀȀǻǽȁǿǷǻ ǹǽdz: from System.Windows import Application from System.Windows.Controls import UserControl def handleClick(sender, eventArgs): sender.Text = sender.Text + " from Python!" class App: def init (self): self.scene = Application.Current.LoadRootVisual(UserControl(),"app.xaml") def start(self): self.scene.txtMessage.MouseLeftButtonUp += handleClick App().start()
ǔȀǺǷ Ȃ DZǯȀ ǴȀȁȋ ǽǾȊȁ ǿǯǶǿǯǰǽȁǹǷ ǾǿǷǺǽǵǴǼǷǸ Silverlight Ǽǯ C# ǷǺǷ VB, ȀǷǼȁǯǹȀǷȀ ǰȂdzǴȁ DZǯǻ ǶǼǯǹǽǻ ǜǯ ǾǿǷǻǴǿ Ȁȁǿǽǹǯ from System.Windows import Application
ȌǹDZǷDZǯǺǴǼȁǼǯ ȀȁǿǽǹǴ Ǽǯ C# using System.Windows;
Ƿ ȂǹǯǶȊDZǯǴȁ Ǽǯ ǾǿǽȀȁǿǯǼȀȁDZǽ ǷǻǴǼ DZ ǹǽȁǽǿǽǻ ǼǯȄǽdzǷȁȀȎ ǹǺǯȀȀ Application.
260
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
ǖǯȁǴǻ ǽǾǿǴdzǴǺȎǴǻ Python-ǹǺǯȀȀ App Ƿ ǶǯdzǯǴǻ ǽǰȉǴǹȁ scene dzǺȎ App ǶǯDzǿȂǵǯȎ XAML-ȃǯǸǺ ǽǾǷȀǯǼǼȊǸ ǿǯǼǴǴ Ǚǯǹ ȆǯȀȁȋ ǽǾǷȀǯǼǷȎ ǹǺǯȀȀǯ ǶǯdzǯǴȁȀȎ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ ǶǯǾȂȀǹǯ def start(self):
Ƿ ǹǽdz ǹǽȁǽǿȊǸ ǰȂdzǴȁ DZȊǾǽǺǼȎȁȋȀȎ DZ Ȍȁǽǻ ǽǰǿǯǰǽȁȆǷǹǴ Ǭȁǽȁ ǹǽdz ǽǾǿǴdzǴǺȎǴȁ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ MouseLeftButtonUp ȌǺǴǻǴǼȁǯ ȂǾǿǯDZǺǴǼǷȎ txtMessage ȁǷǾǯ TextBlock ǹǽȁǽǿȊǸ ǰȊǺ ǽǾǷȀǯǼ ǼǯǻǷ ǿǯǼǴǴ ǜǯǶǽ DZǴǻ ǽǰǿǯǰǽȁȆǷǹ handleClick ǝǰǿǯǰǽȁǹǯ ȈǴǺȆǹǯ Ǡǯǻ ǹǽdz ȌȁǽDzǽ ǽǰǿǯǰǽȁȆǷǹǯ ȀǽǰȊȁǷȎ DZȊDzǺȎdzǷȁ ȀǺǴdzȂȍȈǷǻ ǽǰǿǯǶǽǻ: def handleClick(sender, eventArgs): sender.Text = sender.Text + " from Python!"
ǑȊǾǽǺǼǴǼǷǴ ȌȁǽDzǽ ǹǽdzǯ ǽǰǴȀǾǴȆǷDZǯǴȁ dzǽǰǯDZǺǴǼǷǴ ȃǿǯǶȊ ©from Python!ª ǷǶ Python! DZ ǹǽǼǴȅ ǶǼǯȆǴǼǷȎ ȀDZǽǸȀȁDZǯ Text ǽȁǾǿǯDZǷȁǴǺȎ ǹǽȁǽǿȊǻ DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ ȎDZǺȎǴȁȀȎ TextBlock). ǦȁǽǰȊ DZȊǾǽǺǼǷȁȋ Ȍȁǽ ǾǿǷǺǽǵǴǼǷǴ ǷȀǾǽǺȋǶȂǴȁȀȎ Chiron. ǜǯȀȁǿǽǷȁȋ Visual Studio Ǽǯ ǶǯǾȂȀǹ Chiron ǻǽǵ Ǽǽ ȈǴǺǹǼȂDZ ǾǿǯDZǽǸ ǹǼǽǾǹǽǸ ǻȊȇǷ ȃǯǸǺ ǾǿǽǴǹȁǯ DZ Solution Explorer ǶǯǻǴȁȋȁǴ DZȊ dzǽǺǵǼȊ ǷȀǾǽǺȋǶǽ DZǯȁȋ ȃǯǸǺ ǾǿǽǴǹȁǯ ǯ ǼǴ ȃǯǸǺ ǿǴȇǴǼǷȎ ȃǯǸǺǯ ǾǿǽǴǹȁǯ ǽǰȊȆǼǽ ȎDZǺȎǴȁȀȎ ǾǴǿDZȊǻ dzǽȆǴǿǼǷǻ ȃǯǸǺǽǻ DZ ǿǴȇǴǼǷǷ Ƿ DZȊǰǿǯDZ DZ ǹǽǼȁǴǹȀȁǼǽǻ ǻǴǼȍ ǽǾȅǷȍ Property Pages ǠȁǿǯǼǷȅȊ ȀDZǽǸȀȁDZ ǜǯ Property Pages DZȊǰǴǿǷȁǴ ȀȁǿǯǼǷȅȂ Start Options (ǝǾȅǷǷ ǶǯǾȂȀǹǯ) Ƿ Ǽǯ ǼǴǸ ǽǾȅǷȍ Start External Program (ǖǯǾȂȀȁǷȁȋ DZǼǴȇǼȍȍ ǾǿǽDzǿǯǻǻȂ). ǗȀǾǽǺȋǶȂǸȁǴ ǹǼǽǾǹȂ Ȁ ǻǼǽDzǽȁǽȆǷǴǻ dzǺȎ ǾǴǿǴȄǽdzǯ ǹ ǹǯȁǯǺǽDzȂ DZ ǹǽȁǽǿǽǻ ǼǯȄǽdzǷȁȀȎ Chiron.exe Ǭȁǽ dzǽǺǵǴǼ ǰȊȁȋ ǹǯȁǯǺǽDz C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Tools\Chiron\Chiron.exe. ǑDZǴdzǷȁǴ /b DZ ǾǽǺǴ Command Line Arguments (ǏǿDzȂǻǴǼȁȊ ǹǽǻǯǼdzǼǽǸ ȀȁǿǽǹǷ) Ƿ DZDZǴdzǷȁǴ ǻǴȀȁǽǾǽǺǽǵǴǼǷǴ ǑǴǰ-ȀǯǸȁǯ DZ ǾǽǺǴ Working Directory ǟǯǰǽȆǷǸ ǹǯȁǯǺǽDz ǑȀǴ Ȍȁǽ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ǽǯ ǿǷȀ 14-4.
ǟǗǠ 14 4 ǜǯȀȁǿǽǸǹǯ Visual Studio Ǽǯ ǷȀǾǽǺȋǶǽDZǯǼǷǴ Chiron.
ǡǴǾǴǿȋ ǻǽǵǼǽ DZȊǾǽǺǼǷȁȋ ǼǯȇǴ dzǷǼǯǻǷȆǴȀǹǽǴ ǾǿǷǺǽǵǴǼǷǴ Silverlight ǼǯǵǯDZ F5 DZ Visual Studio. ǖǯǾȂȀ ȁǷȁȀȎ Chiron ǾǽdzȁDZǴǿǵdzǴǼǷǴ ȌȁǽǻȂ DZȊ ȂDZǷdzǷȁǴ DZ ǽǹǼǴ ǹǽǻǯǼdzǼǽǸ ȀȁǿǽǹǷ ǹǽȁǽǿǽǴ ǾǿǴdzȀȁǯDZǺǴǼǽ Ǽǯ ǿǷȀ 14-5.
ǟǗǠ 14 5 Visual Studio DZȊǾǽǺǼȎǴȁ Chiron.
ǒǺǯDZǯ ǗȀǾǽǺȋǶǽDZǯǼǷǴ dzǷǼǯǻǷȆǴȀǹǷȄ ȎǶȊǹǽDZ DZ Silverlight 2
261
ǖdzǴȀȋ ȀǽǽǰȈǯǴȁȀȎ Ȇȁǽ dzǽȀȁȂǾ ǹ ǾǿǷǺǽǵǴǼǷȍ ǽȀȂȈǴȀȁDZǺȎǴȁȀȎ ȆǴǿǴǶ http://localhost:2060. Visual Studio ȁǯǹǵǴ ǶǯǾȂȀȁǷȁ ǰǿǯȂǶǴǿ Ȁ ǾǴǿǴȄǽdzǽǻ Ǿǽ ȌȁǽǻȂ ǯdzǿǴȀȂ Ȇȁǽ ǽǰǴȀǾǴȆǷȁ DZȊDZǽdz Ǽǯ ȌǹǿǯǼ ȀǾǷȀǹǯ ȃǯǸǺǽDZ ǑǴǰ-ǹǯȁǯǺǽDzǯ ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ 14-6.
ǟǗǠ 14 6 ǠǾǷȀǽǹ ȃǯǸǺǽDZ ǹǯȁǯǺǽDzǯ Chiron.
ǑȊǰǴǿǷȁǴ Default.html ȆȁǽǰȊ ȂDZǷdzǴȁȋ ȀDZǽǴ dzǷǼǯǻǷȆǴȀǹǽǴ ǾǿǷǺǽǵǴǼǷǴ Silverlight. Ǒ ǰǿǯȂǶǴǿǴ ǰȂdzǴȁ DZȊ DZǴdzǴǼǽ ȀǽǽǰȈǴǼǷǴ ©Hello Worldª ǹǯǹ ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ. 14-7.
ǟǗǠ 14 7 ǑǯȇǴ ǾǴǿDZǽǴ Silverlight ǾǿǷǺǽǵǴǼǷǴ Ǽǯ Python.
ǡǴǾǴǿȋ ǴȀǺǷ ȈǴǺǹǼȂȁȋ ȁǴǹȀȁ ©Hello World,ª ǾǽȎDZǷȁȀȎ dzǽǾǽǺǼǷȁǴǺȋǼǽǴ ȀǽǽǰȈǴǼǷǴ ©from Python!ª ǿǷȀ 14-8).
ǟǗǠ 14 8 ǓǷǼǯǻǷȆǴȀǹǽǴ ǾǿǷǺǽǵǴǼǷǴ DZ dzǴǸȀȁDZǷǷ.
Ǭȁǽ ǾǿǴdzǴǺȋǼǽ ǾǿǽȀȁǽǴ ǾǿǷǺǽǵǴǼǷǴ Ǽǽ ǽǼǽ dzǴǻǽǼȀȁǿǷǿȂǴȁ ǿǯǰǽȁȂ Dynamic Language Runtime ǓǷǼǯ ǻǷȆǴȀǹǯȎ ȀǿǴdzǯ DZȊǾǽǺǼǴǼǷȎ DZ Silverlight Ƿ ȁǽ ǹǯǹ ǻǽǵǼǽ ǼǯȀȁǿǽǷȁȋ Visual Studio dzǺȎ ǷȀǾǽǺȋǶǽDZǯǼǷȎ dzǷǼǯǻǷȆǴȀǹǷȄ ȎǶȊǹǽDZ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ Ǒ ȀǺǴdzȂȍȈǴǻ ǿǯǶdzǴǺǴ ǿǯȀȀǻǯȁǿǷDZǯǴȁȀȎ ǹǯǹ ǻǽǵǼǽ ǿǴǯǺǷ ǶǽDZǯȁȋ Ȍȁǽ ǵǴ ǾǿǷǺǽǵǴǼǷǴ Ǽǯ IronRuby Ƿ ȂǾǿǯDZǺȎǴǻǽǻ JavaScript.
ǗȀǾǽǺȋǶǽDZǯǼǷǴ Ruby Ƿ JavaScript Ǒ ǾǿǴdzȊdzȂȈǴǻ ǿǯǶdzǴǺǴ ǻȊ ǾǽȌȁǯǾǼǽ ǿǯȀȀǻǽȁǿǴǺǷ ǾǿǽȅǴȀȀ ǼǯȀȁǿǽǸǹǷ Visual Studio dzǺȎ ȀǽǶdzǯǼǷȎ dzǷǼǯ ǻǷȆǴȀǹǷȄ ǾǿǷǺǽǵǴǼǷǸ Ǽǯ IronPython. '\QDPLF /DQJXDJH 5XQWLPH ȁǯǹǵǴ ǾǽdzdzǴǿǵǷDZǯǴȁ ȎǶȊǹǷ Ruby Ƿ
262
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
Dynamic JavaScript ǾǽȌȁǽǻȂ ǿǯȀȀǻǽȁǿǷǻ ǹǯǹ ǻǽǵǼǽ ȀǽǶdzǯȁȋ ȁǯǹǽǴ ǵǴ ǾǿǷǺǽǵǴǼǷǴ Ȁ ǷȄ ǷȀǾǽǺȋǶǽDZǯǼǷ Ǵǻ
ǗȀǾǽǺȋǶǽDZǯǼǷǴ Ruby ǜǯȆǼǴǻ ǾǿǽȅǴȀȀ Ȁ ȀǽǶdzǯǼǷȎ ȀȁǿȂǹȁȂǿȊ ǾǿǽǴǹȁǯ DZǹǺȍȆǯȎ HTML-ȃǯǸǺ Ƿ XAML-ȃǯǸǺ ǯǼǯǺǽDzǷȆǼǽǸ ȁǽǸ Ȇȁǽ ǷȀǾǽǺȋǶǽDZǯǺǯȀȋ dzǺȎ IronPython DZ ǾǿǴdzȊdzȂȈǴǻ ǿǯǶdzǴǺǴ ǜǽ DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ DZ ǾǯǾǹǴ app DZǻǴȀȁǽ ȃǯǸǺǯ app.py dzǺȎ ǹǽdzǯ Ǽǯ Ruby ȀǽǶdzǯǴȁȀȎ ȃǯǸǺ app.rb ǡǯǹǵǴ ǼǴ ǶǯǰȂdzȋȁǴ DZȊǾǽǺǼǷȁȋ DZȀǴ ǼǯȀȁǿǽǸǹǷ dzǺȎ ǶǯǾȂȀǹǯ Chiron ȁǯǹ ǵǴ ǹǯǹ Ȍȁǽ dzǴǺǯǺǽȀȋ DZ ǾǿǴdzȊdzȂȈǴǻ ǾǿǷǻǴǿǴ ǑǴǿǼǷȁǴȀȋ ǹ ǿǷȀ 14- Ǽǯ ǹǽȁǽǿǽǻ ǾǿǴdzȀȁǯDZǺǴǼȊ DZȀǴ ǼǴǽǰȄǽdzǷǻȊǴ ǼǯȀȁǿǽǸǹǷ ǑȀȁǯDZȋȁǴ DZ app.rb ǹǽdz Ǽǯ IronRuby9: include System::Windows include System::Windows::Controls def handleClick(sender, eventArgs) sender.text = "Hello World, from Ruby!" end class App def initialize @scene = Application.Current.LoadRootVisual(UserControl.new(), "app.xaml") end def start @scene.find name('txtMessage').mouse left button up { |sender, args| handleClick(sender, args) } end end App.new.start
Ǚǯǹ DZǷdzǷȁǴ DZȀǴ ǽȆǴǼȋ ǾǽȄǽǵǴ Ǽǯ ǾǿǷǻǴǿ Ȁ IronPython. ǑǹǺȍȆǯȍȁȀȎ ǾǿǽȀȁǿǯǼȀȁDZǯ ǷǻǴǼ System.Windows Ƿ System.Windows.Controls ǖǯȁǴǻ ǽǾǷȀȊDZǯǴȁȀȎ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ handleClick dzǺȎ ǷǶǻǴǼǴǼǷȎ ȁǴǹȀȁǯ Ǿǽ ȈǴǺȆǹȂ ǞǽȀǺǴ ȌȁǽDzǽ ǽǰȉȎDZǺȎǴȁȀȎ ǹǺǯȀȀ App ǙǽǼȀȁǿȂǹȁǽǿ ǹǺǯȀȀǯ ǶǯDzǿȂǵǯǴȁ XAML Ƿ ǷȀǾǽǺȋǶȂǴȁ ǴDzǽ dzǺȎ ǷǼǷȅǷǯ ǺǷǶǯȅǷǷ ǹǺǯȀȀǯ ǠǽǰȊȁǷǴ Start ȀDZȎǶȊDZǯǴȁ ǽǰǿǯǰǽȁȆǷǹ ȀǽǰȊȁǷȎ Ȁ TextBlock txtMessage ǽǾǷȀǯǼǼȊǻ DZ XAML. ǡǴǾǴǿȋ ǾǿǷ DZȊǾǽǺǼǴǼǷǷ ǾǿǷǺǽǵǴǼǷȎ ǻȊ ǾǽǺȂȆǯǴǻ ȁǯǹǷǴ ǵǴ ǿǴǶȂǺȋȁǯȁȊ TextBlock ǽȁǽǰǿǯǵǯǴȁ ©Hello World,ª Ƿ ǶǯȁǴǻ ǹǽDzdzǯ ǾǽǺȋǶǽDZǯȁǴǺȋ ȈǴǺǹǯǴȁ ȁǴǹȀȁ ǹ ȌȁǽǻȂ ȁǴǹȀȁȂ dzǽǰǯDZǺȎǴȁȀȎ ©from Ruby!ª
ǗȀǾǽǺȋǶǽDZǯǼǷǴ Dynamic JavaScript ǦȁǽǰȊ ǷȀǾǽǺȋǶǽDZǯȁȋ JavaScript, DZȊǾǽǺǼǷȁǴ ȁȂ ǵǴ ǾǿǽȅǴdzȂǿȂ Ȇȁǽ DZ ǾǿǴdzȊdzȂȈǷȄ dzDZȂȄ ǾǿǷǻǴǿǯȄ ȁǴ ȀǽǶ dzǯǸȁǴ ǑǴǰ-ȀǯǸȁ DZ Visual Studio Ƿ dzǽǰǯDZȋȁǴ DZ ǼǴDzǽ ȃǯǸǺȊ HTML Ƿ XAML ǜǴ ǶǯǰȂdzȋȁǴ ȁǯǹǵǴ ǼǯȀȁǿǽǷȁȋ ǾǿǽǴǹȁ Ǽǯ ǷȀǾǽǺȋǶǽDZǯǼǷǴ Chiron. Ǚǯǹ Ȍȁǽ ȀdzǴǺǯȁȋ, ǾǽǹǯǶǯǼǽ Ǽǯ ǿǷȀ. 14-4. ǜǯ Ȍȁǽȁ ǿǯǶ DZǻǴȀȁǽ ȃǯǸǺǽDZ app.py ǷǺǷ app.rb DZ ǹǯȁǯǺǽDz app dzǽǰǯDZǺȎǴȁȀȎ ȃǯǸǺ app.jsx ǟǴdzǯǹȁǷǿȂǸȁǴ Ȁǽ dzǴǿǵǷǻǽǴ ȃǯǸǺǯ app.jsx dzǽǰǯDZǺȎȎ DZ ǼǴDzǽ ȀǺǴdzȂȍȈǷǸ JavaScript-ǹǽdz Import("System.Windows.Application") Import("System.Windows.Controls.UserControl") function handleClick(sender, eventArgs) { sender.Text = sender.Text + " from Dynamic JavaScript"; } function App() { this.scene =
9ǠȁǿǽǹǷ
Ȁ "app.xaml Ȑ ^ _sender, args| handleClick(sender, args) } ȕȍ ȌȖȓȎȕȣ ȗȍȘȍȕȖșȐȚȤșȧ ȗȘȐȔ ȕȈțȟȕȖȋȖ ȘȍȌȈȒȚȖȘȈ).
ǒǺǯDZǯ ǗȀǾǽǺȋǶǽDZǯǼǷǴ dzǷǼǯǻǷȆǴȀǹǷȄ ȎǶȊǹǽDZ DZ Silverlight 2
263
Application.Current.LoadRootVisual(new UserControl(), "app.xaml") } App.prototype.start = function() { this.scene.txtMessage.MouseLeftButtonUp += handleClick }
app = new App app.start()
Ǚǯǹ DZǷdzǷȁǴ ǹǽdz Ǿǽ-ǾǿǴǵǼǴǻȂ ǾǿǴdzǴǺȋǼǽ ǾǽǼȎȁǴǼ ǢǾǿǯDZǺȎǴǻȊǸ JavaScript ǷȀǾǽǺȋǶȂǴȁ DZȊǿǯǵǴǼǷǴ Import dzǺȎ dzǽǰǯDZǺǴǼǷȎ ȀȀȊǺǽǹ Ǽǯ ǹǺǯȀȀȊ SystemWindows.Application Ƿ System.Windows.Controls.UserControl. Ǒ JavaScript Ȁǯǻǽ ǾǿǷǺǽǵǴǼǷǴ ȎDZǺȎǴȁȀȎ ȃȂǼǹȅǷǴǸ DZ ǹǽȁǽǿȂȍ dzǽǰǯDZǺȎȍȁȀȎ ȀDZǽǸȀȁDZǯ ǾǽȌȁǽǻȂ scene ȎDZ ǺȎǴȁȀȎ ȆǺǴǼǽǻ ȃȂǼǹȅǷǷ App Ƿ ǽǾǷȀȊDZǯǴȁȀȎ ǾȂȁǴǻ ǶǯDzǿȂǶǹǷ XAML. ǠǽǰȊȁǷǴ MouseLeftButtonUp ǽǰǿǯǰǯ ȁȊDZǯǴȁȀȎ ȃȂǼǹȅǷǴǸ handleClick. Ǭȁǽ ǽǾǿǴdzǴǺȎǴȁȀȎ DZ ȃȂǼǹȅǷǷ start ǾǿǷǺǽǵǴǼǷȎ Ǚǯǹ Ƿ DZ ǾǿǴdzȊdzȂȈǷȄ ǾǿǷǻǴǿǯȄ handleClick dzǽǰǯDZǺȎǴȁ ǽǾǿǴdzǴǺǴǼǼȊǸ ȁǴǹȀȁ DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ Ȍȁǽ ©from Dynamic JavaScriptª ǷǶ Dynamic JavaScript DZ ȀȁǿǽǹȂ DZ txtMessage TextBlock ǽǾǷȀǯǼǼǽDzǽ DZ XAML. ǟǴǶȂǺȋȁǯȁ ǯǰȀǽǺȍȁǼǽ ǯǼǯǺǽDzǷȆǴǼ ǾǿǴdzȊdzȂȈǷǻ dzDZȂǻ ǾǿǷǻǴǿǯǻ ǞǿǷǺǽǵǴǼǷǴ ǽȁǽǰǿǯǵǯǴȁ ȀǽǽǰȈǴǼǷǴ ©Hello Worldª Ƿ DZȊDZǽdzǷȁ dzǽǾǽǺǼǷȁǴǺȋǼȊǸ ȁǴǹȀȁ ǹǽDzdzǯ ǾǽǺȋǶǽDZǯȁǴǺȋ ȈǴǺǹǯǴȁ ȀǽǽǰȈǴǼǷǴ
ǐǽǺǴǴ ȀǺǽǵǼȊǸ ǾǿǷǻǴǿ ǞǴǿDZȊǻ ǾǿǷǺǽǵǴǼǷǴǻ Silverlight, ǹǽȁǽǿǽǴ ȂDZǷdzǴǺǽ ȀDZǴȁ (ǴȈǴ ǹǽDzdzǯ Silverlight ǼǯǶȊDZǯǺȀȎ WPF/E), ǰȊǺǽ ǾǿǷǺǽǵǴǼǷǴ Ȁ ȆǯȀǯǻǷ. Ǚǯǹ ǽǼǽ DZȊDzǺȎdzǷȁ ǾǿǴdzȀȁǯDZǺǴǼǽ Ǽǯ ǿǷȀ 14-9. Ǭȁǽ ǶǯǻǴȆǯȁǴǺȋǼȊǸ ǾǿǷǻǴǿ Silverlight-ǾǿǷǺǽǵǴǼǷȎ ǾǽȁǽǻȂ Ȇȁǽ ǽǼ dzǴǻǽǼȀȁǿǷǿȂǴȁ ǻǼǽDzǷǴ ǾǿǷǼȅǷǾȊ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ DZ Silverlight. ǜǴȁ ǼǴǽǰȄǽdzǷǻǽȀȁǷ ǾǿǽDzǿǯǻǻǷǿǽDZǯȁȋ ȀǯǻǷ ȆǯȀȊ DZȀǴ dzǴǺǯǴȁ ǯǼǷǻǯȅǷȎ Silverlight ǜǯǻ ǼǴǽǰȄǽdzǷǻǽ ȁǽǺȋǹǽ ȂȀȁǯǼǽDZǷȁȋ ȀȁǿǴǺǹǷ ȆǯȀǽDZ DZ ǷȀȄǽdzǼǽǴ ǾǽǺǽǵǴǼǷǴ ȀǽǽȁDZǴȁȀȁDZȂȍȈǴǴ ȀǷȀȁǴǻǼǽǻȂ DZǿǴǻǴǼǷ
ǟǗǠ 14 9 ǦǯȀȊ Ǽǯ Silverlight.
ǠǼǯȆǯǺǯ ǿǯȀȀǻǽȁǿǷǻ XAML dzǺȎ ȆǯȀǽDZ ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ȇȁǽ Ȍȁǽ ǺǷȇȋ ȃǿǯDzǻǴǼȁ XAML ǾǿǴdzȀȁǯDZ ǺȎȍȈǷǸ ȁǿǷ ȀȁǿǴǺǹǷ ȆǯȀǽDZ Ƿ ǷȄ ǯǼǷǻǯȅǷȍ
264
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2
XAML ǼǯȆǷǼǯǴȁȀȎ Ȁ ǿǯǶǻǴȈǴǼǷȎ ȁǿǴȄ ǯǼǷǻǯȅǷǸ DZ ȀǽǽȁDZǴȁȀȁDZȂȍȈǷȄ ȌǺǴǻǴǼȁǯȄ Storyboard ǠȁǿǴǺǹǷ Ȇǯ ȀǽDZ ǻǽǵǼǽ ǿǯȀȀǻǯȁǿǷDZǯȁȋ ǹǯǹ DZǿǯȈǯȍȈǷǴȀȎ ǾǿȎǻȊǴ ǾǽȌȁǽǻȂ dzǺȎ ǷȄ ǯǼǷǻǯȅǷǷ ǷȀǾǽǺȋǶȂǴȁȀȎ ȁǷǾ DoubleAnimation ǽǰǴȀǾǴȆǷDZǯȍȈǷǸ ǷǶǻǴǼǴǼǷǴ ȂDzǺǯ ǾǽDZǽǿǽȁǯ ǞǽdzǿǽǰǼǴǴ ǽ ǿǴǯǺǷǶǯȅǷǷ ȌȁǽDzǽ DZ XAML ǿǯȀȀǹǯǶȊDZǯǴȁ ǒǺǯDZǯ ©ǡǿǯǼȀȃǽǿǻǯȅǷȎ Ƿ ǯǼǷǻǯȅǷȎ DZ XAMLª ǠǺǴdzȂǴȁ ǽǰǿǯȁǷȁȋ DZǼǷǻǯǼǷǴ Ǽǯ ǷǻǴǼǯ ǯǼǷǻǯȅǷǸ: hour animation ǯǼǷǻǯȅǷȎ ȆǯȀǽDZ , minute animation ǯǼǷǻǯȅǷȎ ǻǷǼȂȁ Ƿ second animation ǯǼǷǻǯȅǷȎ ȀǴǹȂǼdz , ȀǽǽȁDZǴȁȀȁDZǴǼǼǽ. ǞǽǻǼǷȁǴ ǽǰ Ȍȁǽǻ ǾǿǷ ǿǯȀ ȀǻǽȁǿǴǼǷǷ ǹǽdzǯ Ǒ ǹǯȆǴȀȁDZǴ ȅǴǺǷ ǹǯǵdzǽǸ ǯǼǷǻǯȅǷǷ ǶǯdzǯǼǯ ǷǻǴǼǽDZǯǼǼǯȎ ȁǿǯǼȀȃǽǿǻǯȅǷȎ hourHandTransform ǡǿǯǼȀȃǽǿǻǯȅǷȎ ȆǯȀǽDZǽǸ ȀȁǿǴǺǹǷ ǿǴǯǺǷǶȂǴȁ ǽȁȀȆǴȁ ȆǯȀǽDZ minuteHandTransform
ǒǺǯDZǯ ǗȀǾǽǺȋǶǽDZǯǼǷǴ dzǷǼǯǻǷȆǴȀǹǷȄ ȎǶȊǹǽDZ DZ Silverlight 2
265
ǡǿǯǼȀȃǽǿǻǯȅǷȎ ǻǷǼȂȁǼǽǸ ȀȁǿǴǺǹǷ ǿǴǯǺǷǶȂǴȁ ǽȁȀȆǴȁ ǻǷǼȂȁ Ƿ secondHandTransform ǡǿǯǼȀȃǽǿǻǯȅǷȎ ȀǴǹȂǼdzǼǽǸ ȀȁǿǴǺǹǷ ǽȁDZǴȆǯǴȁ Ƕǯ ǾǴǿǴǻǴȈǴǼǷǴ ȀǴǹȂǼdzǼǽǸ ȀȁǿǴǺǹǷ ǬȁǷ ȁǿǯǼȀȃǽǿǻǯȅǷǷ ǻǽǵǼǽ ǰȂdzǴȁ ȂDZǷdzǴȁȋ ǼǷǵǴ DZ XAML. ǙǯǵdzǯȎ ȀȁǿǴǺǹǯ ǿǴǯǺǷǶǽDZǯǼǯ ǹǯǹ ǽǰȉǴǹȁ Path Ƿ Ȁ ǹǯǵdzȊǻ ǷǶ ȌȁǷȄ ǹǽǼȁȂǿǽDZ ǯȀȀǽ ȅǷǷǿǽDZǯǼǯ ǽdzǼǯ ǷǶ ȂǾǽǻȎǼȂȁȊȄ DZȊȇǴ ȁǿǯǼȀȃǽǿǻǯȅǷǸ Ǘȁǯǹ ǯǼǷǻǯȅǷǷ ǶǯǾȂȀǹǯȍȁȀȎ DZ Canvas.Loaded Ƿ ǾǽDZȁǽǿȎȍȁȀȎ ǾǽȀȁǽȎǼǼǽ ǽǰǴȀǾǴȆǷDZǯȎ ǾǴǿǴǻǴȈǴǼǷǴ ȀȁǿǴǺǽǹ Ǿǽ ȅǷȃǴǿǰǺǯȁȂ ȆǯȀǽDZ Ǽǯ DzǿǯdzȂȀǽDZ Ƕǯ ǶǯdzǯǼǼȊǸ ǾǿǽǻǴǵȂȁǽǹ DZǿǴǻǴǼǷ ǜǽ ǹǯǹ ǷǼǷȅǷǯǺǷǶǷ ǿǽDZǯȁȋ ǷȄ ȆȁǽǰȊ ǽǼǷ ǾǿǴdzȀȁǯDZǺȎǺǷ ȁǴǹȂȈǴǴ DZǿǴǻȎ" Ǒǽȁ dzǺȎ ȌȁǽDzǽ ǾǽǼǯdzǽǰǷȁȋȀȎ ǼǯǾǷȀǯȁȋ ǹǽdz ǟǴǯǺǷǶǯȅǷȎ ȆǯȀǽDZ DZȊǾǽǺǼȎǴȁȀȎ DZ dzDZȂȄ ǻǽdzȂǺȎȄ ǹǽdzǯ Ǽǯ Ruby ǞǴǿDZȊǸ ² DZȀǾǽǻǽDzǯȁǴǺȋǼȊǸ ǹǺǯȀȀ ȀǽǶ dzǯǼǼȊǸ DzǿȂǾǾǽǸ Silverlight Dynamic Languages ǓǷǼǯǻǷȆǴȀǹǷǴ ȎǶȊǹǷ Silverlight dzǺȎ ǷȀǾǽǺȋǶǽDZǯǼǷȎ DZ Ruby-ǾǿǷǺǽǵǴǼǷȎȄ ǟǯȀȀǻǽȁǿǷǻ ǴDzǽ ǹǽdz: include System::Windows include System::Windows::Controls include System::Windows::Media class SilverlightApplication def application Application.current end def self.use xaml(options = {}) options = {:type => UserControl, :name => "app"}.merge(options) Application.current.load root visual(options[:type].new, "#{options[:name]}.xaml") end def root application.root visual end def method missing(m) root.send(m) end end class FrameworkElement def method missing(m) find name(m.to s.to clr string) end end
ǖdzǴȀȋ ǽǾǿǴdzǴǺȎǴȁȀȎ ǿȎdz DZȀǾǽǻǽDzǯȁǴǺȋǼȊȄ ȃȂǼǹȅǷǸ Ƿ ǽǰȉǴǹȁǽDZ, DZǹǺȍȆǯȎ: x
application (ǾǿǷǺǽǵǴǼǷǴ) tion.current)
ǢǹǯǶȊDZǯǴȁ Ǽǯ ȁǴǹȂȈǴǴ ǾǿǷǺǽǵǴǼǷǴ (ǾǿǽȀȁǽ ǽǰǽǶǼǯȆǯǴȁȀȎ Applica-
x
root (ǹǽǿǴǼȋ) XAML
x
method missing ǾǽǷȀǹ ǻǴȁǽdzǯ Ǿǽ ǷǻǴǼǷ ǝǰǿǯǰǯȁȊDZǯǴȁ ȁǿǯǼȀǺȎȅǷȍ ǷǻǴǼǷ ǻǴȁǽdzǯ DZ Ȁȁǿǽǹǽ DZȊǸ ȃǽǿǻǯȁ clr, Ȇȁǽ ǾǽǻǽDzǯǴȁ ǾǿǷ ǼǯǾǷȀǯǼǷǷ ǹǽdzǯ
x
use xaml (ǷȀǾǽǺȋǶǽDZǯȁȋ xaml) ǢǾǿǯDZǺȎǴȁ ǶǯDzǿȂǶǹǽǸ XAML DZ DZǷǶȂǯǺȋǼǽǴ dzǴǿǴDZǽ
ǢǹǯǶȊDZǯǴȁ Ǽǯ ǹǽǿǼǴDZǽǸ DZǷǶȂǯǺȋǼȊǸ ȌǺǴǻǴǼȁ ǯ ǷǻǴǼǼǽ ȌǺǴǻǴǼȁ DZǴǿȄǼǴDzǽ ȂǿǽDZǼȎ DZ
Ǒ ǹǽdzǴ ǾǿǷǺǽǵǴǼǷȎ ǿǴǯǺǷǶȂȍȈǴDzǽ ȆǯȀȊ ǷȀǾǽǺȋǶȂǴȁȀȎ DZȀǾǽǻǽDzǯȁǴǺȋǼȊǴ ȃȂǼǹȅǷǷ root Ƿ use xaml ǟǯȀ ȀǻǽȁǿǷǻ ǷȄ: require 'Silverlight' class Clock < SilverlightApplication use xaml :type => Canvas def start d = Time.now() root.hour animation.from = from angle d.hour, 1, d.minute/2 root.hour animation.to = to angle d.hour root.minute animation.from = from angle d.minute root.minute animation.to = to angle d.minute
266
ǞǿǽDzǿǯǻǻǷǿǽDZǯǼǷǴ DZ Silverlight 2 root.second animation.from = from angle d.second root.second animation.to = to angle d.second end def from angle(time, divisor = 5, offset = 0) ((time / (12.0 * divisor)) * 360) + offset + 180 end def to angle(time) from angle(time) + 360 end end Clock.new.start
ǝǰǿǯȁǷȁǴ DZǼǷǻǯǼǷǴ Ǽǯ ǾǴǿDZȂȍ ȀȁǿǽǹȂ ǹǽdzǯ require 'Silverlight'
Ȍȁǽ ǽǶǼǯȆǯǴȁ Ȇȁǽ dzǽǺǵǴǼ ǰȊȁȋ DZǹǺȍȆǴǼ ȃǯǸǺ Silverlight.rb ǾǽȁǽǻȂ ǹǺǯȀȀ ǼǯȇǴDzǽ ǾǿǷǺǽǵǴǼǷȎ ǰȂdzǴȁ Ǽǯ ȀǺǴdzǽDZǯȁȋȀȎ ǽȁ ǼǴDzǽ ǖǯȁǴǻ ǽǰȉȎDZǺȎǴȁȀȎ ǹǺǯȀȀ Clock (ǦǯȀȊ) ǾǿǽǷǶDZǽdzǼȊǸ ǽȁ SilverlightApplication (ǽǾǿǴdzǴǺǴǼǼȊǸ DZ Silverlight.rb): class Clock < SilverlightApplication
ǑȊǶȊDZǯǴǻ ȃȂǼǹȅǷȍ use xaml ǷǶ SilverlightApplication Ƿ ǶǯdzǯǴǻ, Ȇȁǽ ǷȀǾǽǺȋǶȂǴǻ XAML Ȁ ǰǯǶǽDZȊǻ ȌǺǴ ǻǴǼȁǽǻ . Ǭȁǽ ǼǯȀǺǴdzǷǴ Silverlight 1, DZ ǹǽȁǽǿǽǻ ǰȊǺ ǴdzǷǼȀȁDZǴǼǼȊǻ ǹǽǿǼǴDZȊǻ ȌǺǴ ǻǴǼȁǽǻ ǓǯǺǴǴ ǾǴǿǴȄǽdzǷǻ ǹ ȃȂǼǹȅǷǷ start ǹǽȁǽǿǯȎ DZȊǶȊDZǯǴȁȀȎ Ǿǽ ǶǯDZǴǿȇǴǼǷǷ ǷǼǷȅǷǯǺǷǶǯȅǷǷ ǝǼǯ ǾǿǷǼǷǻǯǴȁ ȁǴǹȂȈǴǴ DZǿǴǻȎ Ȁ ǾǽǻǽȈȋȍ ȃȂǼǹȅǷǷ Time.now Ƿ ǷȀǾǽǺȋǶȂǴȁ ǴDzǽ dzǺȎ ǽǾǿǴdzǴǺǴǼǷȎ ǶǼǯȆǴǼǷǸ from ǽȁ Ƿ to dzǽ dzǺȎ ȁǿǴȄ ǯǼǷǻǯȅǷǸ ǞǽǻǼǷȁǴ ǯǼǷǻǯȅǷǷ hour animation, minute animation Ƿ second animation? ǡǴǾǴǿȋ ǻǽǵǼǽ ȂDZǷdzǴȁȋ ǹǯǹ ǽǼǷ ǷȀǾǽǺȋǶȂȍȁȀȎ Ǒ Ruby DZȊǶǽDZ ȃȂǼǹȅǷǷ ǽȀȂȈǴȀȁDZǺȎǴȁȀȎ ǾȂȁǴǻ ȂǹǯǶǯǼǷȎ ǴǴ ǷǻǴǼǷ Ƕǯ ǹǽȁǽǿȊǻ ȀǺǴdzȂǴȁ ǾǿǽǰǴǺ Ƿ ȀǾǷȀǽǹ ǾǯǿǯǻǴȁǿǽDZ ȆǴǿǴǶ ǶǯǾȎȁȂȍ ǡǯǹǷǻ ǽǰǿǯǶǽǻ ȂDzǽǺ ǾǿǴdz ȀȁǯDZǺȎȍȈǷǸ ȁǴǹȂȈǴǴ ǿǯȀǾǽǺǽǵǴǼǷǴ ȆǯȀǽDZǽǸ ȀȁǿǴǺǹǷ ǾǽǺȂȆǯǴǻ DZȊǶȊDZǯȎ from angle Ƿ ǾǴǿǴdzǯDZǯȎ DZ ǼǴǴ ȀǽǽȁDZǴȁȀȁDZȂȍȈǷǴ ǾǯǿǯǻǴȁǿȊ ǹǽȁǽǿȊǻǷ DZ dzǯǼǼǽǻ ȀǺȂȆǯǴ ȎDZǺȎȍȁȀȎ ȁǴǹȂȈǴǴ ǹǽǺǷȆǴȀȁDZǽ ȆǯȀǽDZ Ƿ ǹǽ ǺǷȆǴȀȁDZǽ ǻǷǼȂȁ dzǴǺǴǼǼǽǴ Ǽǯ ǞǿǷȆǷǼǯ dzǴǺǴǼǷȎ ǹǽǺǷȆǴȀȁDZǯ ǻǷǼȂȁ Ǽǯ dzDZǯ DZ ȁǽǻ Ȇȁǽ dzǺȎ ȁǿǯǼȀȃǽǿǻǯ ȅǷǸ ǽȁȀȆǴȁ ȂDzǺǽDZ DZǴdzǴȁȀȎ ǽȁ ǼǷǵǼǴǸ ȁǽȆǹǷ ǽǹǿȂǵǼǽȀȁǷ ȁǴ ǶdzǴȀȋ ǼǴǽǰȄǽdzǷǻǽ DZȊǾǽǺǼǷȁȋ ȀǻǴȈǴǼǷǴ Ǽǯ DzǿǯdzȂȀǽDZ ȀǺǴdzǽDZǯȁǴǺȋǼǽ ȁǴǹȂȈǴǴ ǾǽǹǯǶǯǼǷǴ dzǴǺǷȁȀȎ Ǽǯ ȆȁǽǰȊ ©ǾǴǿǴDZǴǿǼȂȁȋª ȂDzǽǺ ǾǿǴdzǽȀȁǯDZ ǺȎǴǻȊǸ ǶǼǯȆǴǼǷǴǻ minute. ǟǯȀȀǻǽȁǿǷǻ ȌȁȂ ȃȂǼǹȅǷȍ: def from angle(time, divisor = 5, offset = 0) ((time / (12.0 * divisor)) * 360) + offset + 180 End
ǑǽǶDZǿǯȈǯȎȀȋ ǹ ǹǽdzȂ ǻǽǵǼǽ ȂDZǷdzǴȁȋ Ȇȁǽ ǼǯȆǯǺȋǼǽǴ ȂȀǺǽDZǷǴ ǾǿǽȀȁǽ ǷȀǾǽǺȋǶȂǴȁ ȌȁȂ ȃȂǼǹȅǷȍ dzǺȎ DZȊ ȆǷȀǺǴǼǷȎ ȀǽǽȁDZǴȁȀȁDZȂȍȈǴDzǽ ȂDzǺǯ ȁǿǯǼȀȃǽǿǻǯȅǷǷ Ȁ ǹǽȁǽǿǽDzǽ ǰȂdzǴȁ ǼǯȆǷǼǯȁȋȀȎ ǯǼǷǻǯȅǷȎ Ƿ ǶǯdzǯǴȁ ǴDzǽ DZ ǹǯȆǴȀȁDZǴ ǶǼǯȆǴǼǷȎ ȀDZǽǸȀȁDZǯ from ǯǼǷǻǯȅǷǷ ǏǼǯǺǽDzǷȆǼǽ ǶǼǯȆǴǼǷǴ ǽǹǽǼȆǯǼǷȎ ǯǼǷǻǯȅǷǷ to ǿǯDZǼǽ DzǿǯdzȂȀǯǻ ǾǺȍȀ ȁǴǹȂȈǴǴ ǶǼǯȆǴǼǷǴ from ǡǯǹǷǻ ǽǰǿǯǶǽǻ ȁǿǯǼȀȃǽǿǻǯȅǷȎ ǽǰǴȀǾǴȆǷȁ ǾǿǽȄǽǵdzǴǼǷǴ ȀȁǿǴǺǹǽǸ DzǿǯdzȂȀǽDZ ǼǯȆǷǼǯȎ ǽȁ ǷȀȄǽdzǼǽDzǽ ǶǼǯȆǴǼǷȎ Ƕǯ ǶǯdzǯǼǼȊǸ ǾǿǽǻǴǵȂȁǽǹ DZǿǴǻǴǼǷ 12 ȆǯȀǽDZ dzǺȎ ȆǯȀǽDZǽǸ ȀȁǿǴǺǹǷ ȆǯȀ dzǺȎ ǻǷǼȂȁǼǽǸ Ƿ ǻǷǼȂȁǯ dzǺȎ ȀǴǹȂǼdzǼǽǸ ȀȁǿǴǺǹǷ ǜǯǹǽǼǴȅ, ǾǿǷǺǽǵǴǼǷǴ ǼǯȆǷǼǯǴȁȀȎ Ȁ ȀǽǶdzǯǼǷȎ ǼǽDZǽDzǽ ȌǹǶǴǻǾǺȎǿǯ ǹǺǯȀȀǯ Clock Ƿ ǴDzǽ ǶǯǾȂȀǹǯ: Clock.new.start
ǡǯǹǷǻ ǽǰǿǯǶǽǻ, Ȁ ǾǽǻǽȈȋȍ Ruby ǻȊ ȀǽǶdzǯǺǷ ȃȂǼǹȅǷǽǼǯǺȋǼǽǴ Silverlight-ǾǿǷǺǽǵǴǼǷǴ ² ǯǼǷǻǷǿǽDZǯǼǼȊǴ ȆǯȀȊ ǹǽȁǽǿȊǴ ǽȁǽǰǿǯǵǯȍȁ ȁǴǹȂȈǴǴ DZǿǴǻȎ.
ǒǺǯDZǯ ǗȀǾǽǺȋǶǽDZǯǼǷǴ dzǷǼǯǻǷȆǴȀǹǷȄ ȎǶȊǹǽDZ DZ Silverlight 2
267
ǖǯǹǺȍȆǴǼǷǴ Ǒ dzǯǼǼǽǸ DzǺǯDZǴ ǾǿǴdzȀȁǯDZǺǴǼȊ dzǷǼǯǻǷȆǴȀǹǷǴ ȎǶȊǹǷ ǾǿǽDzǿǯǻǻǷǿǽDZǯǼǷȎ Ƿ ȀǽǶdzǯǼǽ ǾǿǽȀȁǽǴ ǾǿǷǺǽǵǴǼǷǴ Hello World Ȁ ǷȀǾǽǺȋǶǽDZǯǼǷǴǻ IronPython, IronRuby Ƿ ȂǾǿǯDZǺȎǴǻǽDzǽ JavaScript. ǑȊ ȂDZǷdzǴǺǷ ǹǯǹ ǼǯȀȁǿǯǷ DZǯȁȋ Visual Studio dzǺȎ ǿǯǰǽȁȊ Ȁ ǷǼȀȁǿȂǻǴǼȁǽǻ Chiron ǾǿǷǻǴǼȎǴǻȊǻ dzǺȎ ǾǽȀȁǿǽǴǼǷȎ Ƿ ȂǾǿǯDZǺǴǼǷȎ DZȊ ǾǽǺǼǴǼǷǴǻ dzǷǼǯǻǷȆǴȀǹǷȄ ǾǿǷǺǽǵǴǼǷǸ Ǭȁǽ DZȀǴDzǽ ǺǷȇȋ ǾǿǽȀȁǯȎ ǷǺǺȍȀȁǿǯȅǷȎ dzǽȀȁȂǾǼȊȄ DZǽǶǻǽǵǼǽȀȁǴǸ ǽdzǼǯǹǽ ȌȁǽDzǽ dzǽȀȁǯȁǽȆǼǽ ȆȁǽǰȊ DZdzǽȄ ǼǽDZǷȁȋ DZǯȀ Ǽǯ ǾǿǽdzǽǺǵǴǼǷǴ ȌǹȀǾǴǿǷǻǴǼȁǽDZ Ȁ dzǷǼǯǻǷȆǴȀǹǷǻǷ ȎǶȊǹǯǻǷ Ǘ Ǽǯ Ȍȁǽǻ ǼǯȇǴ ǶǼǯǹǽǻȀȁDZǽ Ȁ Silverlight ǾǽdzǽȇǺǽ ǹ ǹǽǼȅȂ ǙǽDzdzǯ DZȊ DZȊǰǷǿǯǺǷ ȌȁȂ ǹǼǷDzȂ DZǴǿǽȎȁǼǽ DZǯȀ ǷǼȁǴǿǴȀǽDZǯǺǽ Ȇȁǽ ȁǯǹǽǴ Silverlight Ƿ Ȇȁǽ ǻǽǵǼǽ ȀdzǴǺǯȁȋ Ȁ ǴDzǽ ǾǽǻǽȈȋȍ ǙǽDzdzǯ Ȏ ǾǷȀǯǺ ǴǴ Ȏ ǼǴ ȄǽȁǴǺ ȀǽǶdzǯDZǯȁȋ ǷȀȆǴǿǾȊDZǯȍȈǷǸ ȌǼȅǷǹǺǽǾǴdzǷȆǴȀǹǷǸ ȀǾǿǯDZǽȆǼǷǹ Ǯ ǾǿǽȀȁǽ ȄǽȁǴǺ ǾǿǴdzȀȁǯDZǷȁȋ DZȀǴ ǶǯǻǴȆǯ ȁǴǺȋǼȊǴ DZǽǶǻǽǵǼǽȀȁǷ Silverlight 2 DZ ǹǯǹ ǻǽǵǼǽ ǰǽǺǴǴ dzǽȀȁȂǾǼǽǸ ȃǽǿǻǴ ȆȁǽǰȊ DZȊ ǻǽDzǺǷ DZǶȎȁȋ ǹǼǷDzȂ ǽȁǹǿȊȁȋ ǺȍǰȂȍ DzǺǯDZȂ Ǿǿǽǿǯǰǽȁǯȁȋ ǴǴ Ƿ ǾǽǼȎȁȋ Ȇȁǽ ǾǿǴdzȀȁǯDZǺȎǴȁ ȀǽǰǽǸ Ȍȁǯ ȁǴȄǼǽǺǽDzǷȎ Ƿ ǶǯȄǽȁǴǺǷ ǾǽǸȁǷ dzǯǺȋȇǴ. ǜǯdzǴȍȀȋ, DZȊ ǾǽǺȂȆǷǺǷ ȁǯǹǽǴ ǵǴ ȂdzǽDZǽǺȋȀȁDZǷǴ ǽȁ ǿǯǰǽȁȊ Ȁ ȌȁǽǸ ǹǼǷDzǽǸ ǹǯǹǽǴ ǷȀǾȊȁȊDZǯǺ Ȏ ǾǿǷ ǴǴ Ǽǯ ǾǷȀǯǼǷǷ!
ǞǿǴdzǻǴȁǼȊǸ ȂǹǯǶǯȁǴǺȋ .NET Framework 3.x ...................................................................................... 17 CLR ..................................................................................... 18 ̨̛̭̦̖̔̌̚ ̨̛̛̪̬̣̙̖̦̜ ............................................... 53ʹ70 .NET͕ ̨̛̛̥̖̜̭̯̖̏̌̔̏̚ ̛ ̦̦̼̖̔̌ ................................. 196ʹ99 ....................................................................................... 27 ADO.NET ................................................................................ 18 AJAX ....................................................̭̥͘ ̡̯̙̖̌ ASP.NET AJAX ̨̛̭̦̖̔̌̚ ̨̨̭̖̬̖̬̦̏̐ ̨̛̛̪̬̣̙̖̦́ ̛̬̖̥̖̦̏ ......... 191ʹ92 ̨̛̭̦̖̔̌̚ ̣̖̥̖̦̯̾̌ ̨̨̛̯̬̙̖̦̍̌́ ̛̬̖̥̖̦̏ ........... 192ʹ94 App.xaml ̨̪ ̸̨̛̱̥̣̦̌̀ ....................................................... 35 App.xaml͕ ̨̪ ̸̨̛̱̥̣̦̌̀ ...................................................... 35 AppManifest.xml .................................................................... 59 ASP.NET AJAX ....................................................... 191, 194ʹ204 Assemblyinfo.cs ..................................................................... 59 ATOM͕ ̨̨̛̛̭̪̣̦̖̽̏̌̚ SyndicatedFeed ̣̔́ ̨̭̯̱̪̔̌ 199ʹ201 Avalon .................................................................................... 20 %HJLQ6WRU\ERDUG ȈȕȐȔȈȞȐȐ ..................................... 109 createObjectEx͕ ̪̬̥̖̯̬̼̌̌ .......................................... 120ʹ22 CSS/DHTML͕ ̏ ̨̛̥̖̣̔ ̛̪̬̖̭̯̣̖̦̔̌̏́ ................................ 17 Deep zoom ̡̨̭̪̬̯̾ ̵̥̖̯̦̦̼̌̔̌ ...................................................... 233 Deep Zoom ..................................................................... 229ʹ40 ̨̨̛̛̭̪̣̦̖̽̏̌̚ ̛̥̼̹ ̛ ̸̵̨̡̛̛̣̖̭̐ ̡̨̨̛̬̦̯̔̌ ..... 235ʹ37 ̶̡̨̡̛̛̣̣̖ ................................................................. 238ʹ40 ̡̨̬̖̯̬̔̌ ................................................................... 231ʹ34 ̨̛̭̦̖̔̌̚ ̨̡̪̬̖̯̌ ..................................................... 234ʹ35 ̨̛̭̦̖̔̌̚ ̴̶̡̨̨̛̛̱̦̦̣̦̭̯̌̽ ̨̛̛̥̭̹̯̬̦̌̌̍̏̌́ ̭ ̨̨̛̛̭̪̣̦̖̥̽̏̌̚ ̡̨̣̖̭̌ ̛̥̼̹ ........................... 237ʹ38 Default.aspx ........................................................................... 62 Default.html................................................................. 26ʹ27 EventTrigger ..................................................................... 108ʹ9 Expression Blend ........................................................ 23, 25ʹ28 App.xaml ̨̪ ̸̨̛̱̥̣̦̌̀................................................... 35 ̨̛̼̪̣̦̖̦̖̏ ̨̛̛̪̬̣̙̖̦́ ................................................ 36 ̛ ̶̛̛̦̥̌̌́ ............................................................... 115ʹ19 ̨̛̛̦̯̖̬̬̦̦̐̏̌̌́ ̭̬̖̔̌ ̨̡̛̬̬̯̌̌̍̚ ;IDE) .... 32, ̭̥͘ ̡̯̙̖̌ Expression Blend IDE ̸̡̨̨̨̨̥̪̦̦̼̖̏ ̛̦̭̯̬̱̥̖̦̯̼................................... 43ʹ48 ̶̨̛̛̪ ̨̨̨̨̛̣̔̌̐̏̐ ̨̡̦̌ New Project ............................. 33 ̨̡̨̛̛̪̬̖̯̬̦̖̏̌ ̶̛̛̦̥̜̌̌ ....................................... 50ʹ52 ̛̬̥̖̺̖̦̖̌̚ ̛ ̨̡̦̭̯̬̜̌̌ ̵̛̱̣̦̼̏̌̽̚ ̨̣̖̥̖̦̯̾̏ ... 48ʹ49 ̛̬̥̖̺̖̦̖̌̚ ̛ ̨̡̦̭̯̬̜̌̌ ̨̣̖̥̖̦̯̾̏ ̛̱̪̬̣̖̦̌̏́ ... 49ʹ50 ̭̯̦̬̯̦̌̔̌̌́ ʦ̖̍-̶̛̭̯̬̦̌̌............................................... 26 ̶̛̭̯̬̦̌̌ ̨̪ ̸̨̛̱̥̣̦̌̀ ............................................ 34ʹ35 ̛̯̪̼ ̨̡̨̪̬̖̯̏ Silverlight.................................................. 25 ̴̜̣̼̌ ̭ ̼̖̣̖̦̦̼̥̏̔ ̡̨̨̥̔........................................... 35 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ ŽƌĚĞƌ ............................................ 48 Expression Blend IDE .............................................................. 32 268
̪̦̖̣̌̽ ̨̛̛̥̖̜̭̯̜̏̌̔̏̚ .................................................. 39 ̪̦̖̣̌̽ ̨̛̦̭̯̬̱̥̖̦̯̏....................................................... 38 ̪̦̖̣̌̽ ̨̡̪̬̖̯̌ ........................................................... 40ʹ41 ̪̦̖̣̌̽ ̨̭̜̭̯̏̏ ........................................................... 41ʹ42 ̸̨̬̌̍̌́ ̵̨̨̪̖̬̦̭̯̏̽ ................................................. 39ʹ40 Expression Design .................................................................. 23 ̨̨̨̛̣̖̔̌̐̏ ̨̡̨̦ Export XAML................................... 23ʹ24 ̛ Silverlight .................................................................. 23ʹ25 ̨̛̪̖̬̙̖̥̼̖̔̔̏̌ ̴̨̬̥̯̼̌ ̴̸̵̡̛̛̬̖̭̐̌ ̴̨̜̣̌̏ ......... 23 ̡̨̛̭̪̬̯̬̱̖̥̼̖̾ ̛̯̪̼ ̨̛̛̬̙̖̦̜̍̌̚.............................. 23 Expression Encoder .................................................... 23, 28ʹ30 Expression Media ................................................................... 23 Expression Studio ̛ Silverlight .................................................................. 22ʹ28 ̛̦̭̯̬̱̥̖̦̯̼ ..................................................................... 22 Expression Web ..................................................................... 23 ExpressionEncoder ̴̨̨̛̭̬̥̬̦̦̼̜̏̌ ̛̥ ̛̥̖̪̣̖̖̬̔̌ ................................. 31 +70/ ȌȖșȚțȗ ș șȍȘȊȍȘȕȖȋȖ ȥȓȍȔȍȕȚȈ țȗȘȈȊȓȍȕȐȧ........................................................... 249ʹ50 ImageBrush ...................................................................... 79ʹ81 Java͕ ̛ Silverlight............................................................ 186ʹ91 JavaScript Dynamic ..................................................................... 263ʹ64 ̡̣̭̭̌ scene ........................................................................ 28 ̡̣̭̭̼̌ ̡̨̨̨̛̬̱̪̭̦̐ ̨̏̏̔̌ ....... 222ʹ24, ̭̥͘ ̡̯̙̖̌ ʶ̣̭̭̼̌ ̡̨̨̨̛̬̱̪̭̦̐ ̨̏̏̔̌ ̣̔́ JavaScript ̶̨̛̛̬̦̐̌̌́̚ ̨̛̛̥̖̜̭̯̏̌̔̏́̚ ̭ ̨̭̖̬̖̬̥̏ ............. 191ʹ94 ̴̜̣̌ ̭ ̼̖̖̣̖̦̦̼̥̏̔̔ ̡̨̨̥̔ Page.xaml........................ 28 JavaScript DOM API.......................................................... 18ʹ19 JavaScript Object Notation (JSON) ............................... 120, 194 JSP͕ ̨̨̛̯̬̙̖̦̖̍̌ Silverlight ......................................... 190ʹ91 LinearGradientBrush .................................................. 21, 73ʹ75 LINQ ....................................................................................... 18 Media Encoder ....................................................................... 29 MP3........................................................................................ 19 MySQL Query Browser ......................................................... 179 Page.xaml ............................................................................... 25 JavaScript-̴̜̣̌ ̭ ̼̖̣̖̦̦̼̥̏̔ ̡̨̨̥̔ ............................ 28 ̨̪ ̸̨̛̱̥̣̦̌̀ ............................................................ 34ʹ35 Page.xaml.js ........................................................................... 25 PHP͕ ̛ Silverlight ............................................................ 177ʹ86 RadialGradientBrush ........................................................ 76ʹ79 RIA................. ̭̥͘ ʻ̭̼̺̖̦̦̼̖̌ ̡̛̛̦̯̖̬̯̦̼̖̌̏ ̨̛̛̪̬̣̙̖̦́ RSS͕ ̨̨̛̛̭̪̣̦̖̽̏̌̚ SyndicatedFeed ̣̔́ ̨̭̯̱̪̔̌ .... 199ʹ201 Ruby ;̸̡̛̛̛̦̥̖̭̜̔̌ ̡̼́̚ ̨̨̛̛̪̬̬̥̥̬̦̐̌̏̌́Ϳ .............. 263 scene.handleLoad .................................................................. 28 Silverlight 1 Site ..................................................................... 33 Silverlight 2 Application ................................................... 25, 33
Silverlight Application Wizard ................................................ 56 SilverlightControlHost ............................................................ 27 SolidColorBrush ................................................................ 21, 73 Solution͕ ̦̌ ̛̪̦̖̣̌ ̨̡̪̬̖̯̌ ................................................. 41 Storyboard ̶̛̛̦̥̌̌́ .......................................................... 50, 109, 116 SyndicatedFeed ............................................................ 199ʹ201 Triggers............................................................................. 108ʹ9 User Experience (UX). ̭̥͘ ʦ̨̛̛̥̖̜̭̯̖̌̔̏̚ ̭ ̨̨̪̣̯̖̣̖̥̽̏̌̚, ̭̥͘ ʦ̨̛̛̥̖̜̭̯̖̌̔̏̚ ̭ ̨̨̪̣̯̖̣̖̥̽̏̌̚ UserControl ̨̛̣̖̦̖̔̍̌̏ TextBlock ...................................................... 36 ̛ ̶̛̭̯̬̦̌̌ ̨̪ ̸̨̛̱̥̣̦̌̀ ............................................... 35 VideoBrush ..................................................................... 81, 220 Visual studio ̨̛̭̦̖̔̌̚ ̨̛̛̪̬̣̙̖̦́ Silverlight ............................. 168ʹ72 Visual Studio ̨̨̨̛̣̖̔̌̐̏ ̨̡̨̦ New Project .......................................... 55 ̨̡̪̬̖̯ ̣̖̥̖̦̯̾̌ ̛̱̪̬̣̖̦̌̏́ Silverlight ........... ̭̥͘ ʿ̨̡̬̖̯ ̣̖̥̖̦̯̾̌ ̛̱̪̬̣̖̦̌̏́ Silverlight ̨̡̪̬̖̯ ̣̖̥̖̦̯̾̌ ̛̱̪̬̣̖̦̌̏́ Silverlight ʦ̖̍-̨̡̪̬̖̯ .............................................................. 62ʹ63 ̨̛̭̦̖̔̌̚ ̛̬̼̐ ̦̌ ^ŝůǀĞƌůŝŐŚƚ Ϯ .................................... 64ʹ70 ̨̛̭̦̖̔̌̚ ̨̛̛̪̬̣̙̖̦́ Silverlight ............................... 55ʹ57 ̨̡̱̭̯̦̌̏̌ ̨̛̦̭̯̬̱̥̖̦̯̏ ............................................ 53ʹ55 WCF͕ ̛ Silverlight ............................................................. 201ʹ4 Web Services͕ ̨̛̛̥̖̜̭̯̱̺̖̏̌̔̏̀̚ ̭ ̨̭̖̬̖̬̥̏ ̨̛̛̪̬̣̙̖̦́ ............................................................ 194ʹ204 Windows Presentation Foundation........................................ 20 WMA ...................................................................................... 19 WMV ...................................................................................... 19 WPF Application (.exe) ........................................................... 33 WPF Control Library ............................................................... 33 x Name.......................................................................... 20, 181 XAML (Extensible Application Markup Language).................. 16 ̛̼̬̖̦̖̏̌̚ ......................................................................... 94 ȋȍȕȍȘȐȘȖȊȈȕȐȍ Ȑȏ 3+3 Ȑ 0\64/ .................. 181ʹ85 ̸̨̡̛̛̖̥̖̯̬̖̭̖̐ ̣̖̥̖̦̯̼̾ .............................................. 94 ̨̨̡̬̯̍̌̍̌ ̨̡̛̛̹̍ ̸̡̡̨̨̛̛̭̦̯̭̖̭̌̐ ̨̬̬̌̍̌̚ .......... 128 ̴̛̱̬̼̐.......... 86ʹ94, ̭̥͘ ̡̯̙̖̌ ̛̛̪̭̌̚ ̣̔́ ̵̭̖̏ ̴̛̱̬̐ ̏ ̨̨̛̯̖̣̦̭̯̔̽ ̸̨̡̛̪̣̖̦̖̔̀ ̨̛̛̪̬̣̙̖̦̜ .................... ̭̥͘ ʿ̸̨̡̛̣̖̦̖̔̀ ̨̛̛̪̬̣̙̖̦̜ ̨̹̣̦̌̍ ̵̦̦̼̔̌............................................................... 160 yD>͕ ̸̡̨̨̨̨̥̪̦̦̼̖̏ ̨̭̜̭̯̏̏̌ ................................... 71ʹ72 XAML-̨̹̣̦̌̍................................................................ 179ʹ81 XML ........................................................................................ 20 ʤ̸̨̡̨̛̯̥̯̖̭̖̏̌ ̨̨̛̛̭̪̬̖̖̦̖̏̏̔̚ ................................... 211 ʤ̶̛̛̦̥̌́ ...................................................................... 108ʹ15 %HJLQ6WRU\ERDUG Ȑ 6WRU\ERDUG ............................. 109 Expression Blend .......................................................... 50ʹ52 ̛ Expression Blend ..................................................... 115ʹ19 ̸̡̣̖̼̖̀̏ ̡̬̼̌̔ ....................................................... 112ʹ15
̨̛̪̬̖̖̣̖̦̖̔ .................................................................. 108 ̪̬̥̖̯̬̼̌̌ ........ 109ʹ12, ̭̥͘ ̡̯̙̖̌ ʿ̬̥̖̯̬̼̌̌ ̶̛̛̛̦̥̌̌ ̛̯̪̼................................................................................... 22 ̛̯̬̖̬̼̐̐ ̛ ̛̯̬̖̬̼̐̐ ̨̛̭̼̯̜̍.................................. 108ʹ15 ʤ̵̡̛̬̯̖̯̱̬̌ Silverlight .................................................... 18ʹ19 ʤ̵̡̛̬̯̖̯̱̬͕̌ Silverlight ................................................... 18ʹ19 ʤ̴̴̛̦̦̌́ ̶̛̥̯̬̌̌............................................................. 106 ʥ̌̌̚ ̵̦̦̼̔̌ ̦̌ ̨̨̭̯̬̦̖ ̭̖̬̖̬͕̏̌ ̨̛̭̦̖̔̌̚ ............... 178ʹ79 ʥ̌̌̚ ̵̦̦̼͕̔̌ ̦̌ ̨̨̭̯̬̦̖ ̭̖̬̖̬̏̌ ............................... 178ʹ79 ʥ̨̡̛̛̣̯̖̍̌ system.Xml.Linq ........................................ 158ʹ59 ʥ̨̡̛̛̛̣̯̖̍ ̡̨̣̭̭̌̏ ..................................................... 172ʹ76 ʥ̴̶̛̛̱̖̬̌́̚, ̛̱̪̬̣̖̦̖̌̏ ........................................... 214ʹ15 ʦ̨̏̔ ̨̨̪̭̬̖̭̯̥̔̏ ̛̥̼̹ ................................................... 221 ʦ̨̏̔ ̭ ̨̨̪̥̺̽̀ ̪̖̬̌ ........................................................ 221 ʦ̖͕̍ ̨̛̥̖̣̔ ̨̨̛̛̪̬̬̥̥̬̦̐̌̏̌́ ̛ ̛̪̬̖̭̯̣̖̦̔̌̏́ ..... 18ʹ19 ʦ̖̍-̨̡̪̬̖̯͕ Visual Studio ................................................ 62ʹ63 ʦ̖̍-̶̛̭̯̬̦̌̌ ̨̪ ̸̨̛̱̥̣̦̌̀ ......................................... 26ʹ28 ʦ̨̛̛̥̖̜̭̯̖̌̔̏̚ ̭ ̨̨̪̣̯̖̣̖̥̽̏̌̚ . ̭̥͘ User Experience (UX), ̭̥͘ User Experience (UX) ʦ̨̛̛̥̖̜̭̯̱̺̖̌̔̏̀̚ ̭ ̨̭̖̬̖̬̥̏ ̨̛̛̪̬̣̙̖̦́ ASP.NET AJAX ̛ ʦ̖̍-̛̭̖̬̭̼̏ ................................. 194ʹ204 Silverlight ̛ Java ........................................................ 186ʹ91 Silverlight ̛ PHP ......................................................... 177ʹ86 Silverlight ̛ WCF .......................................................... 201ʹ4 ̛ JavaScript ................................................................ 191ʹ94 ʦ̨̛̖̔.......... ̭̥. ̡̯̙̖̌ ˑ̣̖̥̖̦̯̼ ̛̱̪̬̣̖̦̌̏́ MediaElement ̡̛̛̬̹̦̖͕̌̌̏̌̚ ̨̨̛̛̭̪̣̦̖̽̏̌̚ VideoBrush .................. 220 ̛̪̭̌̽̚ ̨̨̨̛̭̖̬̙̥̔̐ ̵̨̪̖̬̏ ......................................... 210 ̨̛̪̬̬̖̭̭̦̐̏̌́ ̡̬̱̌̐̌̚̚ ........................................... 214ʹ15 ʦ̛̱̣̦̼̖̌̽̚ ̨̭̜̭̯̏̏̌ XAML ........................................... 81ʹ85 ̨̛̪̖̖̦̖̏̔ ̡̨̱̬̭̬̌ ............................................................ 82 ̸̨̨̪̬̬̦̭̯̌̽̚ .................................................................... 82 ̨̭̜̭̯̏̏̌ ̛̦̌̔̌́̚ ̨̬̥̖̬̌̏̚ ̛ ̨̨̨̛̥̖̭̯̪̣̙̖̦́...... 81ʹ82 ̨̨̭̜̭̯̏̏ Stroke ........................................................... 82ʹ85 ʦ̛̱̣̦̼̖̌̽̚ ̣̖̥̖̦̯̼͕̾ ̛̬̥̖̺̖̦̖̌̚ ̛ ̨̡̦̭̯̬̜̌̌ ....... 48ʹ49 ʦ̨̨̛̛̭̪̬̖̖̦̖̏̔̚ ̨̛̖͕̏̔ ̭ ̨̨̪̥̺̽̀ ̣̖̥̖̦̯̾̌ ̛̱̪̬̣̖̦̌̏́ MediaElement ............................................................. 206ʹ7 ʦ̨̨̛̛̭̪̬̖̖̦̖͕̏̔̚ ̸̨̡̨̛̯̥̯̖̭̖̌̏̌ .................................. 211 ʦ̬̖̥̖̦̦̌́ ̡̹̣̌̌ ̏ ̡̨̡̬̭̬̖̌̌̔̏ ................................................................... 22 ̡̨̛̛̬̖̯̬̦̖̔̌̏̌ ............................................................... 51 ʦ̛̼̬̖̦̖̌̚ ̏ XAML ............................................................................... 94 ̛̭̬̦̖̦̖̌̏ ̭ ̨̡̨̬̖̜̍̚͘ ..................................................... 64 ʧ̸̨̡̛̛̖̥̖̯̬̖̭̖ ̨̡̻̖̯̼̍ .............................................. 86ʹ94 ʧ̸̨̡̛̛̖̥̖̯̬̖̭̖ ̣̖̥̖̦̯̼̾ Silverlight ..................................................................... 20ʹ22 ̏ XAML ................................................................... 87ʹ94, 94 ̛̼̬̖̦̖̏̌̚ ̛̛̥̱̣̯̥̖̽̔̌ ............................................... 210 ̨̡̻̖̯̍ ArcSegment ........................................................... 88 ȖȉȢȍȒȚ %H]LHU6HJPHQW.............................................. 89 ̨̡̻̖̯̍ LineSegment .......................................................... 88 ̨̡̻̖̯̍ PolyBezierSegment .......................................... 89ʹ90 ̨̡̻̖̯̍ PolyLineSegment ................................................... 89
̨̡̻̖̯̍ PolyQuadraticBezierSegment .......................... 91ʹ92 ̨̡̻̖̯̍ QuadraticBezierSegment ................................. 90ʹ91 ʧ̛̬̖̦̯̦̌̔̌́ ̡̛̣̌̏̌̚............................................................ 21 ʧ̛̬̖̦̯̦̌̔̌́ ̡̛̭̯̽ ................................................................ 21 ʪ̸̡̛̛̛̦̥̖̭̖̌ ̡̛̼́̚ ̨̨̛̛̪̬̬̥̥̬̦̐̌̏̌́ Dynamic JavaScript .................................................... 263ʹ64 Ruby ................................................................................. 263 ̨̛̪̬̖̖̣̖̦̖̔................................................................... 258 ̨̛̛̪̬̣̙̖̦̖ ̦̌ IronPython ...................................... 258ʹ62 ̛̪̬̥̖̬ ̶̛̛̛̬̖̣̌̌̚ ̸̨̭̌̏ ....................................... 264ʹ68 ʯ̡̬̱̌̐̌̚, ̛̱̪̬̣̖̦̖̌̏ ................................................... 214ʹ15 ʯ̡̱͕̏ ̛̱̪̬̣̖̦̖̌̏ ................................................................ 211 ʰ̬̐̌ ̦̌ Silverlight 2 ̛̛̦̪̭̦̖̌̌ ̡̨̔̌ ̛̬̼̐ .....................64, ̭̥͘ ̡̯̙̖̌ ʶ̨̔ ̛̬̼̐ ̨̛̭̦̖̔̌̚ UI ̏ XAML .......................................................... 64 ʰ̦̭̯̬̱̥̖̦̯ Pen .................................................................... 48 ʰ̦̭̯̬̱̥̖̦̯ Pencil ................................................................. 48 ʰ̦̯̖̬̦̖̯͕ ̶̛̛̭̖̦̬̌ ̨̭̯̱̪̔̌ ̡ ̴̶̨̛̛̛̦̬̥̌ ...................... 16 ʶ̛̛̭̯............................................... 21, ̭̥͘ ̡̯̙̖̌ ʶ̛̛̭̯ XAML ̛̦̖̌̔̌̚ ̨̭̜̭̯̏̏̌ Stroke .................................................. 83 ̨̨̛̛̭̪̣̦̖̽̏̌̚ ̣̔́ ̨̛̪̬̖̖̣̖̦̔́ ̴̶̨̛̛̯̬̦̭̬̥̌̌ ..... 100 ʶ̛̛̭̯ XAML ImageBrush .................................................................. 79ʹ81 LinearGradientBrush .................................................... 73ʹ75 RadialGradientBrush .................................................... 76ʹ79 SolidColorBrush.................................................................. 73 VideoBrush......................................................................... 81 ʶ̛̣̯̱̬͕̌̏̌̌ ̣̖̥̖̦̯̼̾ ̛̱̪̬̣̖̦̌̏́ ̣̔́ ̖̖ ̨̨̛̛̭̪̣̦̽̏̌́̚ ......................................................................................... 155 ʶ̣̭̭̌ Scene ........................................................................... 28 ʶ̣̭̭̌ WebClient ............................................................ 196ʹ97 ʶ̣̭̭̌ WebRequest ........................................................ 197ʹ99 ʶ̣̭̭̼̌ ̡̨̨̨̛̬̱̪̭̦̐ ̨̏̏̔̌ ̣̔́ JavaScript ̬̱̥̖̦̯̼̌̐ ̨̛̭̼̯̜̍ ̛̥̼̹ ....................................... 224ʹ25 ̨̨̛̛̪̬̬̥̥̬̦̖̐̌̏̌ .................................................. 225ʹ29 ̛̯̪ Stroke ........................................................................ 223 ̛̯̪ StrokeCollection ........................................................ 222 ̛̯̪ StylusPoint................................................................. 224 ʶ̣̭̭̼̌ ̡̨̨̨̛̬̱̪̭̦̐ ̨̏̏̔̌ ̣̔́ JavaSkript ̛̯̪ StylusPointCollection........................................... 223ʹ24 ʶ̡̨̛̣̖̦̯̭̖ ̨̛̛̪̬̣̙̖̦̖ ̣̔́ ̨̨̛̯̬̙̖̦̍̌́ ̛̬̖̥̖̦͕̏ ̨̛̭̦̖̔̌̚ ................................................................... 192ʹ94 ʶ̸̣̖̼̖̀̏ ̡̬̼̌̔ .......................................................... 112ʹ15 ̨̛̣̖̦̖̔̍̌̏ ....................................................................... 51 ̡̨̛̭̬̖̯̦̜̔ ̶̛̛̛̦̥̌̌ ............................................... 114 ̛̦̖̌̔̌̚ ̛̛̥̖̦̖̦̜̚ ................................................... 117 ̛̣̦̖̜̦̼̖ .................................................................... 113 ̨̭̣̙̖̦̦̜̐̌ ̶̛̛̛̦̥̌̌ ......................................... 114ʹ15 ʶ̨̡̦̪̌ Assembly Information ......................................... 58ʹ59 ʶ̨̡̛̦̪ ̏ StackPanel ....................................................................... 46 ̡̡̌ ̣̖̥̖̦̯̼̾ ̛̱̪̬̣̖̦̌̏́ ̨̨̡̨̨̪̣̯̖̣̭̽̏̌̽̐̚ ̴̛̦̯̖̬̖̜̭̌ ................................................................... 49 ̨̨̬̭̪̣̙̖̦̦̼̖̌ ̸̭̣̱̜̦̼̥̌ ̨̨̬̥̍̌̚............................. 43
̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ RepeatButton ......................... 164ʹ65 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ ToggleButton .......................... 164ʹ65 ʶ̨̡̛̦̪͕ ̨̨̬̭̪̣̙̖̦̦̼̖̌ ̸̭̣̱̜̦̼̥̌ ̨̨̬̥̍̌̚ .................. 43 ʶ̨̔ ̛̬̼̐ ̶̶̛̛̛̛̛̦̣̌̌́̚ ̡̭̯̬̱̯̱̬ ̵̦̦̼̔̌ .............................. 64ʹ65 ̨̨̡̬̯̍̌̍̌ ̨̨̡̨̨̪̣̯̖̣̭̽̏̌̽̐̚ ̣̖̥̖̦̯̾̌ ̛̱̪̬̣̖̦̌̏́ . 68ʹ 69 ̨̨̡̛̯̬̭̏̌ ̨̨̨̛̬̐̏̐ ̨̪̣́ ........................................... 67ʹ68 ̛̛̪̖̬̖̥̖̹̦̖̏̌ ̴̨̬̥̖̦̯̌̐̏ ̨̨̨̨̡̛̣̣̥̐̏ ................... 67 ̨̡̪̬̖̬̏̌ ̨̛̱̭̣̏́ ̛̼̬̼̹̏̐̌ .................................... 69ʹ70 ̨̛̭̦̖̔̌̚ ̴̨̬̥̖̦̯̌̐̏ ̨̨̨̨̡̛̣̣̥̐̏ ......................... 65ʹ67 ʶ̨̔ ̣̖̥̖̦̯̾̌ ̛̱̪̬̣̖̦͕̌̏́ ̛̛̦̪̭̦̖̌̌ ....................... 170ʹ72 ʶ̨̨̣̖̭ ̛̥̼̹͕ ̨̛̭̦̖̔̌̚ ̴̶̡̨̨̛̛̱̦̦̣̦̭̯̌̽ ̨̛̛̥̭̹̯̬̦̌̌̍̏̌́ .................................................... 237ʹ38 ʶ̸̨̨̨̨̥̪̦̦̏̌́ ̡̭̖̯̌ .......................................................... 44 ʶ̸̨̨̨̨̥̪̦̦̼̖̏ ̛̦̭̯̬̱̥̖̦̯̼ ...................................... 43ʹ48 ScrollViewer ................................................................. 46ʹ48 ̸̡̨̨̨̨̥̪̦̦̼̜̏ ̣̖̥̖̦̯̾ Canvas .............................. 45ʹ46 ̸̡̨̨̨̨̥̪̦̦̼̜̏ ̣̖̥̖̦̯̾ StackPanel .............................. 46 ̡̭̖̯̌ ............................................................................ 43ʹ45 ʶ̸̨̨̨̨̥̪̦̦̼̖̏ ̨̭̜̭̯͕̏̏̌ yD> .................................. 71ʹ72 ʶ̸̨̨̨̨̥̪̦̦̼̜̏ ̣̖̥̖̦̯̾ Canvas .................................. 45ʹ46 ʶ̸̨̨̨̨̥̪̦̦̼̜̏ ̣̖̥̖̦̯̾ Grid....................................... 43ʹ45 ʶ̸̨̨̨̨̥̪̦̦̼̜̏ ̣̖̥̖̦̯̾ StackPanel .................................. 46 ʶ̬̖̦̽ Canvas ......................................................................... 20 ʸ̸̨̡̛̛̖̭̖̐ ̡̨̨̛̬̦̯̼͕̔̌ ̨̨̛̛̭̪̣̦̖̽̏̌̚ ̏ Deep Zoom. 235ʹ 37 ʺ̡̬̖̬̌ ̨̬̖̥̖̦̦̜̏ ̡̹̣̼̌ .......................................... 217ʹ19 ʺ̡̬̖̬̼̌ ̨̬̖̥̖̦̦̜̏ ̡̹̣̼̌ ̛̛̥̱̣̯̥̖̽̔̌ ............... 217ʹ19 ʺ̨̛̛̭̹̯̬̦̖̌̌̍̏̌ .......................................... ̭̥͘ ĞĞƉ ŽŽŵ ʺ̶̛̯̬̌̌ ̴̶̨̛̛̯̬̦̭̬̥̌̌ .................................................. 100 ʺ̖̯̦̦̼̖̌̔̌ ......................................................................... 29 ʺ̨̖̯̔ AddEventListener ............................................... 134ʹ35 ʺ̨̖̯̔ CaptureMouse ......................................................... 138 ̨̥̖̯̔ createFromXaml ................................................. 131ʹ32 ʺ̨̖̯̔ createFromXamlDownloader ................................... 132 ʺ̨̖̯̔ createObject ............................................................ 132 ʺ̨̖̯̔ findName ................................................................. 132 ʺ̨̖̯̔ GetHost .................................................................... 135 ʺ̨̖̯̔ getParent ................................................................. 135 ʺ̨̖̯̔ GetValue .................................................................. 135 ʺ̨̖̯̔ ReleaseMouseCapture ............................................. 138 ʺ̨̖̯̔ RemoveEventListener ........................................ 134ʹ35 ʺ̨̖̯̔ SetFontSource .......................................................... 136 ʺ̨̖̯̔ SetValue ................................................................... 136 ʺ̨̖̯̼̔ ̣̖̥̖̦̯̾̌ ̛̱̪̬̣̖̦̌̏́ ̨̥̖̯̔ createFromXaml ............................................. 131ʹ32 ̨̥̖̯̔ createFromXamlDownloader ............................... 132 ̨̥̖̯̔ createObject ......................................................... 132 ̨̥̖̯̔ findName .............................................................. 132 ʺ̴̨̨̨̦̪̣̯̬̥̖̦̦̼̖̐̌ ̨̛̛̪̬̣̙̖̦́ .................................. 33 ʺ̨̖̣̔̽ ̛̪̬̖̭̯̣̖̦͕̔̌̏́ CSS/DHTML .................................. 17 ʺ̨̖̣̔̽ ̨̨̛̛̪̬̬̥̥̬̦̐̌̏̌́ JavaScript/AJAX/.NET Framework......................................................................... 18
ʺ̨̖̣̔̽ ̨̡̛̬̬̯͕̌̌̍̚ ̵̨̨̛̛̯̖̦̣̐ ̨̡̛̬̬̯̌̌̍̚ ̨̛̛̖̪̬̣̙̖̦̜̏̍ ...................................................................... 17 ʺ̛̛̱̣̯̥̖͕̽̔̌ ̨̛̛̥̖̜̭̯̖̏̌̔̏̚ .................................. 256ʹ57 ʺ̼̹͕̽ ̨̨̛̛̭̪̣̦̖̽̏̌̚ ̏ Deep Zoom ........................... 235ʹ37 ʻ̭̼̺̖̦̦̼̖̌ ̡̛̛̦̯̖̬̯̦̼̖̌̏ ̨̛̛̪̬̣̙̖̦́ ................ ̭̥͘ RIA ̣̖̥̖̦̯̼̾ ̛̱̪̬̣̖̦̌̏́ ̣̔́ ̵̛̦ ...................................... 157 ʻ̨̖̪̭̬̖̭̯̖̦̦̼̖̔̏ ̨̭̜̭̯̏̏̌ ............................................. 130 ʽ̸̨̡̛̬̯̍̌̍ ̨̨̡̛̹͕̍ ̨̭̭̯̖̦̼̜̍̏ ............................... 128ʹ29 ʽ̡̬̖͕̍̌̚ ̛̭̬̦̖̦̖̌̏ ̭ ̛̼̬̖̦̖̥̏̌̚ ..................................... 64 ʽ̡̻̖̯̍ ArcSegment ............................................................... 88 ǶȉȢȍȒȚ %H]LHU6HJPHQW ................................................. 89 ʽ̡̻̖̯̍ Downloader....................................................... 132ʹ34 ʽ̡̻̖̯̍ GeometryGroup .................................................. 92ʹ93 ʽ̡̻̖̯̍ Line .......................................................... 21, 48, 86, 87 ʽ̡̻̖̯̍ LineSegment.............................................................. 88 ʽ̡̻̖̯̍ Path ............................................................... 21, 86, 87 ʽ̡̻̖̯̍ PolyBezierSegment ............................................. 89ʹ90 ʽ̡̻̖̯̍ PolyLineSegment ....................................................... 89 ʽ̡̻̖̯̍ PolyQuadraticBezierSegment.............................. 91ʹ92 ʽ̡̻̖̯̍ QuadraticBezierSegment .................................... 90ʹ91 ʽ̛̻̣̖̦̍́̏́ ̨̪̬̭̯̬̦̭̯̌̏ ̛̥̖̦ XML ................................... 20 ʽ̛̛̪̭̦̖̌ ̨̡̪̬̖̯̌ ................................................................ 41 ʽ̨̪̬̦̼̖ ̡̬̼̌̔ .................................................................... 22 ʽ̶̛̪́ ƐƐĞŵďůLJ EĂŵĞ .......................................................... 58 ʽ̶̛̪́ Default Namespace .................................................... 58 ʽ̶̛̪́ Startup Object ............................................................ 58 ʽ̡̛̹̍̌ ̸̡̡̨̨̛̛̭̦̯̭̖̭̌̐ ̨̬̬͕̌̍̌̚ ̨̨̡̬̯̍̌̍̌ ................. 128 ʿ̡̖̯̌ ̭̬̖̭̯̔̏ ̨̡̛̬̬̯̌̌̍̚ Silverlight ................................... 25 ʿ̦̖̣̌̽ Properties͕ ̏ Expression Blend............................ 41ʹ42 ʿ̡̪̌̌ Properties .............................................................. 41, 59 ʿ̡̪̌̌ References ............................................................ 41, 59 ʿ̬̥̖̯̬̌̌ userContext .................................................. 125ʹ26 ʿ̬̥̖̯̬̌̌ ̨̭̜̭̯̏̏̌ framerate .............................................. 27 ʿ̬̥̖̯̬̌̌ ̨̭̜̭̯̏̏̌ ŝŶƉůĂĐĞ/ŶƐƚĂůůWƌŽŵƉƚ ............................. 27 ʿ̬̥̖̯̬̌̌ ̨̭̜̭̯̏̏̌ isWindowless ........................................ 27 ʿ̬̥̖̯̬̌̌ ̨̭̜̭̯̏̏̌ version .................................................. 27 ʿ̬̥̖̯̬̼̌̌ ̶̛̛̛̦̥̌̌ ̛̦̖̌̔̌̚ ̨̥̥̖̦̯̌ ̸̦̣̌̌̌ ............................................... 110 ̛̦̖̌̔̌̚ ̨̡̻̖̯̍̌ ̶̛̛̛̦̥̌̌ ........................................... 110 ̛̦̖̌̔̌̚ ̨̨̨̛̛̪̬̣̙̯̖̣̦̭̯̔̽ ........................................ 110 ̨̨̭̜̭̯̏̏ AutoReverse ..................................................... 110 ̨̨̭̜̭̯̏̏ DoubleAnimation ............................................. 111 ̨̨̭̜̭̯̏̏ PointAnimation ............................................ 112 ̨̨̭̜̭̯̏̏ RepeatBehavior .......................................... 110ʹ11 ̨̨̭̜̭̯̏̏ SpeedRatio ....................................................... 110 ʿ̛̖̬̖̥̖̺̖̦̖ ̨̨̥̖̯̥̔ ͨdrag-and-dropͩ ̨̨̛̛̭̪̣̦̖̽̏̌̚ ̨̛̭̼̯̜̍ ̛̥̼̹ ............................... 153ʹ55 ̶̛̛̬̖̣̌̌́̚ ............................................................... 138ʹ40 ʿ̨̛̖̬̖̬̭̼̖̥̼̖̏̏̌ ̨̛̣̭̯̍̌ ............................................. 250 ʿ̨̨̛̣̙̖̦̖ ̡̨̱̬̭̬̌ ̨̨̛̛̭̪̬̖̖̦͕̏̏̔́̚ ̛̱̪̬̣̖̦̖̌̏ . 216ʹ17 ʿ̨̛̛̬̣̙̖̦̖ ̦̌ IronPython .......................................... 258ʹ62 ʿ̨̛̛̬̣̙̖̦́ ̨̡̨̯̣̽ ̣̔́ Windows....................................... 33 ʿ̛̬̥̖̬ ̶̛̛̛̬̖̣̌̌̚ ̸̨̭̌̏ ........................................... 264ʹ68 ʿ̨̬̬̥̥̦̼̜̐̌ ̴̛̦̯̖̬̖̜̭ .............................................. 18ʹ19
ʿ̨̡̬̖̯ JavaScript, Silverlight 1 Site ....................................... 25 ʿ̨̡̬̖̯ ^ŝlverlight 1 Site ......................................................... 25 ʿ̨̡̬̖̯ ̣̖̥̖̦̯̾̌ ̛̱̪̬̣̖̦̌̏́ Visual Studio ................................................................ 57ʹ62 ̡̪̪̌̌ References............................................................... 59 ̨̭̜̭̯̏̏̌ ̨̡̪̬̖̯̌ ........................................................ 58ʹ59 ̴̜̣̼̌ App.xaml ̛ App.xaml.cs ................................... 60ʹ61 ̴̜̣̼̌ ̨̭̜̭̯̏̏ .................................................................. 59 ̴̜̼̌ Page.xaml ̛ Page.xaml.cs .................................. 61ʹ62 ʿ̨̡̬̖̯͕ ̨̛̭̦̖̔̌̚ ̨̨̨̦͕̏̐ ̏ Visual Studio .................... 168ʹ72 ʿ̴̨̛̬̣̽ ̡̨̨̛̛̬̦̔̏̌́ ̨̛̖̏̔ .............................................. 29 ˀ̬̼̼̌̏̚ ̨̡̭̯̬ ...................................................................... 99 ˀ̡̨̡̭̬̌̌̔̏̌ ̬̖̥̖̦̦̼̖̏ ̡̹̣̼̌ ........................................................... 22 ˀ̛̖̙̥ Stretch ............................................................... 252ʹ53 ˀ̛̖̙̥ Windowless ....................................................... 253ʹ54 ˁ̨̜̭̯̏̏̌ ̛̦̌̔̌́̚ ̨̨̨̛̥̖̭̯̪̣̙̖̦́ ............................. 81ʹ82 ˁ̨̜̭̯̏̏̌ ̛̦̌̔̌́̚ ̨̬̥̖̬̌̏̚ .......................................... 81ʹ82 ˁ̨̜̭̯̏̏̌ ̨̡̦̭̯̬̖̌ .............................................................. 130 ˁ̨̜̭̯̏̏̌ ̨̡̪̬̖̯̌.................................................................. 58 ˁ̨̜̭̯̏̏̌ ̨̨̨̛̭̖̬̙̥̔̐ ....................................................... 130 ˁ̨̜̭̯̏̏̌ ̣̖̥̖̦̯̾̌ ̛̱̪̬̣̖̦̌̏́ ̨̦̖̪̭̬̖̭̯̖̦̦̼̖̔̏ ̨̭̜̭̯̏̏̌ ......................................... 130 ̨̭̜̭̯̏̏̌ ̨̡̦̭̯̬̖̌ .......................................................... 130 ̨̭̜̭̯̏̏̌ ̨̨̨̛̭̖̬̙̥̔̐ ................................................... 130 ˁ̨̨̜̭̯̏̏ AutoReverse ........................................................ 110 ˁ̨̨̜̭̯̏̏ Canvas.Left ............................................................ 71 ˁ̨̨̜̭̯̏̏ Canvas.Top............................................................. 71 ˁ̨̨̜̭̯̏̏ CanvasZIndex ................................................... 71ʹ72 ˁ̨̨̜̭̯̏̏ ColorAnimation.................................. 22, 50, 111ʹ12 ˁ̨̨̜̭̯̏̏ Cursor .................................................................... 82 ˁ̨̨̜̭̯̏̏ DoubleAnimation ..................................... 22, 50, 111 ˁ̨̨̜̭̯̏̏ Geometry.Transform ........................................... 100 ˁ̨̨̜̭̯̏̏ MatrixTransform ............................................ 22, 106 ˁ̨̨̜̭̯̏̏ Opacity................................................................... 82 ˁ̨̨̜̭̯̏̏ Orientation͕ ̸̡̨̨̨̨̥̪̦̦̼̜̏ ̣̖̥̖̦̯̾ StackPanel ........................................................................................... 46 ˁ̨̨̜̭̯̏̏ PluginBackground .......................................... 250ʹ51 ˁ̨̨̜̭̯̏̏ PointAnimation .............................................. 22, 112 ˁ̨̨̜̭̯̏̏ RepeatBehavior ............................................. 110ʹ11 ˁ̨̨̜̭̯̏̏ RotateTransform.................................... 22, 100ʹ101 ˁ̨̨̜̭̯̏̏ ScaleTransform .......................................... 22, 102ʹ3 ˁ̨̨̜̭̯̏̏ SkewTransform .............................................. 22, 104 ˁ̨̨̜̭̯̏̏ SkewTransfrom ̶̛̛̛̥̯̌́ ̵̨̨̯̬̖̥̖̬̦̐ ̨̛̛̬̙̖̦̍̌́̚ .......................... 105 ˁ̨̨̜̭̯̏̏ SpeedRatio ........................................................... 110 ˁ̨̨̜̭̯̏̏ ^ƉƌĞĂĚDĞƚŚŽĚ ........................................................ 77 ˁ̨̨̜̭̯̏̏ Stroke............................................................... 82ʹ85 ˁ̨̨̜̭̯̏̏ TextDecorations..................................................... 98 ˁ̨̨̜̭̯̏̏ TextWrapping ........................................................ 98 ˁ̨̨̜̭̯̏̏ TranslateTransform ................................... 22, 103ʹ4 ǹȍȋȔȍȕȚȣ ȒȖȕȚțȘȈ șȖșȚȈȊȕȣȍ.................................. 92 ˁ̨̖̦̭̬̦̼̜ ̨̏̏̔ ................................................................. 221 ˁ̨̖̬̖̬̦̖̏ ̨̛̛̪̬̣̙̖̦̖ ̛̬̖̥̖̦͕̏ ̨̛̭̦̖̔̌̚ ............. 191ʹ92
ˁ̖̬̖̬̦̼̖̏ ̶̛̭̯̬̦̼̌ Java.................................................. 186 ˁ̖̬̖̬̦̼̖̏ ̣̖̥̖̦̯̼̾ ̛̱̪̬̣̖̦̌̏́ ̭̥. ˁ̖̬̖̬̦̼̖̏ ̣̖̥̖̦̯̼̾ ̛̱̪̬̣̖̦̌̏́ Silverlight ˁ̖̬̖̬̦̼̜̏ ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ Silverlight ................ 247ʹ55 ȌȖșȚțȗ Ȓ +70/ ..................................................... 249ʹ50 ̡̛̥̭̥̣̦̌̌̽̌́ ̸̨̭̯̯̌̌ ̡̨̬̌̔̏ ...................................... 249 ̨̛̪̖̬̖̬̭̼̖̥̼̖̏̏̌ ̨̛̣̭̯̍̌ ......................................... 250 ̛̬̖̙̥ Stretch ........................................................... 252ʹ53 ̛̬̖̙̥ Windowless ................................................... 253ʹ54 ̨̨̭̜̭̯̏̏ PluginBackground ...................................... 250ʹ51 ̨̛̭̼̯̍́ ..................................................................... 254ʹ55 ̸̸̡̛̭̖̯ ̸̨̭̯̯̼̌ ̡̨̬̌̔̏ ........................................... 247ʹ49 ̛̱̪̬̣̖̦̖̌̏ ̨̡̨̱̭̯̦̜̌̏ ̸̨̡̨̨̪̣̖̥̔̀̌̐ ̨̥̱̣̔́ .. 251ʹ52 ˁ̖̬̣̖̯̏ ................................................................................ 187 ˁ̖̬̣̖̯̏ Java ........................................................................ 187 ˁ̖̬̣̖̯̏ ̣̔́ ̸̨̛̪̣̱̖̦́ ̵̨̨̨̛̭̦̔̐ XAML ................... 187ʹ89 ˁ̨̛̼̯̖̍ MouseMove͕ ̛ Deep Zoom .................................. 236 ˁ̨̛̼̯̖̍ onLoad .................................................................... 28 ˁ̨̛̼̯̖̍ OnPluginError ....................................................... 254 ˁ̨̛̼̯̖̍ OnPluginFullScreenChanged ................................. 254 ˁ̨̛̼̯̖̍ OnPluginLoaded ................................................... 255 ˁ̨̛̼̯̖̍ OnPluginResized ................................................... 255 ˁ̨̛̼̯̍́ OnExit ..................................................................... 35 ˁ̨̛̼̯̍́ OnStartup ............................................................... 35 ˁ̨̛̼̯̍́ ̡̛̬̱̌̐̚̚ ̶̛̭̯̬̦̼͕̌ ̨̯̖̯̏ ̦̌ ̵̛̦ .................. 124ʹ26 ̨̨̡̬̯̍̌̍̌ ̨̪̬̥̖̯̬̌̌̏ ............................................ 124ʹ25 ̵̨̨̡̛̪̣̯̖̣̭̜̽̏̌̽̚ ̡̨̡̦̯̖̭̯ ................................... 125ʹ26 ˁ̨̛̼̯̍́ ̛̥̼̹ ̬̱̥̖̦̯̼͕̌̐ ̨̛̭̪̣̱̖̥̼̖̽̚ ̭ ̡̨̛̬̱̪̭̦̼̥ ̨̨̥̏̏̔ 224ʹ25 ̸̨̨̡̛̛̬̯̍̌̍ ............................................................. 134ʹ40 ̣̖̥̖̦̯̼̾ ̛̱̪̬̣̖̦̌̏́ ̣̔́ ̨̨̡̛̬̯̍̌̍ .................... 153ʹ55 ˁ̨̛̼̯̍́ ̨̡̛̛̹̍ ̶̛̭̯̬̦̼͕̌ ̨̯̖̯̏ ̦̌ ̵̛̦ ................... 127ʹ34 ̨̭̭̯̖̦̦̼̜̍̏ ̸̨̨̡̛̬̯̍̌̍ ̨̛̭̼̯̜̍ ......................... 128ʹ29 ̭̯̦̬̯̦̼̜̌̔̌ ̸̨̨̡̛̬̯̍̌̍ ̨̛̭̼̯̜̍................................ 128 ˁ̨̛̛̖̦̖̦̖̔ ̛̛̣̦̜͕ ̨̛̪̬̖̖̣̖̦̖̔ ....................................... 85 ˁ̨̛̦̖̔̌̚ ̡̖̥̪̣̬̾́̌̚ .......................................................... 27 ǹȖșȚȈȊȕȣȍ șȍȋȔȍȕȚȣ ȒȖȕȚțȘȈ ................................... 92 ˁ̯̦̬̯̦̼̜̌̔̌ ̸̨̨̡̛̬̯̍̌̍ ̨̛̭̼̯̜̍ ................................... 128 ˁ̨̛̯̣̖̖̏ ̴̨̨̛̬̥̣̖̦̖ ................................................. 241ʹ44 ̛̛̥̖̦̖̦̖̚ ̨̛̣̭̯̍̌ ̛̖̜̭̯̔̏́ ̛̭̯̣́ ........................ 243ʹ44 ̨̛̭̦̖̔̌̚ ̛̭̯̣́ ......................................................... 242ʹ43 ˁ̶̛̯̬̦̌̌ ̨̪ ̸̨̛̱̥̣̦̌̀ ...................34, ̭̥͘ ̡̯̙̖̌ Page.xaml ǡǴDz REMHFW! ................................................................ 37, 123 ˃̡̨̖̭̯̼̖̏ ̣̖̥̖̦̯̼̾ ̛̱̪̬̣̖̦̌̏́ ....................................... 49 ˃̨̖̭̯̏̌́ ̶̛̭̯̬̦̌̌ ̴̜̣̌̌ ASPX ............................................ 63 ˃̛̪ Stroke ............................................................................ 223 ̛̯̪ StrokeCollection ............................................................ 222 ˃̛̪ StylusPoint .................................................................... 224 ˃̛̪ StylusPointCollection .............................................. 223ʹ24 ˃̶̛̬̦̭̣̌́́...................................................................... 103ʹ4 ˃̴̶̨̛̛̬̦̭̬̥̌̌ .................................................... 22, 100ʹ108 ̛̬̺̖̦̖̏̌ ................................................................ 100ʹ101 ̶̛̛̛̥̯̌́ ̵̨̨̯̬̖̥̖̬̦̐ ̨̛̛̬̙̖̦̍̌́̚ .......................... 105 ̨̛̛̥̭̹̯̬̦̖̌̌̍̌ ........................................................ 102ʹ3
̡̨̛̦̣̦̖̦̖̌ ̨̡̻̖̯̍̌ ...................................................... 104 ̨̛̪̬̖̖̣̖̦̖̔ ̵̨̭̭̯̖̦̦̼̍̏ ̴̶̨̛̯̬̦̭̬̥̜̌̌ ................ 106 ̛̪̖̬̖̥̖̺̖̦̖ ̨̡̻̖̯̍̌ ............................................... 103ʹ4 ̸̨̛̭̖̯̦̖̌ ........................................................................ 107 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ MediaElement ........................ 209ʹ10 ˃̵̨̬̖̥̖̬̦̖ ̨̛̛̬̙̖̦̖͕̍̌̚ ̶̛̛̛̥̯̌́ .............................. 105 ˄̨̡̭̯̦̌̏̌ ̸̨̡̨̨̪̣̖̥̔̀̌̐ ̨̥̱̣͕̔́ ̛̱̪̬̣̖̦̖̌̏ ....... 251ʹ52 ˇ̜̣̌ DLL................................................................................ 33 ˇ̜̣̼̌ App.xaml .............................................................. 60ʹ61 ˇ̜̣̼̌ App.xaml.cs ................................................... 35, 60ʹ61 ˇ̜̣̼̌ ASPX........................................................................... 63 ˇ̜̣̼̌ Page.xaml ............................................................ 61ʹ62 ˇ̜̣̼̌ Page.xaml.cs ........................................................ 61ʹ62 ˇ̜̣̼̌ ̭ ̼̖̣̖̦̦̼̥̏̔ ̡̨̨̥̔ .............................................. 35 ˇ̛̱̬̐̌ Ellipse ............................................................ 21, 48, 86 ˇ̛̱̬̐̌ WŽůLJŐŽŶ ............................................................... 21, 86 ˇ̛̱̬̐̌ Polyline ............................................................... 21, 86 ˇ̛̱̬̐̌ Rectangle ...................................................... 21, 48, 86 ˇ̛̱̬̼͕̐ ̏ yD> ............................................................... 86ʹ94 ̸̨̡̛̛̖̥̖̯̬̖̭̖̐ ̣̖̥̖̦̯̼̾ ........................................ 87ʹ94 ̡̨̦̯̱̬̼ ....................................................................... 87ʹ88 ̨̡̻̖̯̍ ůůŝƉƐĞ ..................................................................... 86 ̨̡̻̖̯̍ GeometryGroup .............................................. 92ʹ93 ̨̡̻̖̯̍ Line ........................................................................ 87 ̡̼́̚ ̨̛̛̪̭̦̌́ ̡̨̨̦̯̱̬̏ ............................................ 93ʹ94 ˇ̛̱̬̼͕̐ ̨̨̭̦̦̼̖̏ .............21, 48, ̭̥͘ ̡̯̙̖̌ ˇ̛̱̬̼͕̐ ̏ XAML ˇ̛̣̯̬̽ DirectShow ................................................................ 29 ˇ̨̬̥̌ ̨̏̏̔̌ ̵̦̦̼̔̌ ......................................................... 197 ˇ̨̬̥̯̼̌ ̴̸̵̡̛̛̬̖̭̐̌ ̴̨̜̣͕̌̏ ̛ Expression Design .......... 23 ˇ̶̡̛̱̦́ createObjectEx ......................................... 27, 120ʹ22 ˇ̶̡̛̱̦́ createSilverlight...................................................... 27 ˇ̶̡̛̱̦́ handleLoad ............................................................. 28 ˇ̶̡̛̱̦́ handleMouseDown ................................................ 28 ˇ̶̡̛̱̦́ IntelliSense ..................................................... 171ʹ72 ˋ̨̭̯̯̌̌ ̡̨̬̌̔̏ ̡̛̥̭̥̣̦̌̌̽̌́ ................................................................ 249 ̸̸̡̛̭̖̯ ...................................................................... 247ʹ49 ˌ̨̣̦̌̍ Silverlight, Default.html........................................... 26 ˌ̨̣̦̌̍ ̵̦̦̼̔̌ .................................................................. 160 ˌ̨̣̦̌̍ ̣̖̥̖̦̯̾̌ ̛̱̪̬̣̖̦͕̌̏́ ̨̛̣̖̦̖̔̍̌̏ .............. 169ʹ70 ˌ̨̣̦̼̌̍ ...................... 244ʹ46, ̭̥͘ ̡̯̙̖̌ ˌ̨̣̦̌̍ Silverlight XAML.......................................................................... 179ʹ81 ̵̦̦̼̔̌ ............................................................................ 160 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ ................................................ 169ʹ70 ˌ̴̛̬̯̼͕ ͨʦ̖̍-̨̖̪̭̦̼̖̍̌ͩ̚ ............................................... 97 ˑ̣̖̥̖̦̯ Canvas .............................................................. 20ʹ21 ˑ̣̖̥̖̦̯ Canvas .................................................................... 24 ˑ̣̖̥̖̦̯ Glyphs ............................................................... 96ʹ97 ˑ̣̖̥̖̦̯ Image ...................................................................... 67 ˑ̣̖̥̖̦̯ Run ................................................................... 98ʹ99 ˑ̣̖̥̖̦̯ UI͕ ̛̦̖̌̔̌̚ ̴̶̨̛̛̯̬̦̭̬̥̌̌ ............................... 100 ˑ̣̖̥̖̦̯ UI͕ ̨̨̛̛̪̬̬̥̥̬̦̖̐̌̏̌ ̨̥̖̯̼̔ ̣̖̥̖̦̯̾̌ UI................................................. 134ʹ36 ̛̪̖̬̖̥̖̺̖̦̖ ̨̨̥̖̯̥̔ ͨdrag-and-dropͩ ............... 138ʹ40
̨̛̭̼̯̍́ ̣̖̥̖̦̯̾̌ UI ................................................ 137ʹ38 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ ASP.NET MediaPlayer ̨̛̛̥̖̜̭̯̖̏̌̔̏̚ ̭ ̛̛̥̱̣̯̥̖̽̔̌ ............................. 256ʹ57 ̛̦̌̔̌́̚ MediaPlayer ................................................ 255ʹ56 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ ŽƌĚĞƌ ................................................ 48 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ ƵƚƚŽŶ .......................... 141ʹ42, 241ʹ42 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ Calendar ..................................... 162ʹ64 ȅȓȍȔȍȕȚ țȗȘȈȊȓȍȕȐȧ &DQYDV ............................... 95ʹ96 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ CheckBox .............................. 49, 142ʹ43 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ DataGrid ..................................... 157ʹ62 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ DatePicker .................................. 162ʹ64 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ GridSplitter ......................................... 49 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ HyperlinkButton ......................... 143ʹ44 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ Image ................................... 96, 144ʹ45 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ InkPresenter ............................... 220ʹ29 ̡̣̭̭̼̌ ̡̨̨̨̛̬̱̪̭̦̐ ̨̏̏̔̌ ̣̔́ ̨̨̛̪̬̬̥̥̭̯̐̌̏ ̦̌ JavaScript ............................................................... 222ʹ24 ̛̪̬̥̖̬ ̏ Silverlight ................................................... 220ʹ29 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ ListBox ................................................ 49 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ ListBox ........................................ 145ʹ46 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ MediaElement ............................ 205ʹ19 ̸̨̡̨̛̯̥̯̖̭̖̌̏̌ ̨̨̛̛̭̪̬̖̖̦̖̏̏̔̚ ............................... 211 ̨̼̖̍̌̏̚ ̣̖̥̖̦̯̼̾ ̛̱̪̬̣̖̦̌̏́ ̨̨̛̛̭̪̬̖̖̦̖̥̏̏̔̚ . 212ʹ 14 ̛̼̬̖̦̖̏̌̚ ̛̛̥̱̣̯̥̖̽̔̌ ̸̨̡̛̛̛̖̥̖̯̬̖̭̥̐ ̴̨̛̬̥̥̌ 210 ̛̪̭̌̽̚ ̨̨̨̛̭̖̬̙̥̔̐ ̵̨̪̖̬̏ ̨̨̛̛̛̖̬̙̖̦̏̔̍̌́̚ ....... 210 ̡̱̏̚ .................................................................................. 211 ̡̥̬̖̬̼̌ ̨̬̖̥̖̦̦̜̏ ̡̹̣̼̌ ̛̛̥̱̣̯̥̖̽̔̌ ............ 217ʹ19 ̨̛̪̬̖̖̣̖̦̖̔ ̬̥̖̬̌̌̚.................................................... 207 ̨̨̛̪̣̙̖̦̖ ̡̨̱̬̭̬̌ ̨̨̛̛̭̪̬̖̖̦̏̏̔́̚ ................... 216ʹ17 ̨̨̛̛̪̬̬̥̥̬̦̖̐̌̏̌ .................................................. 212ʹ19 ̸̨̨̪̬̬̦̭̯̌̽̚ ̨̛̖̏̔ ....................................................... 209 ̨̨̪̬̭̯̖ ̨̨̛̛̭̪̬̖̖̦̖̏̏̔̚ ̨̛̖̏̔ .............................. 206ʹ7 ̛̛̬̭̯̦̖̌́̐̏̌ ̨̛̛̬̙̖̦̍̌́̚ ̛̛̥̱̣̯̥̖̽̔̌ ............... 207ʹ9 ̡̯̖̱̺̖̖ ̨̨̛̭̭̯̦̖́ ̨̛̖̏̔ .............................................. 215 ̴̶̨̛̛̯̬̦̭̬̥̌̌ ........................................................ 209ʹ10 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ MultiScaleImage ....... 229ʹ40, ̭̥͘ ̡̯̙̖̌ Deep zoom ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ RadioButton ....................................... 49 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ RadioButton ............................... 147ʹ48 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ RepeatButton ............................. 164ʹ65 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ ^ĐƌŝƉƚDĂŶĂŐĞƌ .................................... 63 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ ScrollBar ............................................. 49 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ ScrollViewer ................... 46ʹ48, 165ʹ66 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ Slider .......................................... 49, 167 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ TextBlock .................................... 148ʹ49 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ TextBox .............................................. 49 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ TextBox ...................................... 150ʹ52 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ ToggleButton .............................. 164ʹ65 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́ ̬̱̖̬̍̌̌̚ ̨̯̖̯̏ ̦̌ ̨̛̭̼̯̍́ ̡̛̬̱̌̐̚̚ ̶̛̭̯̬̦̼̌ ...................... 124ʹ26 ̨̯̖̯̏ ̦̌ ̨̛̭̼̯̍́ ̨̡̛̛̹̍ ̶̛̭̯̬̦̼̌ ....................... 127ʹ34 ̛̬̥̖̺̖̦̖̌̚ Silverlight ̏ ̬̱̖̬̖̍̌̚ .......................... 120ʹ23 ̯̖̐ фobject> ..................................................................... 123
̣̖̥̖̦̯̼̾ UI .............................................................. 134ʹ40 ˑ̣̖̥̖̦̯ ̛̱̪̬̣̖̦̌̏́MediaElement ̴̶̛̛̱̖̬̍̌́̚ ̛ ̡̬̱̌̐̌̚̚ ........................................... 214ʹ15 ˑ̣̖̥̖̦̯̼ ̛̱̪̬̣̖̦̌̏́ ...... ̭̥͘ ̡̯̙̖̌ ˑ̣̖̥̖̦̯̼ ̛̱̪̬̣̖̦̌̏́ Silverlight ̣̔́ ̨̨̛̛̭̪̣̦̽̏̌́̚ ̡̛̣̯̱̬̼̌̏̌ .................................... 155 ̛̬̥̖̺̖̦̖̌̚ ̛ ̨̡̦̭̯̬̜̌̌ .......................................... 49ʹ50 ˑ̣̖̥̖̦̯̼ ̛̱̪̬̣̖̦̌̏́ ^W͘Ed MediaPlayer ............................................................... 255ʹ57 ScriptManager ................................................................... 63 Silverlight ........................................................................... 63 ̭̖̬̖̬̦̼̜̏ ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ Silverlight ............ 247ʹ55 ˑ̣̖̥̖̦̯̼ ̛̱̪̬̣̖̦̌̏́ ^ŝůǀĞƌůŝŐŚƚ ̨̛̭̦̖̔̌̚ ̡̨̖̥̪̣̬̾́̏̚ ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ MediaElement .................... 205ʹ19 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ VideoBrush ............................... 220 ̣̖̥̖̦̯̼̾ ̛̱̪̬̣̖̦̌̏́ ^W͘Ed ̭̥͘ ˑ̣̖̥̖̦̯̼ ̛̱̪̬̣̖̦̌̏́ ASP.NET ̣̔́ ̨̨̡̛̬̯̍̌̍ ̨̛̭̼̯̜̍ ̛̥̼̹ ............................ 153ʹ55 ̣̔́ ̨̨̡̛̬̯̍̌̍ ̴̨̡̱̭̌ ............................................... 152 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ ƵƚŽŶ.................................. 141ʹ42 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ Calendar ............................. 162ʹ64 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ CheckBox ............................ 142ʹ43 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ DataGrid ............................. 157ʹ62 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ DatePicker .......................... 162ʹ64 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ HyperlinkButton ................. 143ʹ44 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ Image ................................. 144ʹ45 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ InkPresenter ....................... 220ʹ29 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ ListBox ................................ 145ʹ46 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ MultiScaleImage................. 229ʹ40 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ RadioButton ....................... 147ʹ48 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ RepeatButton ..................... 164ʹ65 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ ScrollViewer ....................... 165ʹ66 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ Slider ........................................ 167 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ TextBlock ............................ 148ʹ49 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ TextBox .............................. 150ʹ52 ̣̖̥̖̦̯̾ ̛̱̪̬̣̖̦̌̏́ ToggleButton...................... 164ʹ65 ˑ̣̖̥̖̦̯̼ ̛̱̪̬̣̖̦̌̏́ TextBlock ............................. 22, 97ʹ99 ̨̛̣̖̦̖̔̍̌̏ ̏ UserControl ................................................ 36 ̛̛̛̪̬̭̦̖̏̌̏̌ ̥̖̦ ..................................................... 181 ̬̬̼̼̌̏̚ ̨̡̭̯̬ .............................................................. 99 ̨̥̖̯̔ SetFontSource ...................................................... 136 TextBlockStyle.............................................................. 243 ̨̛̭̯̣̖̖̏ ̴̨̨̛̬̥̣̖̦̖ ............................................... 242 ̣̖̥̖̦̯̾ Run ................................................................ 98ʹ99 ȅȓȍȔȍȕȚȣ țȗȘȈȊȓȍȕȐȧ ;$0/ ȥȓȍȔȍȕȚ &DQYDV ..................................................... 95ʹ96 ̣̖̥̖̦̯̾ Glyphs ........................................................... 96ʹ97 ̣̖̥̖̦̯̾ Image .................................................................. 96 ̣̖̥̖̦̯̾ TextBlock....................................................... 97ʹ99 ˑ̣̖̥̖̦̯̼ ̛̱̪̬̣̖̦̌̏́ ̨̨̛̛̭̪̬̖̖̦̖̥̏̏̔̚ ................ 212ʹ14 ˑ̣̖̥̖̦̯̼ ̛̱̪̬̣̖̦̌̏́ ̨̨̡̨̨̪̣̯̖̣̭̽̏̌̽̐̚ ̴̛̦̯̖̬̖̜̭̌ .... 49 ̣̔́ ̛̬̼̐ ...................................................................... 67ʹ69 ˔̡̼̚ ̨̛̛̪̭̦̌́ ̡̨̨̦̯̱̬̏ ................................................ 93ʹ94
Введение в Microsoft Silverlight 2
®
™
ВТОРОЕ ИЗДАНИЕ
Ваш первый взгляд на инструменты и технологии создания приложений с использованием Silverlight 2. Начните применять Silverlight 2—кросс-платформенный, кросс-браузерный плагин для представления расширенных мультимедийных интерактивных приложений и пользовательских интерфейсов следующего поколения. Книга основана на знаниях команды разработчиков Microsoft Silverlight, процесс изучения построен с использованием практических упражнений, подробных указаний и примеров кода, чтобы вы сразу могли перейти к собственным разработкам.
Об авторе Laurence Moroney (Лоуренс Морони) является ведущим экспертом по технологиям Microsoft,специализирующимся на Silverlight и User Experience. Имеет более чем десятилетний опыт разработки и реализации программного обеспечения и является автором около десятка книг по разнообразнейшим тематикам, среди которых Windows Presentation Foundation, Веб-разработка, безопасность и способность к взаимодействию.
Изучите как: •
Использовать XAML для отрисовки, масштабирования и анимации
•
Воспользоваться мощью Microsoft .NET и удобством языков поддерживаемых Visual Studio®
•
Применять разнообразные компоненты, создавая и расширяя свои собственные
•
Экспериментировать с возможностями медиа и Deep Zoom
•
Создавать подключаемые приложения
•
Применять динамические языки, такие как Ruby и Python
•
Управлять приложениями Silverlight при помощи ASP.NET
ПОЛЕЗНЫЕ РЕСУРСЫ MICROSOFT ® Для дизайнеров •
Веб-сайт Expression www.microsoft.com/rus/expression
•
Бюллетень Expression для дизайнеров www.microsoft.com/rus/expression /news-press/newsletter
Для веб-разработчиков •
Веб-технологии Microsoft www.microsoft.com/rus/web
Загрузите примеры к книге на C# и XAML www.microsoft.com/rus/expression/resources
•
Центр разработки ASP.NET msdn microsoft.com/ru-ru/asp.net
Для разработчиков •
Инструменты на русском языке www.visualstudio2008.ru
•
Веб-сайт для разработчиков msdn.microsoft.com/ru-ru
Part No. X14-55516
Подробнее см. на msdn.microsoft.com/ru-ru
ISBN-13: 978-0-7356-2528-0 ISBN-10: 0-7356-2528-X
[msdn.microsoft.com/ru-ru]
Программирование/Веб