2014-02-19 54 views
0

我有一個帶有多個綁定文本塊的列表框。有沒有一種方法可以將選定列表框中的文本塊數據作爲字符串綁定到其他頁面?提取列表框的文本塊綁定到字符串wp7

<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/

回答

0

你可以試試這個:通過這種方式

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

,我們可以過渡LineOne到目標頁面。