如何在文本块中获取所选项目存储

时间:2015-06-21 13:42:44

标签: c# windows-phone-8.1

这是我用过的xaml代码。

   <ListView  x:Name="lvLocations" Grid.Row="1" 
             HorizontalAlignment="Left" 
            IsItemClickEnabled="True"
            SelectionMode="Single"

               SelectionChanged="lvLocations_SelectionChanged"
            IsSwipeEnabled="false"
             Margin="19,12,19,0"
             >

        <ListView.ItemTemplate>

            <DataTemplate>
                <TextBlock Text="{Binding}" 
                                FontSize="22"
                                TextWrapping="Wrap"
                                Margin="0,12,0,0" 
                                />

            </DataTemplate>

        </ListView.ItemTemplate>

    </ListView>

这是

背后的c#代码
      List<string> locations = new List<string>();

        // If the query returns results then bind it to the list view.
        if (result.Status == MapLocationFinderStatus.Success)
        {
            foreach (MapLocation mapLocation in result.Locations)
            {
                // create a display string of the map location
                string display = mapLocation.Address.StreetNumber + " " +
                    mapLocation.Address.Street + Environment.NewLine +
                    mapLocation.Address.Town + ", " +
                    mapLocation.Address.RegionCode + "  " +
                    mapLocation.Address.PostCode + Environment.NewLine +
                    mapLocation.Address.CountryCode;

                // add the display string to the location list
                locations.Add(display);
            }

            // bind the location list to the ListView control
            lvLocations.ItemsSource = locations;

        }

此代码将在textblocks中显示字符串,我希望当用户点击其中一个选项时,它会在textblock中存储或者绑定到其他文本块中 请建议我如何做到这一点

提前谢谢

0 个答案:

没有答案