ç®æ¬¡
- ã¯ããã«
- Prismã¢ããªã±ãŒã·ã§ã³ã®åæå
- ã³ã³ããŒãã³ãéã®äŸåé¢ä¿ã®ç®¡ç
- ã¢ãžã¥ã©ãŒã¢ããªã±ãŒã·ã§ã³éçº
- MVVMãã¿ãŒã³ã®å®è£
- é«åºŠãªMVVMã·ããªãª
- ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã®äœæ
- ããã²ãŒã·ã§ã³
- ççµåã³ã³ããŒãã³ãéã®çžäºäœçš
ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã®ã¬ã€ãã©ã€ã³
ãã®ã»ã¯ã·ã§ã³ã®ç®æšã¯ãWPFãSilverlightããŸãã¯Windows RTãšPrismã©ã€ãã©ãªã䜿çšããŠã¢ããªã±ãŒã·ã§ã³ãäœæããXAMLãã¶ã€ããŒããã³ããã°ã©ããŒåãã®è¡šé¢ãã¥ãŒããªã¢ã«ãæäŸããããšã§ãã ãã®ã»ã¯ã·ã§ã³ã§ã¯ããŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã¬ã€ã¢ãŠããèŠèŠçãªãã¬ãŒã³ããŒã·ã§ã³ãããŒã¿ãã€ã³ãã£ã³ã°ããªãœãŒã¹ãããã³ããŒã¿è¡šç€ºã¢ãã«ã«ã€ããŠèª¬æããŸãã ãã®ã»ã¯ã·ã§ã³ãèªãã åŸãPrismã©ã€ãã©ãªã䜿çšããŠãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ãäœæããæ¹æ³ãšãã¢ãžã¥ãŒã«åã¢ããªã±ãŒã·ã§ã³ã§ãµããŒããããŠããUIãäœæããã®ã«åœ¹ç«ã€ãã¯ããã¯ãé©çšããæ¹æ³ã«ã€ããŠè¡šé¢çãªç解ãåŸãããšãã§ããŸãã
UIéçº
Prismã©ã€ãã©ãªã䜿çšããŠäœæãããè€åã¢ããªã±ãŒã·ã§ã³ã®ã¬ã€ã¢ãŠãã¯ãWPFããã³Silverlightã®æšæºåçã«åºã¥ããŠæ§ç¯ãããŠããŸã-ã¬ã€ã¢ãŠãã¯ãé¢é£ããèŠçŽ ãå«ãããã«ã®æŠå¿µã䜿çšããŸãã ãã ããè€åã¢ããªã±ãŒã·ã§ã³ã§ã¯ãããã«ã®ã³ã³ãã³ãã¯åçã§ãããã¢ããªã±ãŒã·ã§ã³ãèµ·åããããŸã§ããããŸããã ããã«ããããã¶ã€ããŒãšéçºè ã¯ãåçã³ã³ãã³ãã衚瀺ã§ããããŒã¯ã¢ããæ§é ãäœæãããã®ã³ã³ãã³ãã®åèŠçŽ ãåå¥ã«éçºããå¿ èŠããããŸãã ããªãã«ãšã£ãŠãããã¯ãPrismã©ã€ãã©ãªã®2ã€ã®äž»èŠãªæŠå¿µãã³ã³ããæ§æãšãªãŒãžã§ã³ãåŠã¶å¿ èŠãããããšãæå³ããŸãã
ã³ã³ããæ§æ
ã³ã³ããæ§æã¯ãWFPããã³SilverlightãæäŸããããã©ã«ãã®ã³ã³ãã³ãã¢ãã«ã®åãªãæ¡åŒµã§ãã ãã³ã³ããããšããçšèªã¯ããŠã£ã³ããŠãããŒãžããŠãŒã¶ãŒã³ã³ãããŒã«ãããã«ãç¹å¥ãªã³ã³ãããŒã«ãã³ã³ãããŒã«ãã³ãã¬ãŒããåçã³ã³ãã³ããªã©ã®èŠçŽ ãæå³ããŸãã åºå®ã³ã³ãã³ãã¯ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹èŠçŽ ã®å šäœçãªæ§é ãè¡šããåçã³ã³ãã³ãã¯é åå ã«é 眮ãããŸãã
è€åã¢ããªã±ãŒã·ã§ã³çšã®ããŒã«ã«ããèšèšæã®ãµããŒãã¯ããçšåºŠå¶éãããŠããŸãããå®è¡æã«ç°ãªãã³ã³ãã³ããã©ã®é åã«é 眮ãããããç¥ã£ãŠãããšããäºå®ã¯ãéçºã«ãšã£ãŠéèŠã§ãã ããšãã°ã次ã®å³ã®èšèšäžã®ãŠã£ã³ããŠã®ãã¥ãŒãšãã¢ããªã±ãŒã·ã§ã³ãèµ·åããåŸã®ãã¥ãŒã®æ¯èŒã次ã®å³ã«ç€ºããŸãã èšèšäžãããŒãžã¯ã»ãšãã©ç©ºçœã§ãã ã¢ããªã±ãŒã·ã§ã³ã®åºæ¬çãªæ©èœãå®è¡ããå€ãã®ã³ã³ãããŒã«ã衚瀺ãããŠããå Žåãèµ·ååŸã®ãã¥ãŒãšæ¯èŒããŠãã ããã ããã«åºã¥ããŠãè€åã¢ããªã±ãŒã·ã§ã³ã®éçºè ãšèšèšè ãçŽé¢ããã¿ã¹ã¯ã®è€éããæ³åã§ããŸãã
èšèšäžã«èŠçŽ ã衚瀺ããããšã¯ã§ããŸããããã®ãããèŠçŽ ã®ãµã€ãºãšãã¢ããªã±ãŒã·ã§ã³ã®äžè¬çãªå€èŠ³ã«ã©ã®ããã«å¯Ÿå¿ããããå€æããã®ã¯å°é£ã§ãã ã³ã³ãããäœæãããšãã¯ã次ã®ç¹ãèæ ®ããŠãã ããã
- æ倧ã³ã³ãã³ããµã€ãºã«å¶éã¯ãããŸããïŒ ååšããå Žåã¯ãã¹ã¯ããŒã«ããµããŒãããã³ã³ããã®äœ¿çšãæ€èšããŠãã ããã
- éãããã¹ããŒã¹ã«å€§éã®åçã³ã³ãã³ããé
眮ããå¿
èŠãããå Žåã¯ã
Expander
ScrollViewer
ãšScrollViewer
çµã¿åããã䜿çšããããšãæ€èšããŠãã ããã - ã¢ããªã±ãŒã·ã§ã³ãŠã£ã³ããŠããµã€ãºå€æŽããããšãã«ã³ã³ãã³ãã®ãµã€ãºãã©ã®ããã«å€æŽããããã«æ³šæããŠãã¢ããªã±ãŒã·ã§ã³ãã©ã®ãŠã£ã³ããŠãµã€ãºã§ãé åçã«èŠããããã«ããŸãã
Expression Blendã®Stock Trader RIã®ã¡ã€ã³ãŠã£ã³ããŠã
ã¹ã¿ãŒãã¢ããåŸã®Stock Trader RIã®ã¡ã€ã³ãŠã£ã³ããŠã
éçºäžã®è€åã¢ããªã±ãŒã·ã§ã³ã®ãã¥ãŒ
åã®2ã€ã®å³ã¯ãè€åã¢ããªã±ãŒã·ã§ã³ã®éçºã«ããã課é¡ã®1ã€ã瀺ããŠããŸãã è€åã¢ããªã±ãŒã·ã§ã³ã®åãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹èŠçŽ ã¯ãåå¥ã«éçºããå¿ èŠããããŸãã ããã«ãããèµ·ååŸã®ã¢ããªã±ãŒã·ã§ã³ã®å€èŠ³ãèŠèŠåããããšãé£ãããªããŸãã çµã¿ç«ãŠãããç¶æ ã§ã¢ããªã±ãŒã·ã§ã³ãã©ã®ããã«èŠããããæ³åããããã«ããã¹ããããã¬ãŒã³ããŒã·ã§ã³ã®ãã¹ãŠã®ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹èŠçŽ ãå«ãããŒãžãŸãã¯ãŠã£ã³ããŠã§ãã¹ããããžã§ã¯ããäœæã§ããŸãã
- ããã«ãExpression Blendããã³Visual Studio 2010-2012ãæäŸãããã¶ã€ã³æã®ãµã³ãã«ããŒã¿ã䜿çšããŠãUIèŠçŽ ãèšå®ããããšãæ€èšããŠãã ããã ãã®æ©èœã¯ãããŒã¿ãã³ãã¬ãŒãããªã¹ããã°ã©ãããŸãã¯ãã£ãŒããæäœãããšãã«éåžžã«åœ¹ç«ã¡ãŸãã 詳现ã«ã€ããŠã¯ã ãèšèšæã®ãµã³ãã«ããŒã¿ã®ã¬ã€ãã©ã€ã³ããåç §ããŠãã ããã
ããŒã¯ã¢ãã
è€åã¢ããªã±ãŒã·ã§ã³ã®ã¬ã€ã¢ãŠããèšèšãããšãã¯ã次ã®ç¹ãèæ ®ããŠãã ããã
- ã·ã§ã«ã¯ãã¢ããªã±ãŒã·ã§ã³ã®åºæ¬ã¬ã€ã¢ãŠããå®çŸ©ããŸãã åã¬ã€ã¢ãŠãé åã¯é åã§ããã空ã®ã³ã³ããã§ããå¿ èŠããããŸãã èšèšäžã«ã³ã³ãã³ãããªãŒãžã§ã³å ã«é 眮ããªãã§ãã ãããèµ·åæã«ã³ã³ãã³ããããŒããããŸãã
- ã·ã§ã«ã«ã¯èæ¯ãšããããŒãå«ãŸããŠããå¿ èŠããããŸãã ASP.NETã®ãã¹ã¿ãŒããŒãžãšèããŠãã ããã
- é åã®ã³ã³ãããšããŠæ©èœããã³ã³ãããŒã«ã¯ãå«ãŸãããã¥ãŒãšã¯å¥ã§ãã ãããã£ãŠãã³ã³ãããŒã«ãå€æŽããã«ãã¥ãŒã®ãµã€ãºãå€æŽãããã¥ãŒãå€æŽããã«ã³ã³ãããŒã«ã®ãµã€ãºãå€æŽã§ããå¿
èŠããããŸãã ãã¥ãŒã®ãµã€ãºãèšå®ãããšãã¯ã次ã®ç¹ãèæ
®ããå¿
èŠããããŸãã
- ãã¥ãŒãè€æ°ã®é åã§äœ¿çšãããå ŽåããŸãã¯ã©ãã§äœ¿çšããããããããªãå Žåã¯ãåçãªé«ããšå¹ ã§èšèšããŸãã
- ãã¥ãŒã®ãµã€ãºãåºå®ãããŠããå Žåãã·ã§ã«ã®é åã¯åçãªãµã€ãºã§ããå¿ èŠããããŸãã
- ã·ã§ã«ã®é åã®ãµã€ãºãåºå®ãããŠããå Žåããã¥ãŒã®ãµã€ãºã¯åçã§ããå¿ èŠããããŸãã
- ãã¥ãŒã«ã¯ãåºå®ã®é«ããšåçãªå¹
ãå¿
èŠãªå ŽåããããŸãã ãã®ã¢ãããŒãã®äŸãšããŠã æ ªåŒãã¬ãŒããŒRIã®ãµã€ãããŒã«ã¯
PositionPieChart
ãã¥ãŒããããŸãã - ä»ã®ãã¥ãŒã¯ãåçãªé«ããšå¹
ãæã€ããšãã§ããŸãã ããšãã°ã Stock Trader RIã®ãµã€ãããŒã«ãã
NewsReader
ã é«ãã¯ã¿ã€ãã«ã®é·ãã«äŸåããå¹ ã¯åžžã«é åã®ãµã€ãºã«å¯Ÿå¿ããå¿ èŠããããŸãã åãã«ãŒã«ãPositionSummaryViewã«ãé©çšãããŸããPositionSummaryViewã§ã¯ãããŒãã«ã®å¹ ãç»é¢ãµã€ãºã«ãé«ããããŒãã«å ã®è¡æ°ã«åãããŠèª¿æŽããå¿ èŠããããŸãã
- ãã¥ãŒã«ã¯åºæ¬çã«éæãªèæ¯ãå¿ èŠã§ããããã«ãããã·ã§ã«ã¯ç¬èªã®èæ¯ãæäŸã§ããŸãã
- è²ããã©ã·ãããã³ãã©ã³ããèŠçŽ ã®ããããã£ã«çŽæ¥å²ãåœãŠãã®ã§ã¯ãªããåžžã«ååä»ããªãœãŒã¹ã䜿çšããŠå²ãåœãŠãŸãã ããã«ãããã¢ããªã±ãŒã·ã§ã³ã®ãµããŒããå€§å¹ ã«ç°¡çŽ åãããŸãã ãŸããããã«ãããå®è¡æã«ãªãœãŒã¹ãã£ã¯ã·ã§ããªã®åçãªå€æŽã衚瀺ã§ããå ŽåããããŸãã
ã¢ãã¡ãŒã·ã§ã³
ã·ã§ã«ãŸãã¯ãã¥ãŒã§ã¢ãã¡ãŒã·ã§ã³ã䜿çšããå Žåã¯ã次ã®ç¹ãèæ ®ããŠãã ããã
- ã·ã§ã«ã®ã¬ã€ã¢ãŠããã¢ãã¡ãŒã·ã§ã³åã§ããŸããããã®ã³ã³ãã³ããšãã¥ãŒãåå¥ã«ã¢ãã¡ãŒã·ã§ã³åããå¿ èŠããããŸãã
- åãã¥ãŒãåå¥ã«èšèšããã³ã¢ãã¡ãŒã·ã§ã³åããŸãã
- ãœããã§æ§ãããªã¢ãã¡ãŒã·ã§ã³ã䜿çšããŠãèŠèŠèŠçŽ ããã¥ãŒã«è¿œå ãŸãã¯åé€ãããããšã瀺ããŸãã ããã«ãããã¢ããªã±ãŒã·ã§ã³ã«å æ²¢ãäžããããŸãã
Expression Blendã¯ãç¶æ ãšã€ãã³ãã«åºã¥ããŠã¢ãã¡ãŒã·ã§ã³ãšé·ç§»ãäœæããã³ç·šéããããã®è±å¯ãªäžé£ã®åäœãæžè¡°æ©èœãããã³èšå€§ãªæ©äŒãæäŸããŸãã 詳现ã«ã€ããŠã¯ãMSDNã®èšäºãVisualStateManagerã¯ã©ã¹ããåç §ããŠãã ããã
ã©ã³ã¿ã€ã æé©å
ããã©ãŒãã³ã¹ãæé©åããã«ã¯ã次ã®ç¹ãèæ ®ããŠãã ããã
- ã¹ã¿ã€ã«ã®éè€ãé²ãããã«ãå
±æãªãœãŒã¹ã
App.xaml
ãã¡ã€ã«ãŸãã¯App.xaml
å¯èœãªèŸæžã«é 眮ããŸãã - Silverlightã§ã¯ãèŠåºããªã©ãã¢ããªã±ãŒã·ã§ã³ã®ä»ã®éšå以å€ã®ããã¹ãã¹ã¿ã€ã«ã«éã·ã¹ãã ãã©ã³ãã䜿çšããªãã§ãã ããã ãã®å Žåãããã¹ãããã¹ã«å€æããããã¢ããªã±ãŒã·ã§ã³ã«ãã©ã³ããåã蟌ãããšãæ€èšããŠãã ããã äžéšã®ãã©ã³ããã¡ã€ã«ã¯æ¯èŒç倧ãããããã¢ããªã±ãŒã·ã§ã³ã«ãã©ã³ããåã蟌ããšããã®ãµã€ãºã«å€§ãã圱é¿ããå¯èœæ§ããããŸãã ããŠã³ããŒããã.xapãã¡ã€ã«ã®ãµã€ãºãå°ããããããã«ãExpression Blendã§ã¯ããã©ã³ãå šäœã§ã¯ãªããæåã®ãµãã»ããã®ã¿ãããŒãã§ããŸãã
詳现ã«ã€ããŠã¯ã ãSilverlightã§ã®ã«ã¹ã¿ã ãã©ã³ãã®äœ¿çšããåç §ããŠãã ããã
èšèšæã®æé©å
以äžã¯ãã¢ããªã±ãŒã·ã§ã³ã®èŠèŠçãªèšèšäžã«çºçããåé¡ã®ããã€ãã«å¯Ÿããæšå¥šäºé ãšè§£æ±ºçã§ãã
å€ãã®XAMLãªãœãŒã¹ãåããåªãããœãªã¥ãŒã·ã§ã³
å€ãã®XAMLãªãœãŒã¹ãå«ãŸãã倧èŠæš¡ãªãœãªã¥ãŒã·ã§ã³ã§ã¯ãããžã¥ã¢ã«ãšãã£ã¿ãŒã®èªã¿èŸŒã¿æéãå€§å¹ ã«å¢å ããå¯èœæ§ããããŸãã ããã¯ãããžã¥ã¢ã«ãšãã£ã¿ããã¹ãŠã®åã蟌ã¿ãªãœãŒã¹ãããŠã³ããŒãããŠè§£æããå¿ èŠãããããã«çºçããŸãã ããã«å¯ŸåŠãã1ã€ã®æ¹æ³ã¯ããã¹ãŠã®XAMLãªãœãŒã¹ãå¥ã®ãããžã§ã¯ãã«è»¢éãããã®ãããžã§ã¯ããã³ã³ãã€ã«ããŠãããå ã®ãããžã§ã¯ãããçµæã®DLLãžã®ãªã³ã¯ãäœæããããšã§ãã çŸåšããã¹ãŠã®ãªãœãŒã¹ã¯ãã€ããªã¢ã»ã³ããªã«ãªã£ãŠãããããèšèšè ã¯ç¬èªã«ãªãœãŒã¹ãå解ããå¿ èŠããªããèšèšäžã®çç£æ§ã«ãã©ã¹ã®åœ±é¿ãåãŒããŸãã XAMLãªãœãŒã¹ãå¥ã®ãããžã§ã¯ãã«ç§»åããå ŽåããªãœãŒã¹ã«
ComponentResourceKeys
ã䜿çšããããšãæ€èšã§ããŸãã 詳现ã«ã€ããŠã¯ãMSDNã®ãComponentResourceKey Markup Extensionããåç §ããŠãã ããã
XAMLãªãœãŒã¹
XAMLã¯ãç»åãå³ãå³é¢ã3Dã·ãŒã³ãªã©ã®ãªãœãŒã¹ãäœæããããã®åŒ·åã§è¡šçŸåè±ããªèšèªã§ãã äžéšã®éçºè ããã³èšèšè ã¯ãã°ã©ãã£ãã¯ã€ã¡ãŒãžã䜿çšãã代ããã«ããã®ãããªãªãœãŒã¹ãäœæããããšã奜ã¿ãŸãã ãã®ã¢ãããŒãã®æåã®å©ç¹ã¯ãç»é¢è§£å床ã®ç¬ç«æ§ã§ãã 2çªç®ã¯ãExpression Suiteã®ã¿ã䜿çšããŠãå¿ èŠãªãã¹ãŠã®ãªãœãŒã¹ãäœæããã¢ããªã±ãŒã·ã§ã³ãèšèšããæ©èœã§ãã
ããžã¥ã¢ã«ãšãã£ã¿ãŒãšãã«ã
ãªãœãŒã¹ã«å¥ã®ã¢ã»ã³ããªã䜿çšããããšã®æ¬ ç¹ã¯ãExpression Blendããã³Visual Studio 2010ã®ããããã£ãšãã£ã¿ãŒããã®ãããªã¢ã»ã³ããªã«ãããªãœãŒã¹ã衚瀺ããªãããšã§ãã ãããã£ãŠãä»ã®ã¢ã»ã³ããªã«ãããªãœãŒã¹ã®ååãæåã§å ¥åããå¿ èŠããããŸãã
Silverlight Design-Time App.xamlãªãœãŒã¹
è€åSilverlightã¢ããªã±ãŒã·ã§ã³ã¯ãã¢ã»ã³ããªã®èªã¿èŸŒã¿ã®é 延ã«ããèªã¿èŸŒã¿æéã®ççž®ãšãåæ.xapãã¡ã€ã«ã®åæžã®äž¡æ¹ãè¡ãããã«æ§æã§ããŸãã 1ã€ã®æŠç¥ã¯ãã¡ã€ã³ã®Silverlightã¢ããªã±ãŒã·ã§ã³ãäœæããåã¢ãžã¥ãŒã«ã«ãµãã©ã€ãã¢ã»ã³ããªãè¿œå ããããšã§ãã ãã®ãããªã¢ã»ã³ããªãè¿œå ãããšãããã³ãã¬ãŒãã®1ã€ãéžæã§ããŸããããã¯ãSilverlightãããžã§ã¯ããŸãã¯Silverlightã¯ã©ã¹ã©ã€ãã©ãªã®ããããã§ãã
ãµãã©ã€ãã¢ã»ã³ããªçšã®Silverlightãããžã§ã¯ããã³ãã¬ãŒããéžæãããšãå±éæã«å©ç¹ãåŸ
.xap
ãŸããã¢ã»ã³ããªã¯ã³ã³ãã€ã«æã«
.xap
ãã¡ã€ã«ã«ããã¯ãããŸãã ãã ãã1ã€ã®ãœãªã¥ãŒã·ã§ã³ã«è€æ°ã®Silverlightãããžã§ã¯ããããå Žåãããžã¥ã¢ã«ãã¶ã€ããŒã¯ã¢ã¯ãã£ããªãããžã§ã¯ãã®
App.xaml
ãã¡ã€ã«ã®ãªãœãŒã¹ã®ã¿ã䜿çšãããšãã
App.xaml
ãŸãã
Expression Blend 4ã¯ããã®åé¡ã®è§£æ±ºçãæäŸããŸãã ãã®ãããªåé¡ãç¹å®ãããšããã€ã¢ãã°ã衚瀺ããŠãã¢ããªã±ãŒã·ã§ã³å šäœã§äœ¿çšãããå¿ èŠãªãªãœãŒã¹ã©ã€ãã©ãªãéžæããããææ¡ããŸãã Visual Studio 2010ã«ã¯ãããããã®ãããªæ©èœã¯ãããŸããããµãã©ã€ãã¢ã»ã³ããªã¯ããã¹ãŠã®ã¢ããªã±ãŒã·ã§ã³ã¬ãã«ã®ãªãœãŒã¹ãå¥ã®ã¢ã»ã³ããªã«é 眮ããªãéããããžã¥ã¢ã«ç·šéãåãããã«ãµããŒãããŸããã ãã®ã¢ãããŒããéžæããå Žåã¯ãã¢ããªã±ãŒã·ã§ã³ããããã€ããåã«ãµãã©ã€ãã¢ã»ã³ããªãããžã§ã¯ããããããã®ãªãœãŒã¹ãåé€ããŠãã ããã
èšèšã«é©ãããã¥ãŒã¬ã€ã
次ã®ãã€ã³ãã¯ãèšèšã«é©ãããã¥ãŒã®ç¹æ§ã§ãïŒ ãã¬ã³ãå¯èœ ããŸãã¯ããŒã« å¯èœãšãåŒã°ããŸãïŒã
- Visual Studioã®ãã¶ã€ããŒãŸãã¯Expression Blendã䜿çšããŠå¹æçã«ç·šéã§ããŸãã
- ãã€ã³ãã£ã³ã°åŒãã«ããŒãªã©ãããŸããŸãªããŒã«ã䜿çšã§ããŸãã
- èšèšäžã«è¡šç€ºãããµã³ãã«ããŒã¿ãæäŸããŸãã
- ããã«ãããæªåŠçã®äŸå€ãçæããã«èšèšæã«ã³ãŒããå®è¡ã§ããŸãã
以äžã®æäœã¯ãç·šéäžã«äœåºŠãå®è¡ãããŸãã èšèšè ã«éŠŽæã¿ã®ãªãã«ã¹ã¿ã ã³ãŒãã¯ãå®è¡ã«å¹²æžããèšèšè ãŸãã¯ããã°ã©ãã®çç£æ§ãäœäžãããå¯èœæ§ããããŸãã
- è¡šé¢åŠçã®èšèšïŒ
- ãªããžã§ã¯ããäœæãã
- ãªããžã§ã¯ãã®èªã¿èŸŒã¿
- ããããã£å€ã®èšå®
- ãã¶ã€ã³ãµãŒãã§ã¹ã€ãã³ãåŠç
- ã«ãŒãèŠçŽ ãšããŠã³ã³ãããŒã«ã䜿çšãã
- ããã³ã³ãããŒã«ãå¥ã®ã³ã³ãããŒã«å ã«é 眮ãã
- XAMLãã¡ã€ã«ãéããéããŠããªããŒããã
- ãããžã§ã¯ãã®åã³ã³ãã€ã«
- ãã¶ã€ããŒã®ãªããŒã
- ãã€ã³ãã£ã³ã°åŒãã«ããŒã®ã¢ã¯ã·ã§ã³ïŒ
-
DataContext
æ€åº - å©çšå¯èœãªããŒã¿ãœãŒã¹ã®ãªã¹ã
- ããŒã¿ãœãŒã¹ã¿ã€ãã®ããããã£ã®åæ
-
- èšèšæã®ãµã³ãã«ããŒã¿ã®ã¢ã¯ã·ã§ã³ïŒ
- ãµã³ãã«ããŒã¿ãæ£ãã衚瀺ããããã®ãã¶ã€ã³ãµãŒãã§ã€ã¹äžã®ã³ã³ãããŒã«ã®äœ¿çš
èšèšäžã«å®è¡ããã³ãŒãã®äœæ
ãã¶ã€ããŒã䜿çšããããã«ãVisual StudioãšExpression Blendã¯ãªããžã§ã¯ããäœæããèšèšäžã«ã³ãŒããå®è¡ããŸãã ãã ãããªããžã§ã¯ããäœæãããåã«ãªããžã§ã¯ãã«ã¢ã¯ã»ã¹ããããšããã³ãŒããåå ã®nullåç §äŸå€ã¯ãèšèšäžã«å€æ°ã®èªã¿èŸŒã¿ãšã©ãŒãšäžèŠãªäŸå€ãåŒãèµ·ããå¯èœæ§ããããŸãã
次ã®è¡šã«ããã¶ã€ããŒã®äœ¿ããããã«åœ±é¿ããäž»ãªåé¡ã瀺ããŸãã ãããã®åé¡ãåé¿ãããã¯ããã¯ã䜿çšããŠä¿®æ£ããããšã«ãããããžã¥ã¢ã«ãã¶ã€ããŒã䜿çšããããšã§çç£æ§ãšæºè¶³åºŠãå€§å¹ ã«åäžãããããšãã§ããŸãã
ããªãã®ã³ãŒãã§ã¯ãããé¿ããŠãã ãã
| Visual Studio 2010
| ãã¬ã³ã4
|
èšèšäžã«è€æ°ã®ã¹ã¬ãããå®è¡ããŸãã ããšãã°ãã³ã³ã¹ãã©ã¯ã¿ãŒãŸãã¯Loaded
ã€ãã³ã㧠Timer
ãäœæã㊠Loaded
ãŸãã | ||
èšèšäžã«ã¹ã¿ãã¯ãªãŒããŒãããŒãåŒãèµ·ããå¯èœæ§ãããã³ã³ãããŒã«ããŸãã¯ååž°çã«èªåèªèº«ãããŒãããã³ã³ãããŒã«ã䜿çšããŸãã | ||
ã³ã³ããŒã¿ãŒãŸãã¯ããŒã¿ãã³ãã¬ãŒãã»ã¬ã¯ã¿ãŒã§nullåç §äŸå€ãã¹ããŒããŸãã | ||
nullåç
§äŸå€ããŸãã¯ã³ã³ã¹ãã©ã¯ã¿ãŒå
ã®ä»ã®äŸå€ãã¹ããŒããŸãã ããã¯æ¬¡ã«ãã£ãŠåŒãèµ·ããããå¯èœæ§ããããŸãã
| ||
nullåç
§äŸå€ããŸãã¯ã³ã³ãããŒã«ã®Loaded
ã€ãã³ãå ã®ä»ã®äŸå€ã Loaded
ãŸãã ããã¯ãã³ã³ãããŒã«ã®ç¶æ ã«ã€ããŠä»®å®ãããšãã«çºçããå¯èœæ§ããããŸããããã¯ãå®è¡æã«ã¯åœãŠã¯ãŸãããèšèšæã«ã¯å®è¡ãããªãå¯èœæ§ããããŸãã | ||
èšèšäžã«Application
ããŸã㯠Application.Current
ãªããžã§ã¯ãã«ã¢ã¯ã»ã¹ããããšããŸãã | ||
WPF UserControls
StaticResource
ã䜿çšããŸãã | ||
éåžžã«å€§èŠæš¡ãªãããžã§ã¯ãã®äœæã |
èšèšäžã®ã³ãŒãã®åé¡ã®åŠç
å€ãã®é²åŸ¡çãªããã°ã©ãã³ã°ææ³ã«ãããäžèšã®è¡šã«ãªã¹ããããŠããã»ãšãã©ãã¹ãŠã®é ç®ãæé€ã§ããŸãã ãã ããèšèšäžã«å®è¡ãããã³ãŒãã®åé¡ã«åãçµãåã«ãã³ã³ãããŒã«ãšã¢ããªã±ãŒã·ã§ã³ã³ãŒããåæåãããŠããªãã¢ããªã±ãŒã·ã§ã³ãã¡ã€ã³å ã§èšèšè ã«ãã£ãŠåç¬ã§å®è¡ãããããšãç解ããå¿ èŠããããŸãã ãã®ã³ã³ããã¹ãã§ã¯ãåæåãããŠããªããšããããšã¯ãããŒãããŒããŒãŸãã¯åæåã³ãŒããå®è¡ãããªãããšãæå³ããŸãã
ã¢ããªã±ãŒã·ã§ã³ãèµ·ååŸã«å®è¡ãéå§ãããšã
App.xaml.cs
ã®ã³ãŒã
App.xaml.cs
ãŸãã ã¢ããªã±ãŒã·ã§ã³ãäŸåããã³ãŒããããå Žåãèšèšäžã«å®è¡ãããŸããã äºæããªãå ŽåãäžèŠãªäŸå€ã確å®ã«çºçããŸãã ãããä¿®æ£ããã«ã¯ïŒ
- èšèšäžã«ãªããžã§ã¯ããäœæããããšæã蟌ãŸãªãã§ãã ããã èšèšäžã«å®è¡ã§ããã³ãŒãã§ã¯ããªããžã§ã¯ããæäœããåã«åžžã«
null
確èªããŠãã ããã - ã³ãŒãã
Application
ãªããžã§ã¯ããŸãã¯Application.Current
ãªããžã§ã¯ãã§åäœããå Žåã¯ããã®åã«null
確èªããŠãã ããã - ã³ã³ã¹ãã©ã¯ã¿ãŒãŸãã¯
Loaded
ã€ãã³ãã®ã³ãŒããããŒã¿ããŒã¹ãŸãã¯ãããã¯ãŒã¯ãµãŒãã¹ã«ã¢ã¯ã»ã¹ããå Žåã¯ã次ã®ãªãã·ã§ã³ãæ€èšããŠãã ããã
- ã³ãŒããåŒã³åºãåã«ã次ã®ã¡ãœãããåç
§ããŠããã¶ã€ããŒã§å®è¡ãããŠãããã©ããã確èªããŸãã
- WPF ïŒ
DesignerProperties.GetIsInDesignMode
- Silverlight ïŒ
DesignerProperties.IsInDesignTool
- WPF ïŒ
- ã³ã³ã¹ãã©ã¯ã¿ãŒãŸãã¯
Loaded
ã€ãã³ããã³ãã©ãŒã§ã³ãŒããçŽæ¥å®è¡ãã代ããã«ãã€ã³ã¿ãŒãã§ã€ã¹ãéããŠã¡ãœããåŒã³åºãã®èåŸã§ã³ãŒããæœè±¡åããŸãããã®åŸãå®è¡æãèšèšãããã³ãã¹ãã§ããŸããŸãªå®è£ ã䜿çšããããã®å€ãã®ææ³ã®1ã€ãé©çšã§ããŸãã
- ã³ãŒããåŒã³åºãåã«ã次ã®ã¡ãœãããåç
§ããŠããã¶ã€ããŒã§å®è¡ãããŠãããã©ããã確èªããŸãã
èšèšäžã«ã³ãŒããå®è¡ãããããšã決å®ãã
Expression BlendãšVisual Studioã¯ã©ã¡ããããã¶ã€ããŒããã«ã«è¡šç€ºãããã«ãŒããªããžã§ã¯ãã¬ã€ã¢ãŠãã䜿çšããŸãã ããã¯ãèšèšè ã«å¿ èŠãªæ©èœãæäŸããããã«å¿ èŠã§ãã ã«ãŒããªããžã§ã¯ãã¯åœç©ãªã®ã§ããã®ã³ã³ã¹ãã©ã¯ã¿ãŒãš
Loaded
ã€ãã³ãã¯èšèšäžã«åŒã³åºãããŸããã ãã ããã¹ããŒãžäžã®æ®ãã®ã³ã³ãããŒã«ã¯éåžžã©ããã«æ§ç¯ããããããã®
Loaded
ã€ãã³ãã¯å®è¡æãšåæ§ã«çºçããŸãã
次ã®å³ã§ã¯ã
Windows
ã«ãŒãèŠçŽ ã®ã³ã³ã¹ãã©ã¯ã¿ãŒãšãã®
Loaded
ã€ãã³ãã¯åŒã³åºããããåèŠçŽ ã¯åŒã³åºãããŸããã
ãã®æŠå¿µã¯ãå®è¡æã«åçã«æ§ç¯ãããè€åã¢ããªã±ãŒã·ã§ã³ãäœæããå Žåã«ç¹ã«éèŠã§ãã
ã¢ããªã±ãŒã·ã§ã³ã®ã»ãšãã©ã®ãã¥ãŒã¯ç¬ç«ããŠäœæãããŸãã ãã®ãããéåžžã¯ãããããã¶ã€ããŒã®ã«ãŒããªããžã§ã¯ãã§ãããã³ã³ã¹ãã©ã¯ã¿ãŒãš
Loaded
ã€ãã³ãã¯åŒã³åºãããŸããã
ãã ãã以åã«åé¢ãããåèŠçŽ ãšããŠãã¶ã€ã³ãµãŒãã§ã€ã¹ã«ãã®ãããªã³ã³ãããŒã«ãé 眮ãããšããã¶ã€ã³äžã«å®è¡ãéå§ããããã«ãªããŸããã äžèšã®ãã¶ã€ã³ãã©ã¯ãã£ã¹ã«åŸããªãã£ãå Žåããã®èŠçŽ ãäºæãã¬äžå¿«ãªãšã©ãŒã®åå ãšãªããããžã¥ã¢ã«ãã¶ã€ããŒã®äœ¿ãããããäœäžããå¯èœæ§ããããŸãã
èšèšæã®ããããã£
æ¥é èŸã
d:
ããä»ããçµã¿èŸŒã¿ã®èšèšæããããã£ã¯ãèšèšäžã®çç£æ§ãåäžãããç°¡åãªæ¹æ³ãæäŸããŸãã
ç§ãã¡ã解決ããããšããŠããåé¡ã¯ããã¶ã€ããŒããªãã¬ã¯ã·ã§ã³ãéããŠããããã£ã«é¢ããæ å ±ãååŸã§ããåã®ãã€ã³ãã£ã³ã°åŒãæäŸããããšã§ãã ãŸããèšèšäžã«è¡šç€ºããããµã³ãã«ããŒã¿ãæäŸããå¿ èŠããããŸãã
次ã®ã»ã¯ã·ã§ã³ã§ã¯ã
d:DataContext
ãš
d:DesignInstance
ããŒã¯ã¢ãã
d:DesignInstance
䜿çšæ¹æ³ã«ã€ããŠèª¬æããŸãã
åã®æ®µèœã®ã
d:
ãã¯ãèšèšæããŒã«ãé 眮ãããŠããããŒã ã¹ããŒã¹ã®ãšã€ãªã¢ã¹ã§ãã 次ã®èšäºã§ã¯ãã
d:
ãããããã£ãšããŒã¯ã¢ããæ¡åŒµæ©èœã«ã€ããŠè©³ãã説æããŠããŸãã
- ãWPFãã¶ã€ããŒã®ãã¶ã€ã³æå±æ§ã
- ãSilverlightãã¶ã€ããŒã®ãã¶ã€ã³æå±æ§ã
ã
d:
ãããããã£ããã³ããŒã¯ã¢ããæ¡åŒµæ©èœã¯ããŠãŒã¶ãŒã³ãŒãã§äœæãŸãã¯äœ¿çšããããšã¯ã§ããŸãããXAMLã§ã®ã¿é©çšã§ããŸãã ãŸããã¢ããªã±ãŒã·ã§ã³ã«ã³ã³ãã€ã«ããããVisual Studioããã³Expression Blendã®ããŒã«ã§ã®ã¿äœ¿çšãããŸãã
ããããã£dïŒDataContext
d:DataContext
ã¯ãã³ã³ãããŒã«ãšãã®åå«ã®ã©ã³ã¿ã€ã ããŒã¿ã³ã³ããã¹ããèšå®ããŸãã
d:DataContext
æå®ããå Žåãå®è¡æã«
DataContext
ããŒã¿ã³ã³ããã¹ãã«åžžã«åãã¿ã€ãã®ããŒã¿ãæäŸããå¿ èŠããããŸãã
ã³ã³ãããŒã«ã«
DataContext
ãš
d:DataContext
æå®ãããŠããå ŽåãèšèšããŒã«ã¯
d:DataContext
ãéžæããŸãã
DããŒã¯ã¢ããæ¡åŒµæ©èœïŒDesignInstance
ããŒã¯ã¢ããæ¡åŒµæ©èœãããããªãå Žåã¯ãMSDNã®èšäºãããŒã¯ã¢ããæ¡åŒµæ©èœãšWPF XAMLããèªãããšããå§ãããŸãã
d:DesignInstance
ã¯ãèšèšäžã«ããŒã¿ã³ã³ããã¹ããšããŠäœ¿çšããã¿ã€ãã®ãªããžã§ã¯ããäœæããŠè¿ããŸãã ãã®ã¿ã€ãã¯ããªããžã§ã¯ããäœæããæ©èœãæã€å¿ èŠã¯ãããŸããã 次ã®æ®µèœã§ã¯ã
d:DesignInstance
ããããã£ã«ã€ããŠèª¬æããŸãã
ããŒã¯ã¢ããæ¡åŒµãããã㣠| 説æ |
---|---|
Type
| ã¿ã€ãåã Typeã¯ã³ã³ã¹ãã©ã¯ã¿ãŒãã©ã¡ãŒã¿ãŒã§ãã |
IsDesignTimeCreatable
| ãã®ã¿ã€ãã®ã€ã³ã¹ã¿ã³ã¹ãäœæãããã©ããã決å®ããŸãã false
å Žåãå®éã®æ¬äŒŒåã§ã¯ãªããæ¬äŒŒåãäœæãããŸãã ããã©ã«ãå€ã¯falseã§ãã |
CreateList
| trueã®å Žåããã®ã¿ã€ãã®èŠçŽ ãå«ãäžè¬åãªã¹ããè¿ããŸãã ããã©ã«ãå€ã¯false
ã§ãã |
dã®äžè¬çãªäœ¿çšäŸïŒDataContext
次ã®ã³ãŒãäŸã¯ããã¥ãŒããã¬ãŒã³ããŒã·ã§ã³ã¢ãã«ã«é¢é£ä»ããããã®ç¹°ãè¿ããã¿ãŒã³ã瀺ããŠããŸãã
PersonViewã¯ãå®è¡æã«è§£æ±ºããã
PersonViewModel
äŸåããŠããŸãã äŸã§ç€ºãããŠããã¢ãã«ã¯æå³çã«åçŽåãããŠããŸãããå®éã®ã¢ããªã±ãŒã·ã§ã³ã§ã¯ãéåžžãã³ã³ã¹ãã©ã¯ã¿ãŒã«æ³šå ¥ãããäŸåé¢ä¿ããããŸãã
äœæããããš
PersonView
ããã®äŸåé¢ä¿
PersonViewModel
ãäœæãããã³ã³ãããéããŠè§£æ±ºãããŸãã
ã泚æ
ãã¬ãŒã³ããŒã·ã§ã³ã¢ãã«ã«äŸåé¢ä¿ããªãå Žåã¯ãå®å šã«XAMLã§äœæã§ããŸãããã®ã€ã³ã¹ããŒã«ã§ã¯DataContext
ãããã³d:DataContext
å¿ èŠãšãããŠããŸããã
PersonViewModel.cs
[Export] public class PersonViewModel { public String FirstName { get; set; } public String LasName { get; set; } }
PersonView.xaml.cs
[Export] public partial class PersonView : UserControl { public PersonView() { InitializeComponent(); } [Import] public PersonViewModel ViewModel { get { return this.DataContext as PersonViewModel; } set { this.DataContext = value; } } }
ããã¯ããã¬ãŒã³ããŒã·ã§ã³ãšãã¬ãŒã³ããŒã·ã§ã³ã¢ãã«ããªã³ã¯ããã®ã«é©ãããã³ãã¬ãŒãã§ãããã ããèšèšäžã«ã©ã®ããŒã¿ã³ã³ããã¹ãã䜿çšããã¹ãããšããèãã¯æéã®äžã«æ®ããŸãã
次ã®XAMLã§ã¯ãããããã£ãèšå®ãããŠããæ¬äŒŒã€ã³ã¹ã¿ã³ã¹ãè¿ã
d:DesignInstance
èŠçŽ
Grid
ã§äœ¿çšãããããŒã¯ã¢ããæ¡åŒµæ©èœã確èªã§ããŸãããã®çµæãã®åã¯valueãç¶æ¿ããŸããããã«ãããèšèšããŒã«ã䜿çšããŠããŒã¿ã³ã³ããã¹ãã®ããããã£ãšã¿ã€ãã確èªã§ãããã¶ã€ããŒãšããã°ã©ããŒã®äœæ¥ãå€§å¹ ã«å®¹æã«ãªããŸããPersonView.xaml
PersonViewModel
d:DataContext
Grid
d:DataContext
<UserControl xmlns:local="clr-namespace:WpfApplication1" x:Class="WpfApplication1.PersonView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"> <Border BorderBrush="LightGray" BorderThickness="1" CornerRadius="10" Padding="10"> <Grid d:DataContext="{d:DesignInstance local:PersonViewModel}"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="100" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <Label Grid.Column="0" Grid.Row="0" Content="First Name" /> <Label Grid.Column="0" Grid.Row="1" Content="Las Name" /> <TextBox Grid.Column="1" Grid.Row="0" Width="150" MaxLength="50" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Path=FirstName, Mode=TwoWay}" /> <TextBox Grid.Column="1" Grid.Row="1" Width="150" MaxLength="50" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Path=LasName, Mode=TwoWay}" /> </Grid> </Border> </UserControl>
: ViewModel Locator .
, . , , , .DataContext
. , , .
,d:DataContext â d:DesignInstance
, ,d:DesignInstance
ã
䜿çšããæ©åšã«é¢ä¿ãªããã¢ããªã±ãŒã·ã§ã³å šäœã§äžè²«ããŠäœ¿çšããå¿ èŠããããŸããäžè²«æ§ã«ãããã¢ããªã±ãŒã·ã§ã³ã®å±éãç°¡çŽ åãããèšèšè ãšããã°ã©ããŒéã®å¯Ÿè©±ãæåããŸãã
èšèšæã®ãµã³ãã«ã¬ã€ã
WPFããã³Silverlightã®èšèšããŒã ã¯ãWPFããã³Silverlightãããžã§ã¯ãã§ã®ãµã³ãã«ããŒã¿ã®äœ¿çšã«ã€ããŠèª¬æãã詳现ãªèšäºãå ¬éããŠããŸããMSDNã®èšäºãWPFããã³Silverlight Designerã®ãµã³ãã«ããŒã¿ããåç §ããŠãã ããã
ãµã³ãã«ããŒã¿ã®äœ¿çšïŒãã¶ã€ã³ã¿ã€ã ãµã³ãã«ããŒã¿ïŒ
Expression BlendãVisual Studioãªã©ã®ããžã¥ã¢ã«ãã¶ã€ã³ããŒã«ã䜿çšããå Žåããµã³ãã«ããŒã¿ã¯ç¹ã«éèŠã«ãªããŸãããã¥ãŒã«ã¯ããŒã¿ãšç»åãå ¥åã§ããŸããããã«ããããã¶ã€ããŒã®äœæ¥ãå€§å¹ ã«ç°¡çŽ åãããçç£æ§ãåäžããŸãã
ããŒã¿ãã³ãã¬ãŒããå«ã空ã®ãªã¹ãã¯ãããŒã¿ãè¿œå ãããŸã§è¡šç€ºãããŸããããããã£ãŠãé衚瀺ã®ããŒã¿ãã³ãã¬ãŒããç·šéããã¢ããªã±ãŒã·ã§ã³ãå®æçã«èµ·åããŠãã®å€èŠ³ã確èªãããšãäœæ¥ãå€§å¹ ã«é ããªãããã¶ã€ããŒãããã°ã©ããŒã®ç·åŒµãé«ãŸããŸãã
ãµã³ãã«ããããœãŒã¹
次ã®ãœãŒã¹ãããµã³ãã«ããŒã¿ãååŸã§ããŸãã
- Expression Blend XMLãµã³ãã«ããŒã¿
- Expression Blend 4ããã³Visual Studio 2010 XAMLãµã³ãã«ããŒã¿
- XAMLãªãœãŒã¹
- ã³ãŒã
ãããã®ãœãŒã¹ããã®ããŒã¿ã®ååŸã«ã€ããŠã¯ã以äžã§èª¬æããŸãã
Expression Blend XMLãµã³ãã«ããŒã¿
Expression Blendã䜿çšãããšãXMLã¹ããŒãããã°ããäœæãã察å¿ããXMLãã¡ã€ã«ã«ããŒã¿ãå ¥åã§ããŸããããã¯ãç¡é¢ä¿ãªãããžã§ã¯ãããœãªã¥ãŒã·ã§ã³ã«è¿œå ããããšãªãè¡ãããŸãã
ãã®ã¿ã€ãã®ãµã³ãã«ããŒã¿ã®ç®çã¯ãããã°ã©ããŒãå¿ èŠãªã¯ã©ã¹ãèšè¿°ããã®ãåŸ ããã«ããã¶ã€ããŒããããžã§ã¯ãã®äœæ¥ãéå§ã§ããããã«ããããšã§ãã
ã»ãšãã©ã®ãµã³ãã«ããŒã¿ã¯Expression BlendãšVisual Studio 2010ãã¶ã€ããŒã®äž¡æ¹ã§äœ¿çšã§ããŸãããXMLãµã³ãã«ããŒã¿ã¯Expression Blendã®æ©èœã§ãããVisual Studio 2010ã«ã¯è¡šç€ºãããŸããã
ã泚æ
ãµã³ãã«XMLããŒã¿ãã¡ã€ã«ã¯ã³ã³ãã€ã«ããããã¢ã»ã³ããªã«è¿œå ãããŸããããã ããXMLã¹ããŒãã¯æçµã¢ã»ã³ããªã«ã³ã³ãã€ã«ãããŸãã
Expression Blend 4ããã³Visual Studio 2010 XAMLãµã³ãã«ããŒã¿
Expression Blend 4ããã³Visual Studio 2010ãããããŒã¯ã¢ããæ¡åŒµæ©èœãè¿œå ãã
d:DesignData
ããã¶ã€ã³äžã«ãµã³ãã«ããŒã¿ãããŒãã§ããããã«ãªããŸããã
ãµã³ãã«ããŒã¿ãå«ãXAMLãã¡ã€ã«ã«ã¯ã1ã€ãŸãã¯è€æ°ã®ã¿ã€ãã€ã³ã¹ã¿ã³ã¹ãäœæãããããŒã¯ã¢ãããå«ãŸããŸãããã®åŸãããã€ãã®ããŒã¿ãããããã£ã«å²ãåœãŠãããŸãã
ãã
d:DesignData
財ç£ã§ãã
Source
ãããžã§ã¯ãã«ãããµã³ãã«ããŒã¿ãæã€XAMLãã¡ã€ã«ãžã®URIãåããŸããããŒã¯ã¢ããæ¡åŒµæ©èœã¯
d:DesignData
ããã®ãã¡ã€ã«ãããŠã³ããŒãããŠè§£æãããªããžã§ã¯ãã°ã©ããè¿ããŸãã property
d:DataContext
ãproperty
CollectionViewSource d:DesignSource
ããŸãã¯property ã§äœ¿çšã§ããŸã
DomainDataSource d:DesignData
ã
æ¡åŒµæ©èœã«ãã£ãŠè§£æ±ºãããåé¡ã®1ã€
d:DesignData
ãäœæã§ããªãã«ã¹ã¿ã ã¿ã€ãã®ãµã³ãã«ããŒã¿ãäœæã§ããããšã§ããããšãã°ãWCF RIAã¢ããªã±ãŒã·ã§ã³ã§ã¯ããµãŒãã¹ãšã³ãã£ãã£ãªããžã§ã¯ããã³ãŒãã§äœæããããšã¯ã§ããŸãããããã«å ããŠãéçºè ã¯ç¬èªã®äœæãããŠããªãã¿ã€ããæã£ãŠããå¯èœæ§ãããããã®ããã«ãµã³ãã«ããŒã¿ãäœæããããšèããŠããŸãã以äžã«ç€ºãããã«ããœãªã¥ãŒã·ã§ã³ãšã¯ã¹ãããŒã©ãŒã§ããŒã¿ãã¡ã€ã«ã®ãã«ãã¢ã¯ã·ã§ã³ããããã£ãèšå®
ããããšã«ããã
d:DesignData
ãµã³ãã«ããŒã¿ã®åŠçæ¹æ³ãå€æŽã§ããŸãã
- ãã«ãã¢ã¯ã·ã§ã³= DesignData-ç䌌ã¿ã€ããäœæãããŸã
- ãã«ãã¢ã¯ã·ã§ã³= DesignDataWithDesignTimeCreatableTypes-å®éã®åãäœæãããŸã
Expression Blendã䜿çšããŠãµã³ãã«ããŒã¿ãäœæãããšãDesignDataã«æ¢ã«ã€ã³ã¹ããŒã«ãããŠãããã«ãã¢ã¯ã·ã§ã³ã䜿çšããŠXAMLãã¡ã€ã«ãäœæãããŸããå®éã®åãå¿ èŠãªå Žåã¯ãVisual Studioã§ãœãªã¥ãŒã·ã§ã³ãéããããŒã¿ãã¡ã€ã«ã®ãã«ãã¢ã¯ã·ã§ã³ãDesignDataWithDesignTimeCreatableTypesã«å€æŽããŸãã
ã泚æ
, Custom Tool . . , Expression Blend .
Visual Studio 2010, , . , Build Action Custom Tool .
Expression Blendã¯ãéžæçãªXAMLããŒã¿ããã°ããäœæããã³ãªã³ã¯ããããã®ããŒã«ãæäŸããŸãããã®ããŒã¿ã¯ã次ã®å³ã«ç€ºãããã«ãVisual Studio 2010ã®ãã¶ã€ããŒã§ã䜿çšã§ããŸãã
Expression Blend 4ã§ãµã³ãã«ããŒã¿ãå®çŸ©
ãããµã³ãã«ããŒã¿ãäœæãããšã次ã®ããã«ããŒã¿ããã«ã«è¡šç€ºãããŸãã
ããŒã¿ããã«ã
ãã®åŸããããããã¥ãŒã®ã«ãŒãèŠçŽ ã«ãã©ãã°ããŠã
UserControl
é©åã«ã€ã³ã¹ããŒã«ã
d:DataContext
ãŸãããµã³ãã«ããŒã¿ã®ã³ã¬ã¯ã·ã§ã³ãã«ãã©ãã°ããããšãã§ã
ItemsControl
ãŸãããã®åŸãBlendã¯ãã®ããŒã¿ãžã®ãã€ã³ãã£ã³ã°ãäœæããŸãã
ã泚æ
éžæçãªXAMLããŒã¿ã¯ã³ã³ãã€ã«ããããæçµã¢ã»ã³ããªã«å«ãŸããŸããã
XAMLãªãœãŒã¹
XAMLã§ãªãœãŒã¹ãäœæããŠãç®çã®ã¿ã€ããäœæããããã
DataContext
ããŸãã¯ãªã¹ãã«ãã€ã³ãã§ããŸãã
ãã®ææ³ã䜿çšãããšãããŒã¿ãã³ãã¬ãŒãã®ç·šéã«äœ¿çšããã1åéãã®ããŒã¿ããã°ããäœæã§ããŸãã
ã³ãŒã
ã³ãŒãã§ãµã³ãã«ããŒã¿ãäœæããå Žåã¯ããµã³ãã«ããŒã¿ãè¿ãããããã£ãšã¡ãœãããæã€ã¯ã©ã¹ãèšè¿°ã§ããŸããããšãã°ãå¿ èŠãªããŒã¿ã§æºããã
Customers
ãã¯ã©ã¹ã®ã€ã³ã¹ã¿ã³ã¹ã§ãæšæºã®ãã©ã¡ãŒã¿ãŒã¬ã¹ã³ã³ã¹ãã©ã¯ã¿ãŒã§ããèªèº«ãåããã¯ã©ã¹ãäœæã§ã
Customer
ãŸãã
ãã®ãããªããŒã¿ãæ¶è²»ãã1ã€ã®æ¹æ³ã¯
d:DataContext â d:DesignInstance
ãããããã£
d:DesignInstance.IsDesignTimeCreatable
ã
true
ã«èšå®ããŠãã³ãã«ã䜿çšããèšèšäžã«ã³ãŒããå®è¡ãããããã«ããããšã§ãããã®ããããã£ãèšå®ãããŠããªãå Žåãç䌌ã¿ã€ããäœæãããèšèšäžã«ã¿ã€ãããŒã¿ã®ã¿ã䜿çšå¯èœã«ãªããŸãã
次ã®XAMLã¯ãã¯ã©ã¹ã®ã€ã³ã¹ã¿ã³ã¹ãäœæãã
Customers
ããããšããŠèšå®ããæ¹æ³ã瀺ããŠã
d:DataContext
ãŸããåäŒç€Ÿ
Grid
ã³ã³ãããŒã«ã¯ãã¯ã©ã¹ãæäŸãããµã³ãã«ããŒã¿ã䜿çšã§ã
Customers
ãŸãã
<Grid d:DataContext="{d:DesignInstance local:Customers, IsDesignTimeCreatable=True}">
ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã¬ã€ã¢ãŠããäœæããéã®éèŠãªæ±ºå®
è€åã¢ããªã±ãŒã·ã§ã³ãããžã§ã¯ããäœæããå Žåãå°æ¥å€æŽããã®ãå°é£ãªãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹èšèšã«é¢ãã決å®ãè¡ãå¿ èŠããããŸããååãšããŠããããã¯ã¢ããªã±ãŒã·ã§ã³å šäœã®ã¬ãã«ã®æ±ºå®ã§ããããããã®äžè²«æ§ã¯éçºè ãšãã¶ã€ããŒã®çç£æ§ãåäžãããŸãã
ãããã®ãœãªã¥ãŒã·ã§ã³ã¯æ¬¡ã®ãšããã§ãã
- ã¢ããªã±ãŒã·ã§ã³ãããŒãå®çŸ©ããããã«å¿ããŠé åãèšå®ããŸãã
- 䜿çšãããåé åã«ããŒãããããã¥ãŒã®ã¿ã€ãã決å®ããŸãã
- Region Navigation APIã䜿çšãããã©ããã決å®ããŸãã
- , (MVVM, presentation model, ).
- .
è¿œå æ å ±
Prism Libraryæ¡åŒµæ©èœã®è©³çŽ°ã«ã€ããŠã¯ããPrismã®æ¡åŒµããåç §ããŠãã ããã
ã³ãã³ãã®è©³çŽ°ã«ã€ããŠã¯ã第5éšãMVVMãã¿ãŒã³ã®å®è£ ãã®ãã³ãã³ãããåç §ããŠãã ãããããŒã¿ãã€ã³ãã£ã³ã°ã®è©³çŽ°ã«ã€ããŠã¯ã第5éšãMVVMãã¿ãŒã³ã®å®è£ ãã®ãããŒã¿ãã€ã³ãã£ã³ã°ããåç §ããŠãã ããããªãŒãžã§ã³ã®ããã²ãŒã·ã§ã³ã®è©³çŽ°ã«ã€ããŠã¯ãããŒã8ãããã²ãŒã·ã§ã³ããåç §ããŠãã ããããã®ç« ã§èª¬æããã¬ã€ãã®è©³çŽ°ã«ã€ããŠã¯ã以äžãåç §ããŠãã ããã
- MSDNã®ãäŸåé¢ä¿ããããã£ã®æŠèŠãïŒ
- http://msdn.microsoft.com/en-us/library/ms752914.aspx .
- Data binding; see:
- «Data Binding Overview» on MSDN:
http://msdn.microsoft.com/en-us/library/ms742521.aspx . - «Data Binding in WPF» in MSDN Magazine :
http://msdn.microsoft.com/en-us/magazine/cc163299.aspx .
- «Data Binding Overview» on MSDN:
- «Data Templating Overview» on MSDN:
http://msdn.microsoft.com/en-us/library/ms742521.aspx . - «Resources Overview» on MSDN:
http://msdn.microsoft.com/en-us/library/ms750613.aspx . - «UserControl Class» on MSDN:
http://msdn.microsoft.com/en-us/library/system.windows.forms.usercontrol.aspx . - «VisualStateManager Class» on MSDN:
http://msdn.microsoft.com/en-us/library/cc626338(v=VS.95).aspx . - «Customizing Controls For Windows Presentation Foundation» in MSDN Magazine :
http://msdn.microsoft.com/en-us/magazine/cc163421.aspx . - «ComponentResourceKey Markup Extension» MSDN topic:
http://msdn.microsoft.com/en-us/library/ms753186.aspx . - «Design-Time Attributes in the WPF Designer» on MSDN:
http://msdn.microsoft.com/en-us/library/ee839627.aspx . - «Design-Time Attributes in the Silverlight Designer» on MSDN:
http://msdn.microsoft.com/en-us/library/ff602277(VS.95).aspx . - «Markup Extensions and WPF XAML» on MSDN:
http://msdn.microsoft.com/en-us/library/ms747254.aspx . - «Using Custom Fonts in Silverlight»:
http://silverlight.net/learn/learnvideo.aspx?video=69800 . - «Sample Data in the WPF and Silverlight Designer» on MSDN:
http://blogs.msdn.com/b/wpfsldesigner/archive/2010/06/30/sample-data-in-the-wpf-and-silverlight-designer.aspx . - Learning the Visual Studio WPF and Silverlight DesignerThis contains tutorials and articles on layout, resources, data binding, sample data, debugging data bindings, object data sources, and master-detail forms.
- http://blogs.msdn.com/b/wpfsldesigner/archive/2010/01/15/learn.aspx .