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
close icon

Changing the text color of a label on an itemtemplate in sflistview

I have a SfListView with an ItemTemplate which has 3 labels in it, I want to be able to change teh second labels color using a IValueVonverter, I can get the converter called no problem however the text value of the label is always null, the label is bound to a datasource column.



            <local:ColorConverter x:Key="ColorConverter"/>



    <Grid RowDefinitions="*">

        <syncfusion:SfListView x:Name="listView" BackgroundColor="DarkGrey" ItemsSource="{Binding TheCameraHealth}" ItemSize="300" EmptyView="Loading......" AutoFitMode="Height">



                    <Border StrokeThickness="4" HorizontalOptions="Center" StrokeShape="RoundRectangle 20,0,0,20" Stroke="Gray" BackgroundColor="LightGray" >

                        <Grid RowDefinitions="*,*,*" RowSpacing="5">

                            <Label Margin="20,0,0,0" Grid.Row="0" Grid.Column="0" Text="{Binding CameraName}" TextColor="Black" FontAttributes="Bold" FontSize="16"/>

                            <Label x:Name="status" Margin="25,0,0,0" Grid.Row="1" Grid.Column="0" Text="{Binding TheCameraStatus}" FontAttributes="Bold" TextColor="{Binding TheCameraStatus, Converter={StaticResource Key=ColorConverter},ConverterParameter={x:Reference Name=status}}"/>

                            <Label Margin="24,0,0,0" Grid.Row="2" Grid.Column="0" Text="{Binding TheCameraReads}" TextColor="Black" />






                <syncfusion:GridLayout x:Name="gridLayout" SpanCount="4" />




1 Reply

DV Diwakar Venkatesan Syncfusion Team April 3, 2023 12:47 PM UTC

Hi Terence,

We could understand the reported scenario and experienced the same case in a simple demo with framework Label alone. It seems, converter is triggered prior to the text being bound to the Label. As this is framework behavior, we are unable to address it on our end.


    <Label x:Name="status"




           Text="{Binding Comments}"


           TextColor="{Binding Comments, Converter={StaticResource Key=ColorConverter}, ConverterParameter={x:Reference Name=status}, Mode=TwoWay}" />





Live Chat Icon For mobile
Up arrow icon