locked
How to Save Listbox item in Windows Phone 8

    Question

  • I have a two listbox one listbox i am showing data from my JSON we servive and another listbox i am showing selected item from frist listbox it is working fine but the problem is that when i come back from my application and reopen app i want to show second list box with selected item i am using following code:

         <Grid x:Name="ContentPanel" Grid.Row="2" Margin="15,10,15,0">
                    <ListBox Name="list_location" Tap="list_location_Tap" Foreground="Black">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock x:Name="item_name" Text="{Binding description, Mode=OneWay}" Padding="5,15,5,15" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeLarge}"/>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                       
                    </ListBox>

                    <ListBox Name="list_locationAdd"  Foreground="Black" Visibility="Collapsed">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock x:Name="item_name" Text="{Binding description, Mode=OneWay}" Padding="5,15,5,15" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeLarge}"/>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

                </Grid>
    and my .cs code is as follow:
    list_locationAdd.Visibility = Visibility.Visible;
                    list_location.Visibility = Visibility.Collapsed;


                    if (!list_locationAdd.Items.Contains(list_location.SelectedItem))
                    {
                        list_locationAdd.Items.Add(list_location.SelectedItem);

                    }

    thanks:
    Friday, April 24, 2015 11:00 AM

Answers