簡體   English   中英

將列表框的綁定文本塊提取到字符串wp7

[英]Extract Listbox's binded textblock to string wp7

我有一個帶有多個綁定文本塊的列表框。 有沒有一種方法可以將文本框數據從選定的listboxitem作為字符串綁定到另一個頁面?

<ListBox Margin="0,10,-12,0" ItemsSource="{Binding Items}" Width="408" x:Name="ListBox1">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" Margin="0,0,0,17" Tap="StackPanel_Tap">
                            <!--Replace rectangle with image-->
                            <Rectangle Height="100" Width="100" Margin="12,0,9,0">
                                <Rectangle.Fill>
                                    <ImageBrush ImageSource="{Binding LineImg}" x:Name="img"/>
                                </Rectangle.Fill>
                            </Rectangle>
                            <StackPanel Width="311">
                                <TextBlock x:Name="title" Text="{Binding LineOne}" TextWrapping="Wrap" FontSize="30"/>
                                <Line X1="0" Y1="0" X2="1" Y2="0" Stretch="Fill" Stroke="White" />
                                <TextBlock x:Name="time" Text="{Binding LineTwo}" Margin="0,0,12,10" Style="{StaticResource PhoneTextSubtleStyle}"/>
                                <Image Height="20" Width="20" Margin="-170,-45,0,0" Source="/PostDateIcon.png"/>
                                <TextBlock x:Name="date" Text="{Binding LineThree}" Margin="85,-37,12,10" Style="{StaticResource PhoneTextSubtleStyle}"/>
                                <TextBlock x:Name="content" Text="{Binding LineContent}" Visibility="Collapsed"/>
                            </StackPanel>                            </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

我使用此方法來加載綁定數據: http : //kevinashley.com/connect-windows-phone-7-apps-to-wordpress-using-json/

您可以嘗試以下方法:

var yourClassName = ListBox1.SelectedItem as YourClassType;
NavigationService.Navigate(new Uri(String.Format("/TargetPage.xaml?param={0}", yourClassName.LineOne),  UriKind.Relative));

通過這種方式,我們可以將LineOne過渡到您的目標頁面。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM