We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Click event on DataSource table row

Thread ID:

Created:

Updated:

Platform:

Replies:

132769 Sep 20,2017 04:05 AM UTC Sep 25,2017 05:51 AM UTC Xamarin.Android 5
loading
Tags: DataSource
Nicolas
Asked On September 20, 2017 04:05 AM UTC

Hi,

I want to expand full screen an image on a clicked row of a DataSource and be able to close it, returning to the list.

I have checked and I haven't found any ItemClicked event (or the equivalent)

I am pretty new to Xamarin.Android, need some help here!

Thank you in advance

Nicolas 

Dinesh Babu Yadav [Syncfusion]
Replied On September 21, 2017 05:19 PM UTC

Hi Nicolas, 

Thank you for using Syncfusion Products. 

DataSource is not an UI component. It is a class library which is used for data operations such as sorting, filtering and grouping. So, you can check the event on the UI component (Example: ListView) which you used to display the data. 

Regards, 
Dinesh Babu Yadav 
 


Nicolas
Replied On September 22, 2017 05:28 AM UTC

Hi, I am playing around with your Xamarin Android sample, trying to figure out the logic of it all.

Yes, already got that about the UI for the ListView UI, I am now able to generate a click event on the ListView as follows:

DataSourceGettingStarted.cs

public override Android.Views.View GetSampleContent(Android.Content.Context context)

{ ... listView.ItemClick += ListView_ItemClick; ... }


private void ListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)

{

int idx = e.Position; //selected item index

Bitmap img = mContacts[idx].FlagImage; //image stored

imgView.SetImageBitmap(img);

GlobalVar.GImgView = imgView;

???

}

For the remainder, I figure that I should start a new activity which is using a new ImageViewer.axml (using a ImageView UI full screen) for the Image Viewer, and recall that Global variable to place that picture in the ImageView UI. Am I getting it right? Any input would be more than appreciated, any simpler way to do it?

Take care,

Nicolas


N.B. While we are on the datasource page, how can we can we extract data from a datasource, I can perform a first level to get the row, but not field in it : for example Bitmap img = mDataSource.Items[idx].("FlagImage")








Dinesh Babu Yadav [Syncfusion]
Replied On September 22, 2017 04:14 PM UTC

Hi Nicolas, 
 
As stated in previous update, DataSource is a non UI component which doesn’t related to any user interactions. And your requirement “Getting the particular property value of clicked item” can be achieved by using the approach you tried and which is the correct and easiest approach. 
 
Still if you want to get the value from DataSource, then you have to get it by using Reflection (Which is pretty complex) like below. This is not a recommended approach. 
 
var item = mDataSource.Items[idx] 
var value = item.GetType().GetProperty("FlagImage").GetValue(item); 
 
Please let us know if you require further assistance. 
 
Regards, 
Dinesh Babu Yadav 
 


Nicolas
Replied On September 22, 2017 04:30 PM UTC

ok, yes pretty same approach as VB .Net in syncfusion win forms apps, I remember this GetValue, it's pretty direct, I used it quite a lot, I should have remembered :). My side, I have found other way which works too, much less efficient to my taste:

private void ListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)

{

int idx = e.Position;

ObservableCollection<FlagDetails> fld = GlobalVar.GflagInfo;

Bitmap img = fld[idx].FlagImage;

string str = fld[idx].FlagName;

GlobalVar.GImg = img;

GlobalVar.GTitle = str;

MainActivity.context.StartActivity(typeof(ImageViewerActivity));

}


Thanks for the good help!

Nicolas



Muthu Kumaran Gnanavinayagam [Syncfusion]
Replied On September 25, 2017 05:51 AM UTC

Hi Nicolas, 
 
Thanks for your valuable response. 
 
Regards, 
G.Muthu Kumaran. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;