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. Image for the cookie policy date

Click event on DataSource table row

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 

5 Replies

DB Dinesh Babu Yadav Syncfusion Team 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 
 



NI Nicolas 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")









DB Dinesh Babu Yadav Syncfusion Team 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 
 



NI Nicolas 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




MK Muthu Kumaran Gnanavinayagam Syncfusion Team September 25, 2017 05:51 AM UTC

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


Loader.
Up arrow icon