我有一个包含多个绑定文本块的列表框。有没有办法可以将选定的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/
答案 0 :(得分:0)
你可以试试这个:
var yourClassName = ListBox1.SelectedItem as YourClassType;
NavigationService.Navigate(new Uri(String.Format("/TargetPage.xaml?param={0}", yourClassName.LineOne), UriKind.Relative));
通过这种方式,我们可以将LineOne转换为您的目标页面。