示例#1
0
        //按+按鈕
        private void AddBtn_MouseDown(object sender, MouseButtonEventArgs e)
        {
            //產生新項目
            NewTag newTags = new NewTag();

            TagList.Children.Add(newTags);

            //計算總額
            int totalprice = 0;

            foreach (NewTag newtags in TagList.Children)
            {
                totalprice += newtags.setPriceValue;
            }
            //顯示價格
            Total.Text = totalprice.ToString();
        }
示例#2
0
        // 開啟視窗事件
        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('|');
                // 建立 NewTag
                NewTag newtags = new NewTag();

                newtags.TagDate.Text  = parts[0];
                newtags.TagName.Text  = parts[1];
                newtags.TagPrice.Text = parts[2];

                // 放到清單中
                TagList.Children.Add(newtags);
            }
        }