Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
220 views
in Technique[技术] by (71.8m points)

c# - How do I add the item I selected in the Combobox to the list box on another page in WPF

**Combobox XAML**

Items in the ComboBox come from an array. Therefore it does not appear in XAML

    <ComboBox Name="cbSelectMovie" HorizontalAlignment="Left" Margin="252,174,0,0" VerticalAlignment="Top" Width="196" Height="32" SelectionChanged="cbSelectMovie_SelectionChanged">

When the button is pressed, it is added to the ListBox.

<Button Content="Ad Movie..." HorizontalAlignment="Left" FontSize="14" Margin="56,264,0,0" VerticalAlignment="Top" Width="165" Height="46" Click="Button_Click" />

ListBox on another page

 <ListBox x:Name="movieListBox" HorizontalAlignment="Left" Height="326" Margin="38,44,0,0" VerticalAlignment="Top" Width="231"/>

I did such a try, but unfortunately, it didn't work.

 private void Button_Click(object sender, RoutedEventArgs e)
    {
        string x = " " ;
        MovieList mv = new MovieList();
        // mv.MovieListBox = cbSelectMovie.Text;
        cbSelectMovie.SelectedItem = x.ToString();
        mv.MovieListBox.Items.Add(x);

    }
question from:https://stackoverflow.com/questions/65647260/how-do-i-add-the-item-i-selected-in-the-combobox-to-the-list-box-on-another-page

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...