//ObservableCollection olmasının sebebi ListBox'ların değişimi algılaması
public ObservableCollection<string> İlkListe { get; set; }
public ObservableCollection<string> SonListe { get; set; }
public MainWindow()
{
InitializeComponent();
İlkListe = new ObservableCollection<string>() { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20" };
SonListe = new ObservableCollection<string>();
ListBox_İlk.ItemsSource = İlkListe;
ListBox_Son.ItemsSource = SonListe;
}
private void Button_Aktar_Click(object sender, RoutedEventArgs e)
{
if(SonListe.Count < İlkListe.Count)
{
Random random = new Random();
string eklenecek;
do
{
int rastgelesayı = random.Next(İlkListe.Count);
eklenecek = İlkListe.ElementAt(rastgelesayı);
} while (SonListe.Contains(eklenecek));
SonListe.Add(eklenecek);
}
else
{
MessageBox.Show("Aktarılacak Değer Kalmadı", "HATA");
}
}