1、后台属性绑定:

Grid g = new Grid() { Width = 60, Height = 100 };
g.SetValue(Panel.ZIndexProperty, 10);
//Canvas.SetBottom 绑定数据MLength
Binding bind = new Binding("MLength") { Source = this,Mode= BindingMode.TwoWay};
g.SetBinding(Canvas.BottomProperty,bind);

注:MLength为依赖性属性

 2、xaml绑定时间(格式)

Text="{Binding JionTime,StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}

注:JionTime为DataTime类型

posted on 2017-03-24 15:15  xs~ing  阅读(200)  评论(0编辑  收藏  举报