通过索引WP RT获取ListViewItem文本

时间:2015-05-22 19:11:39

标签: c# listview windows-phone-8.1 runtime

如何通过此商品索引获取 txt = historico.Items[i].ToString(); 文字?我试过这个

"Windows.UI.Xaml.Controls.ListViewItem" 

但我得到了这个

{{1}}

3 个答案:

答案 0 :(得分:1)

txt = (historico.Items[i] as ListViewItem).Content.ToString();

txt = (historico.Items[i] as ListViewItem).Text;

答案 1 :(得分:1)

在MainPage.xaml中:

<p class="flow-text">
    {{{questionText}}}
</p>

在MainPage.xaml.cs中,我添加了按钮的click事件:

<Page
x:Class="PushNotification_Sampl.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PushNotification_Sampl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
    <ListView Name="list">
        <ListViewItem>1</ListViewItem>
        <ListViewItem>2</ListViewItem>
        <ListViewItem>3</ListViewItem>
        <ListViewItem>4</ListViewItem>
        <Button x:Name="getBtn" Click="getBtn_Click">Get</Button>
        <TextBlock x:Name="text" Width="137" Text="check"></TextBlock>
    </ListView>



</Grid>

这在Windows Phone 8.1应用程序中运行良好。成功测试过。希望这会有所帮助。

答案 2 :(得分:0)

String strval = "in=app type=au act='Aut' check='abc|def|status||1234|4567|9080|x.x|ewer|www.yy.com|error'";

String pattern = "(check='\\w+[|]\\w+[|])\\w+"; 
//                ^------ group 1 ------^  ^^-current value of `status`

String result = strval.replaceAll(pattern, "$1"+"success");
//                                          ^^-match from group 1