WPF学习笔记11. Binding (4)
2010-10-11 16:33:44 来源:本站整理Window1.xaml.cs
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
protected void ButtonClick(object sender, RoutedEventArgs e)
{
var personals = this.FindResource("personals") as PersonalList;
var view = CollectionViewSource.GetDefaultView(personals);
if (sender == btnFirst)
view.MoveCurrentToFirst();
else if (sender == btnPrev && view.CurrentPosition > 0)
view.MoveCurrentToPrevious();
else if (sender == btnNext && view.CurrentPosition < personals.Count - 1)
view.MoveCurrentToNext();
else if (sender == btnLast)
view.MoveCurrentToLast();
else if (sender == btnPostion)
view.MoveCurrentToPosition(Convert.ToInt32(btnPostion.Tag));
}
}
这很有趣,或许你也注意到了 Label 的 Binding 语法。
<Label Content="{Binding /}" /> 表示绑定到当前选择项。
<Label Content="{Binding /Name}" /> 表示绑定到当前选择项的 Name 属性。
更多精彩
赞助商链接