Retrieve Listview entry updates from contentview - xamarin

54 Views Asked by At

I have a listview which I have binde to a set of activities, including a timespan which I have divided the Days, Hours, Minutes Seconds into separate entry fields to be updated in my content view.

When I click save and iteracte through the listview in my code behind, it doesn't retrieve teh updated values, only the original values. If I try to edit a string this methods works fine but I need help to create a custom class or bind a timespan field? Could anyoneone show me how this is done?

Listview in contentview:

<ListView
                     x:Name="ActivitiesSettingsList"
                     SelectionMode="None"
                     CachingStrategy="RetainElement"
                     HasUnevenRows="True"                     
                     BackgroundColor="White"                    
                     IsPullToRefreshEnabled="False"
                     ItemsSource="{Binding UserActivitiesList }"
                     RefreshCommand="{Binding getUserActivities}"
                     IsRefreshing="{Binding IsBusy, Mode=OneWay}"                    
                     SeparatorVisibility="None"
                     RowHeight="70"                      
                    >
                    <ListView.ItemTemplate>
                        <DataTemplate >
                            <ViewCell
                                Height="60" 
                             >                                 
                                <StackLayout>
                                    <Grid BackgroundColor="White" x:Name="activitiesGrid"
                                          HeightRequest="60" WidthRequest="600" Margin="20,0,20,0" >

                                        <Grid.RowDefinitions>                                                                                
                                            <RowDefinition Height="28"/>
                                            <RowDefinition Height="28"/>
                                            <RowDefinition Height="1" />
                                        </Grid.RowDefinitions>

                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="30*"/>
                                            <ColumnDefinition Width="15*"/>
                                            <ColumnDefinition Width="15*"/>
                                            <ColumnDefinition Width="15*"/> 
                                            <ColumnDefinition Width="15*"/>
                                        </Grid.ColumnDefinitions>

                                       <Label
                                            Grid.Row="0"                                                          
                                            Grid.Column="0"
                                            VerticalOptions="Start"
                                            FontAttributes="None"                                       
                                            Text="{Binding  .ActivityName}"
                                            Margin="0,0,0,0"
                                            TextColor="Black"                                            
                                            Padding="0,10,0,0"
                                            FontFamily="Hiragino Sans"
                                            FontSize="14"
                                            HeightRequest="53"
                                            BackgroundColor="White"
                                       />                                        
                                        <Entry
                                            Grid.Row="0"                                                          
                                            Grid.Column="1"
                                            VerticalOptions="Center"
                                            FontAttributes="None"                                       
                                            Text="{Binding ActivityGoalDuration.Days}"
                                            TextColor="Black"
                                            Margin="0, 0,0, 0"                                           
                                            FontFamily="Hiragino Sans"
                                            FontSize="14"
                                            HeightRequest="53"
                                            BackgroundColor="White"
                                       />
                                       <Entry
                                            Grid.Row="0"                                                          
                                            Grid.Column="2"
                                            VerticalOptions="Center"
                                            FontAttributes="None"                                       
                                            Text="{Binding ActivityGoalDuration.Hours}"
                                            TextColor="Black"
                                            Margin="0, 0,0, 0"                                           
                                            FontFamily="Hiragino Sans"
                                            FontSize="14"
                                            HeightRequest="53"
                                            BackgroundColor="White"
                                            x:Name="actDays"
                                       />
                                        <Entry
                                            Grid.Row="0"                                                          
                                            Grid.Column="3"
                                            VerticalOptions="Center"
                                            FontAttributes="None"                                       
                                            Text="{Binding ActivityGoalDuration.Minutes}"
                                            TextColor="Black"
                                            Margin="0, 0,0, 0"                                           
                                            FontFamily="Hiragino Sans"
                                            FontSize="14"
                                            HeightRequest="53"
                                            BackgroundColor="White"
                                       />
                                       <Entry
                                            Grid.Row="0"                                                          
                                            Grid.Column="4"
                                            VerticalOptions="Center"
                                            FontAttributes="None"                                       
                                            Text="{Binding ActivityGoalDuration.Seconds}"
                                            TextColor="Black"
                                            Margin="0, 0,0, 0"                                           
                                            FontFamily="Hiragino Sans"
                                            FontSize="14"
                                            HeightRequest="53"
                                            BackgroundColor="White"
                                       />
                                    </Grid>                                    
                                </StackLayout>

                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>

Code behind:


List<UserActivities.Activities> list = new List<UserActivities.Activities>();

//list = (List<UserActivities.Activities>) ActivitiesSettingsList.ItemsSource.Cast<UserActivities.Activities>();

            foreach (UserActivities.Activities activityCollection in ActivitiesSettingsList.ItemsSource.Cast<UserActivities.Activities>())
            {
                var x = activityCollection.ActivityGoalDuration;
                
            }

0

There are 0 best solutions below