【问题标题】:Extract Listbox's binded textblock to string wp7提取列表框绑定文本块到字符串 wp7
【发布时间】:2014-03-19 12:08:16
【问题描述】:

我有一个包含多个绑定文本块的列表框。有没有一种方法可以将所选列表框项中的文本块数据作为字符串绑定到其他页面?

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

【问题讨论】:

    标签: c# wpf xaml binding listbox


    【解决方案1】:

    你可以试试这个:

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

    通过这种方式,我们可以将 LineOne 过渡到您的目标页面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-20
      • 1970-01-01
      • 1970-01-01
      • 2012-03-12
      • 2011-07-15
      相关资源
      最近更新 更多