I have a GridView in which blocks are generated. The content of the block is taken in this way (in the code it is indicated by comments). Everything works fine. Now there is a problem with the fact that when I click on the block (the address is written in the block), then the element that is written for this address in the database should appear (become the result of the click). How can this be implemented? It was a bit strange, as it seems to me, an idea, but its implementation didn’t give off exactly all the elements.
public sealed partial class Details : Page { public ObservableCollection<ForPerson> list { get; set; } List<ForPerson> L1; public Details() { this.InitializeComponent(); } protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); var parametr = (ForPerson)e.Parameter; //получаем из другого файла через параметры переменные. var name_Person = parametr.namePerson; name.Text = name_Person; var tel_Person = parametr.telPerson; tel.Text = tel_Person; var adres_Person = parametr.adresPerson; adres.Text = adres_Person; var email_Person = parametr.emailPerson; email.Text = email_Person; //основной список,в который записаны адреса и элементы из базы, котрые им отвечают L1 = parametr.l1; Debug.WriteLine("______________" + "tut" + "________________" + name_Person + "____" + tel_Person + "_____" + adres_Person + "______" + email_Person); Metod(); } public void Metod() {// всякая всячина, чтобы вывести в GridView list = new ObservableCollection<ForPerson>(); foreach (ForPerson root in L1) { var T1 = root.adresD; var T2 = root.sostav; list.Add(new ForPerson { adresD = T1, sostav = T2 }); MyGrid.ItemsSource = list; //отрабатывает без проблем } Debug.WriteLine("+++++++++++++++" + list.ToFormattedJsonString()); Debug.WriteLine("_______++++++________" + "(" + L1.ToFormattedJsonString() + ")" + "________"); } private void MyGrid_SelectionChanged_1(object sender, SelectionChangedEventArgs e) {//cпособ, которым пробовала выводить элементы при нажатии на блок с адресом list = new ObservableCollection<ForPerson>(); foreach (ForPerson root2 in L1) { var T1 = root2.adresD; var T2 = root2.sostav; list.Add(new ForPerson { adresD = T1, sostav = T2 }); var res = from s in list where s.adresD == T1 select s.sostav; var res2 = res.ToFormattedJsonString(); list.Add(new ForPerson { sostav = res2 }); Debug.WriteLine("SMOTRET_____TUT_____" + res2); MyGrid2.ItemsSource = list; //но не вышло((( } } } Part of xaml:
<Grid HorizontalAlignment="Left" Height="392" VerticalAlignment="Top" Width="402" Margin="301,330,0,-2"> <ScrollViewer Height="387" VerticalAlignment="Top" HorizontalAlignment="Right"> <GridView x:Name="MyGrid" Width="404" Height="387" SelectionChanged="MyGrid_SelectionChanged_1" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" d:LayoutRounding="Auto"> <GridView.ItemTemplate> <DataTemplate> <StackPanel> <Grid Width="376" > <TextBlock Text="{Binding adresD}" Height="67" TextAlignment="Center" FontSize="28" FontFamily="SF UI Display" Padding="0,10,0,0"/> </Grid> </StackPanel> </DataTemplate> </GridView.ItemTemplate> </GridView> </ScrollViewer> </Grid> <Grid HorizontalAlignment="Right" Height="389" VerticalAlignment="Top" Width="568" Margin="707,332,0,-1"> <ScrollViewer HorizontalAlignment="Right" Height="392" VerticalAlignment="Top" Width="568" Margin="0,-3,0,0"> <GridView x:Name="MyGrid2" > <GridView.ItemTemplate> <DataTemplate> <StackPanel> <TextBox x:Name="Zakaz" TextWrapping="Wrap" Text="{Binding sostav}" Background="{x:Null}" BorderBrush="{x:Null}" Height="388" Width="570"/> </StackPanel> </DataTemplate> </GridView.ItemTemplate> </GridView> </ScrollViewer> </Grid>