WEB开发网
开发学院WEB开发ASP.NET WPF学习笔记11. Binding (4) 阅读

WPF学习笔记11. Binding (4)

 2010-10-11 16:33:44 来源:本站整理   
核心提示:Window1.xaml.cspublicpartialclassWindow1:Window{publicWindow1(){InitializeComponent();}protectedvoidButtonClick(objectsender,RoutedEventArgse){varpersonals=this

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 属性。

上一页  1 2 3 4 5 

Tags:WPF 学习 笔记

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接