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);
});
}
}
}