Refresh SfListView in Execution

Good Morning:

I have the following code to display a list of a objects in my listview.

Main:
    <syncfusion:SfListView  
                           ItemsSource="{Binding ListaEquipos}"
                           SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                           Grid.Row="1" Grid.Column="0"
                           BackgroundColor="{StaticResource Paneles}"
                           Orientation="Horizontal"
                           IsScrollBarVisible="false"
                           AutoFitMode="Height">
                    <syncfusion:SfListView.ItemTemplate >
                        <DataTemplate >
                            <templates:VistaEquiposTemplate/>
                        </DataTemplate>
                    </syncfusion:SfListView.ItemTemplate>
                </syncfusion:SfListView> 
 

Template:

<ContentView
    xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    x:Class="DISAR_XAMARIN.View.Templates.VistaEquiposTemplate"
    xmlns:extensions="clr-namespace:DISAR_XAMARIN.Models">
    <ContentView.Content >
            <Grid HorizontalOptions="CenterAndExpand" VerticalOptions="StartAndExpand">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Label Grid.Row="0" 
                    Grid.Column="1" 
                    Text="{Binding Ubicacion}" 
                    Style="{StaticResource Corriente}"
                    TextColor="Black"/>
                <Image Grid.RowSpan="5" 
                    Grid.Row="1" 
                    Grid.Column="1" 
                    Source="{Binding Imagen}" 
                    Aspect="AspectFill"
                    WidthRequest="125" 
                    HeightRequest="125"/>
                <Label Grid.Row="3" 
                    Grid.Column="3" 
                    IsVisible="{Binding NumEntradasVisible}"
                    Text="{Binding NumEntradas}" 
                    FontSize="15"/>
                <Label Grid.Row="5" 
                    Grid.Column="3" 
                    Text="{Binding NumSalidas}" 
                    IsVisible="{Binding NumSalidasVisible}"
                    FontSize="15"/>
                <Label Grid.Row="2" 
                    Grid.Column="2" 
                    Text= "{Binding Entrada}" 
                    IsVisible="{Binding EntradaVisible}"
                    TextColor="{Binding ColorEntrada}"
                    FontSize="15"/>
                <Label Grid.Row="2" 
                    Grid.Column="3" 
                    Text="{Binding EstadoEntrada}" 
                    TextColor="{Binding ColorEntrada}"
                    IsVisible="{Binding EstadoEntradaVisible}"
                    FontSize="15"/>
                <Label Grid.Row="4"
                    Grid.Column="2" 
                    Text="{Binding Salida}" 
                    IsVisible="{Binding salidaVisible}"
                    TextColor="{Binding ColorSalida}"
                    FontSize="15"/>
                <Label Grid.Row="4" 
                    Grid.Column="3" 
                    Text="{Binding EstadoSalida}" 
                    TextColor="{Binding ColorSalida}"
                    IsVisible="{Binding EstadoSalidaVisible}"
                    FontSize="15"/>
                <Label Grid.Row="6" 
                    Grid.Column="1" 
                    Text="{Binding EstadoEquipo}" 
                    FontSize="15"  
                    HorizontalOptions="Center"/>
            </Grid>
    </ContentView.Content>
</ContentView>

This listview is refreshing every x time to see if the objects are connected to a server, if some equipment is connected changes the image of the computer and some new data that do not appear when it is disconnected.

The problem is good because the app that recognizes that the computer changed status does not refresh the list and I do not appear as connected, but I continue to show is as when I enter the programfor the first time. I would like to know why I do not refresh it, since if I use a normal listview of xamarin the code works perfectly, what happens that I like more your design and the option to be able to change the view forms horizontal to vertical.
Thank you so much.

Maria Chillon
 

4 Replies

EM Emil October 21, 2017 12:22 AM UTC

Hi Maria, 

you must implement INotifyProperty changed for your model and raise property changed for the property you want to refresh. I want to refresh display order my testmodel. If I want to refresh Displayorder it should look like as below

Cheers,

I hope this helps


for example;

 public class TestModel :  INotifyPropertyChanged

    {

        private int displayOrder;

        public int DisplayOrder

        {

            get { return displayOrder; }

            set

            {

                if (displayOrder != value)

                {

                    displayOrder = value;

                    OnPropertyChanged("DisplayOrder");

                }

            }

        }




MK Muthu Kumaran Gnanavinayagam Syncfusion Team October 23, 2017 07:30 AM UTC

Hi, 
 
Thank you for your valuable solution Emil. 
 
As emil stated, you need to implement INotifyCollectionChanged interface in your model class and raise the PropertyChanged method for the property which helps the SfListView control to refresh the view whenever that particular property changes. We have already included in our documentation for the same. Please find the documentation link below. 
 
 
Please let us know if you require further assistance. 
 
Regards, 
G.Muthu Kumaran. 



MA Maria October 23, 2017 09:37 AM UTC

Hello:

Thank you very much for  your time has served me and corrected the problem.



MK Muthu Kumaran Gnanavinayagam Syncfusion Team October 24, 2017 04:01 AM UTC

Hi Maria, 
 
Thanks for the update. Please let us know if you require further assistance. 
 
Regards, 
G.Muthu Kumaran. 


Loader.
Up arrow icon