Aiseduk
Aiseduk

Reputation: 108

How to copy a selected text block to another hub page in Windows phone app

I am using list view to display a list of items in a group. Here is how my list view looks like:

 <ListView
            x:Name="itemListView"
            AutomationProperties.AutomationId="ItemListView"
            AutomationProperties.Name="Items In Group"
            TabIndex="1"
            Grid.Row="1"
            ItemsSource="{Binding Items}"
            IsItemClickEnabled="True"
            ItemClick="ItemView_ItemClick"
            SelectionMode="None"
            IsSwipeEnabled="false"
            Margin="19,0,0,0">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <Border Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" Margin="0,-9.5,0,0" Width="79" Height="79">
                            <Image Source="{Binding ImagePath}" Stretch="UniformToFill"  AutomationProperties.Name="{Binding Title}" VerticalAlignment="Top"/>
                        </Border>
                        <StackPanel Grid.Column="1" VerticalAlignment="Top" Margin="14.5,0,0,0">
                            <TextBlock Text="{Binding Title}" Style="{ThemeResource ListViewItemTextBlockStyle}"/>
                            <TextBlock Text="{Binding Description}" Style="{ThemeResource ListViewItemContentTextBlockStyle}" Foreground="{ThemeResource PhoneMidBrush}" TextWrapping="WrapWholeWords"/>



                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

I would like to add a logic that when a text block is selected, it should copy the entire text block to another hub page (favorite) and create a reference back to the source text block. Whenever the user clicks any text block, it should be copied to the existing list of favorite blocks on Favorite hub page. Also, the user should be able to select the block on the favorite and remove it from the favorite list.

Currently, my "ItemView_ItemClick event looks like below which get the Id of the selecte item in the list, but I don't know how to proceed to implement above logic.

private void ItemView_ItemClick(object sender, ItemClickEventArgs e)
        {


            var itemId = ((SampleDataItem)e.ClickedItem).UniqueId;

            if (!Frame.Navigate(typeof(ItemPage), itemId))
            {
                var resourceLoader = ResourceLoader.GetForCurrentView("Resources");
                throw new Exception(resourceLoader.GetString("NavigationFailedException`enter code here`Message"));
            }

Upvotes: 0

Views: 51

Answers (1)

Sunil Kumar S C
Sunil Kumar S C

Reputation: 304

You can use IsolatedStorageSettings for local storage.

Upvotes: 0

Related Questions