lightswitch binding custom control

Listing 1: Setting up data binding for the Rating control

usingSystem.Windows.Controls;
usingSystem.Windows.Data;
usingMicrosoft.LightSwitch.Threading;
namespace LightSwitchApplication
{
    public partial class ShippersListDetail{
      partial void ShippersListDetail_Created() {
          var proxy =this.FindControl("ShipperRating");     proxy.ControlAvailable+=OnControlAvailable;
      }
      private void OnControlAvailable(object sender,ControlAvailableEventArgs e){
        Dispatchers.Main.BeginInvoke(()=>{
          Rating rc = e.ControlasRating; rc.ItemCount=5; rc.SelectionMode=RatingSelectionMode.Continuous;var b =newBinding("Value"); b.Mode=BindingMode.TwoWay; rc.SetBinding(Rating.ValueProperty, b);
        });
      }
    }
}

  

posted @ 2014-04-28 10:49  阿新  阅读(422)  评论(0编辑  收藏  举报