2016-05-11 5 views
2

私はSwitchCellでTableViewを持っています。私はそれにOnChangedイベントを追加したいと思います。どのように私はそれを達成するだろうか?以下可能であれば、私のコード:SwitchCellのOnChange

TableView tvProfile = new TableView 
     { 
      HasUnevenRows = true, 
      Intent = TableIntent.Form, 
      Root = new TableRoot { 
       new TableSection ("Active") 
       { 
        (new SwitchCell {Text = "Pause Timer" }) 
       } 
      } 
     }; 

答えて

3

あなたがそれを作成するときにスイッチクラスへの参照を保持し、ハンドラを割り当てるためにそれを使用する必要があります。

SwitchCell switch; 

TableView tvProfile = new TableView 
     { 
      HasUnevenRows = true, 
      Intent = TableIntent.Form, 
      Root = new TableRoot { 
       new TableSection ("Active") 
       { 
        (switch = new SwitchCell {Text = "Pause Timer" }) 
       } 
      } 
     }; 

switch.OnChanged += (s,e) => { 
    // handler logic goes here 
};