본문 바로가기

Programing (프로그래밍)/WPF & C# (C Sharp)

WPF & C# - 동적배열 ObservableCollection<string> ( List / Items )

728x90
반응형


 WPF & C# - 동적배열 ObservableCollection<string> ( List / Items )



ObservableCollection.zip


MainWindow.xaml.cs



1
2
3
4
5
6
7
8
9
10
11
12
13
14
public ObservableCollection<string> ListOfItems { get; set; }
private void btn_Click(object sender, RoutedEventArgs e)
{
    ListOfItems = new ObservableCollection<string>();
    ListOfItems.Add("1");
    ListOfItems.Add("2");
    ListOfItems.Add("3");
    ListOfItems.Add("4");
 
    string s="";
    foreach (string str in ListOfItems)
        s += str;
    lbl.Content = s;
}
cs




728x90
반응형