JavaScript側からXAML Objectにアクセスする方法
まず,XAMLにて
<Rectangle x:Name="control" Width="300" Height="300" Fill="#FFFFFFFF" MouseEnter="mouseOver" MouseLeave="mouseLeave"/>
などと名前(x:Name)とイベント(MouseEnter/MouseLeave)を登録.ちなみにFlashで言うところの,
- MouseEnter
- onRollOver
- MouseLeave
- onRollOut
に対応.これを制御するのがJavaScriptで,
function mouseOver( sender, args ){ sender.Fill = "Red"; } function mouseOut( sender, args ){ sender.Fill = "Blue"; }
などとすれば,マウスイベントで色を変えたりできる.