Bonjour,
Je souhaite débuter dans le c# ; je suis actuellement bloquer
voici mon xaml
Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 <ListBox x:Name="listBox1" Margin="0,6,0,6" ItemsSource="{Binding FruitItem}" SelectionChanged="MainListBox_SelectionChanged"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Height="150"> <StackPanel Width="370"> <TextBlock Text="{Binding nom}" Style="{StaticResource PhoneTextExtraLargeStyle}" /> </StackPanel> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox>
s'affichant depuis :
Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 listBox1.ItemsSource = from fruits in xmlFruit.Descendants("Fruit") select new FruitItem { id = fruits.Attribute("id").Value.ToString(), nom = fruits.Attribute("nom").Value.ToString() }; public class FruitItem { public string id { get; set; } }
Je souhaite récupérer l'id du fruit dans textBox1
Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 private void MainListBox_SelectionChanged(object sender, RoutedEventArgs e) { textBox1.Text = " ->"; textBox1.Text += listBox1.SelectedIndex.ToString(); }
j'ai essayé divers chose sans comprendre meme avec ce sujet
http://www.developpez.net/forums/d10...a-datarowview/
J'ai : test_xml_fruit.MainPage+FruitItem dans textBox1
Pourriez vous m'aidez ?
Partager