如何从主页获取列表框项目的值,而选定的项目显示详细信息页面? [英] how can i get listbox item value from main page and selected items show details page ?
问题描述
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string parameter = this.NavigationContext.QueryString["parameter"];
if (NavigationContext.QueryString.TryGetValue("parameter", out parameter))
{
MessageBox.Show("Welcome To TestPage");
}
}
您好,我使用的是下面提供的xaml文件.我具有水平滚动列表.如果单击任何列表项,则应转到另一页并显示所选项目的详细信息.
Hi am using xaml file given below.i have horizontal scrolling list.if i clicked any list item it should go to another page and show selected item detail.
<StackPanel VerticalAlignment="Top" Width="Auto">
<ListBox ItemsSource="{Binding Images}" Width="Auto" ScrollViewer.VerticalScrollBarVisibility="Disabled" SelectionChanged="NotchsList11_SelectionChanged">
<ListBox.ItemsPanel> <ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Top">
</StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="White" BorderThickness="1,1,1,1" Margin="0,0,8,0">
<Image Source="{Binding}" Width="152" Height="90" Stretch="Fill" VerticalAlignment="Top"></Image>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
下面给出了我的mainpage.xaml.cs代码
My mainpage.xaml.cs code given below
private void NotchsList11_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
NavigationService.Navigate(new Uri("/Test.xaml?parameter={0}",UriKind.Relative));
//NavigationService.Navigate(new Uri("/Page1.xaml?parameter=test", UriKind.Relative));
}
catch(Exception)
{
MessageBox.Show("hi");
}
}
Page2.xaml.cs
Page2.xaml.cs
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string parameter = this.NavigationContext.QueryString["parameter"];
if (NavigationContext.QueryString.TryGetValue("parameter", out parameter))
{
}
}
我怎么写才能从主页上获取选定的值.我的输出如下.
how can i write to get selected value from main page.My output given below.
我想要类似的输出.
请帮助我获得此输出.
推荐答案
以下链接演示了在页面之间传递数据的几种方法:
The following link demonstrates several ways to pass data between pages:
http://nishantcop.blogspot.com/2011/08 /passing-data-between-pages-in-windows.html
希望这会有所帮助,
标记
Hope this helps,
Mark
这篇关于如何从主页获取列表框项目的值,而选定的项目显示详细信息页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!