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

How to set the selected item font color?

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

5 Replies

SR Sangeetha Raju Syncfusion Team September 6, 2019 06:14 AM

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. 



WA Will Autio September 6, 2019 11:50 AM

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.'


SR Sangeetha Raju Syncfusion Team September 8, 2019 10:27 PM

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. 



WA Will Autio September 9, 2019 02:06 PM

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


SR Sangeetha Raju Syncfusion Team September 9, 2019 10:28 PM

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


Loader.
Live Chat Icon For mobile
Up arrow icon