1

Hi am using xaml file given below.I want to get selected item value to details view.

<StackPanel Width="Auto">
<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" Margin="0,0,8,0" BorderThickness="1">
                            <Image Source="{Binding}" Width="152" Height="90"  Stretch="Fill"  VerticalAlignment="Top"></Image>
                          </Border>
                            </DataTemplate>
                                </ListBox.ItemTemplate>
                         </ListBox>
                      </StackPanel>
                     <StackPanel Orientation="Horizontal"  VerticalAlignment="Top"  ScrollViewer.VerticalScrollBarVisibility="Disabled" Width="Auto">
                    <ListBox ItemsSource="{Binding Titles}"   ScrollViewer.VerticalScrollBarVisibility="Disabled" SelectionChanged="NotchsList11_SelectionChanged">
                   <ListBox.ItemsPanel>
                         <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal">
                        </StackPanel>
                          </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                               <ListBox.ItemTemplate>
                                    <DataTemplate >
                                        <Border BorderBrush="White" Margin="0,0,8,0"
                                            BorderThickness="1"> 
                                       <TextBlock Text="{Binding}"  Width="152" Height="80" Padding="5,10,0,0"  TextWrapping="Wrap"></TextBlock>    
                                        </Border>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                    </StackPanel>
                    </StackPanel>

My Main.Cs Code

private void NotchsList11_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {

            NavigationService.Navigate(new Uri("/Test.xaml?parameter={0}",UriKind.Relative));
            //NavigationService.Navigate(new Uri("/Page1.xaml?parameter=test", UriKind.Relative));
        }

    }   

I used this thing i cant go to other page with selected item. i want output like given below image enter image description here

user123
  • 183
  • 2
  • 18

1 Answers1

1

The simple and efficient approach - have a ViewModel. When the item is selected (hook the SelectionChanged event handler), pass the instance to the ViewModel and navigate to the second page that will show the item details. Make sure that the page is bound to the ViewModel and simply read from the item you passed in.

Den
  • 16,686
  • 4
  • 47
  • 87
  • hi i am not using MVVM type.I passing values directly to another page. – user123 Mar 23 '13 at 04:14
  • It's one of your better options (very basic MVVM). Refer to this answer for more options: http://stackoverflow.com/a/4728343/303696 – Den Mar 23 '13 at 05:38