Good evening, please tell me there is a ListView:
<ListView x:Name="professions" MouseDoubleClick="professions_MouseDoubleClick"> <ListView.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock x:Name="id" Text="{Binding Key}"/> <TextBlock x:Name="val" Text="{Binding Value}"/> </StackPanel> </DataTemplate> </ListView.ItemTemplate> </ListView> and there is an event handler:
private void professions_MouseDoubleClick(object sender, MouseButtonEventArgs e) { groupSostav.Items.Add("???"); } With a double click, you need this (Text = "{Binding Value}") value to be added to the ListBox groupsostav, it is impossible to get it, what needs to be substituted into (groupSostav.Items.Add ("???");) instead of "? ?? " ?
In ListBox, entries are added from the constructor like this:
Dictionary<int, string> col1 = new Dictionary<int, string>() { {1, "ΠΠ½Π°ΡΠ΅Π½ΠΈΠ΅ 1"}, {2, "ΠΠ½Π°ΡΠ΅Π½ΠΈΠ΅ 2"}, {3, "ΠΠ½Π°ΡΠ΅Π½ΠΈΠ΅ 3"} }; foreach (var profList in col1) { professions.Items.Add(new Item { Key = profList.Key, Value = profList.Value }); } } public class Item { public int Key { get; set; } public string Value { get; set; } }