2017-09-28 53 views
0

今天我下載了syncfusion工具,並設法使用滑動屬性的數據網格,現在我想知道當我向左或向右滑動時如何執行一個函數,有人可以給我一個例子嗎?如何在向右或向左滑動時執行功能? Xamarin Android Syncfusion

這是我的代碼

protected override void OnCreate(Bundle savedInstanceState) 
     { 

      base.OnCreate(savedInstanceState); 
      SetContentView(Resource.Layout.CompartirVale); 

      btnDel = FindViewById<Button>(Resource.Id.btnDelShared); 
      btnAl = FindViewById<Button>(Resource.Id.btnAlShared); 
      btnBuscarRelacionPago = FindViewById<Button>(Resource.Id.btnBuscarValeShared); 
      // 
      RelativeLayout layout = (RelativeLayout)FindViewById(Resource.Id.RelativeCompartirVale); 
      imgPDF = FindViewById<ImageView>(Resource.Id.imgPDFShared); 
      imgwhats = FindViewById<ImageView>(Resource.Id.imgWhatsApp); 
      dataGrid = new SfDataGrid(BaseContext); 
      layout.AddView(dataGrid); 
      this.dataGrid.AllowSwiping = true; 

      OrderInfoRepository viewModel = new OrderInfoRepository(); 
      dataGrid.ItemsSource = viewModel.OrderInfoCollection; 
      ActionBar.SetDisplayHomeAsUpEnabled(true); 
      // 
      SwipeView leftSwipeView = new SwipeView(BaseContext); 
      SwipeView rightSwipeView = new SwipeView(BaseContext); 
      LinearLayout editView = new LinearLayout(BaseContext); 
      LinearLayout deleteView = new LinearLayout(BaseContext); 

      ImageView editImage = new ImageView(BaseContext); 
      editImage.SetImageResource(Resource.Drawable.whatsapp); 
      editImage.SetBackgroundColor(Color.ParseColor("#FFFFFF")); 

      ImageView deleteImage = new ImageView(BaseContext); 
      deleteImage.SetImageResource(Resource.Drawable.gmail); 
      deleteImage.SetBackgroundColor(Color.ParseColor("#FFFFFF")); 

      editView.AddView(editImage, ViewGroup.LayoutParams.MatchParent, (int)dataGrid.RowHeight); 
      //editView.AddView(edit, ViewGroup.LayoutParams.MatchParent, (int)dataGrid.RowHeight); 

      deleteView.AddView(deleteImage, ViewGroup.LayoutParams.MatchParent, (int)dataGrid.RowHeight); 
      //deleteView.AddView(delete, ViewGroup.LayoutParams.MatchParent, (int)dataGrid.RowHeight); 

      leftSwipeView.AddView(editView, dataGrid.MaxSwipeOffset, (int)dataGrid.RowHeight); 
      rightSwipeView.AddView(deleteView, dataGrid.MaxSwipeOffset, (int)dataGrid.RowHeight); 

      dataGrid.LeftSwipeView = leftSwipeView; 
      dataGrid.RightSwipeView = rightSwipeView; 
      // 
     } 

當我行滑動到右側或左側執行什麼事件?

回答

0

在SfDataGrid中,滑動時會引發三個事件。如果您開始滑動過程,則會引發SwipeStarted事件。如果滑動正在進行,則滑動事件將會上升。如果滑動操作結束,則會引發SwipeEnded事件。請參考下面的代碼片段,

dataGrid.SwipeStarted += DataGrid_SwipeStarted; 
dataGrid.Swiping += DataGrid_Swiping; 
dataGrid.SwipeEnded += DataGrid_SwipeEnded; 

//Swipe ended event will fire once you the swiping process is ended 
private void DataGrid_SwipeEnded(object sender, SwipeEndedEventArgs e) 
{ 

} 
//Swiping event will fire when the swiping process is in progress 
private void DataGrid_Swiping(object sender, SwipingEventArgs e) 
{ 

}  
//Swipe started event will fire once you started the swiping process 
private void DataGrid_SwipeStarted(object sender, SwipeStartedEventArgs e) 
{ 

} 

請參考下面的UG鏈接瞭解更多關於SfDataGrid刷卡功能及其活動, UG鏈接:https://help.syncfusion.com/xamarin-android/sfdatagrid/swiping

此外,我們還準備使用刷卡功能的樣本您可以從下面的鏈接中下載相同的代碼 樣品鏈接:http://www.syncfusion.com/downloads/support/forum/132930/ze/Sample1951506069

Regards, Divakar。