private void Window_Loaded(object sender, RoutedEventArgs e) { // 開啟檔案 string[] lines = System.IO.File.ReadAllLines(@"D:\data.txt"); // 分析 foreach (string line in lines) { // 隔開 string[] parts = line.Split('|'); //建立元件 addprice item = new addprice(); //讀取 item.Daytimes = parts[0]; item.ItemName = parts[1]; item.ItemPrice = parts[2]; //增加項目 TaskList.Children.Add(item); } }
private void AddBtn_Click(object sender, RoutedEventArgs e) { addprice item = new addprice(); TaskList.Children.Add(item); }