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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set the selected item font color?

Thread ID:

Created:

Updated:

Platform:

Replies:

147314 Sep 5,2019 04:40 PM UTC Sep 10,2019 06:28 AM UTC Xamarin.Forms 5
loading
Tags: SfListView
Will Autio
Asked On September 5, 2019 04:40 PM UTC

Hi,
When I set up a SfListView I can also set the SelectionBackgroundColor. How can I change the SelectionFont Color?
Thanks!
Will

Sangeetha Raju [Syncfusion]
Replied On September 6, 2019 02:14 PM UTC

Hi Will, 
 
We would like to let you know that you can apply TextColor of the SelectedItem by using the SelectionChangedEvent as like following code snippet. 
 
private void ListView_SelectionChanged(object sender, Syncfusion.ListView.XForms.ItemSelectionChangedEventArgs e) 
{ 
   if (e.AddedItems.Count > 0) 
   { 
      var items = e.AddedItems[0]; 
      (items as Model).TextColor = Color.White; 
   } 
   if (e.RemovedItems.Count > 0) 
   { 
      var removedItem = e.RemovedItems[0]; 
      (removedItem as Model).TextColor = Color.Black; 
   } 
} 
 
We have attached the tested sample for your reference. Please find the sample from the below link. 
 
 
Please let us know if you require further assistance. 
 
Regards, 
Sangeetha Raju. 


Will Autio
Replied On September 6, 2019 07:50 PM UTC

Hi Sangeetha Raju,

Thanks for your reply and the sample program. The program works fine in UWP and iOS. Unfortunately, it crashes with a null reference exception in Android. Below is the last part of the Output.

Meanwhile I'll try to make it work in my code.
Regards,
Will

Loaded assembly: System.Threading.dll [External]
09-06 12:45:16.284 D/Mono    (23847): Loading reference 3 of /storage/emulated/0/Android/data/com.companyname.SfListViewSamples/files/.__override__/Syncfusion.GridCommon.Portable.dll asmctx DEFAULT, looking for System.Threading, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
09-06 12:45:16.287 D/Mono    (23847): Unloading image System.Threading.dll [0x95b68f00].
09-06 12:45:16.288 D/Mono    (23847): Image addref System.Threading[0x95f23620] (asmctx DEFAULT) -> System.Threading.dll[0x95b68a00]: 5
09-06 12:45:16.288 D/Mono    (23847): Config attempting to parse: 'System.Threading.dll.config'.
09-06 12:45:16.288 D/Mono    (23847): Config attempting to parse: '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-armeabi-v7a-release/etc/mono/assemblies/System.Threading/System.Threading.config'.
09-06 12:45:16.288 D/Mono    (23847): Assembly Ref addref Syncfusion.GridCommon.Portable[0x96861060] -> System.Threading[0x95f234a0]: 3
09-06 12:45:16.341 D/Mono    (23847): Loading reference 4 of /storage/emulated/0/Android/data/com.companyname.SfListViewSamples/files/.__override__/Syncfusion.GridCommon.Portable.dll asmctx DEFAULT, looking for System.Runtime.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
09-06 12:45:16.344 D/Mono    (23847): Unloading image System.Runtime.Extensions.dll [0x95b68f00].
09-06 12:45:16.345 D/Mono    (23847): Image addref System.Runtime.Extensions[0x95f23620] (asmctx DEFAULT) -> System.Runtime.Extensions.dll[0x966da500]: 5
09-06 12:45:16.345 D/Mono    (23847): Config attempting to parse: 'System.Runtime.Extensions.dll.config'.
09-06 12:45:16.345 D/Mono    (23847): Config attempting to parse: '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-armeabi-v7a-release/etc/mono/assemblies/System.Runtime.Extensions/System.Runtime.Extensions.config'.
09-06 12:45:16.345 D/Mono    (23847): Assembly Ref addref Syncfusion.GridCommon.Portable[0x96861060] -> System.Runtime.Extensions[0x96861ea0]: 3
**System.NullReferenceException:** 'Object reference not set to an instance of an object.'

Sangeetha Raju [Syncfusion]
Replied On September 9, 2019 06:27 AM UTC

Hi Will, 
 
We suspect you are facing this issue because of NuGet restore problem or cache. So, can you please check by deleting bin, obj files and clear the NuGet cache and check once again. 
 
Please let us know if you require further assistance. 
 
Regards, 
Sangeetha Raju. 


Will Autio
Replied On September 9, 2019 10:06 PM UTC

Hello Sangeetha Raju,
I did as you recommended - deleted the bin and obj files on the sample program. It still failed on Android. However, I took the concepts and applied them to my app and it works fine. I am OK with that.
Regards,
Will

Sangeetha Raju [Syncfusion]
Replied On September 10, 2019 06:28 AM UTC

Hi Will, 
 
Thanks for the update. Please let us know if you require any further assistance. 
 
Regards, 
Sangeetha Raju. 


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

This page will automatically be redirected to the 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

Live Chat Icon For mobile
Live Chat Icon