コード例 #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // 讀檔
            string[] lines = System.IO.File.ReadAllLines(@"C:\temp\data.txt");

            // 逐行產生元件
            foreach (string line in lines)
            {
                // 用符號分隔
                string[] parts = line.Split('|');

                // 建立元件
                todolist item = new todolist();
                item.ItemName = parts[1];

                if (parts[0] == "+")
                {
                    item.IsChecked = true;
                }
                else
                {
                    item.IsChecked = false;
                }

                // 放入到 StackPanel
                todoitemlist.Children.Add(item);
            }
        }
コード例 #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // 開檔
            string[] lines = System.IO.File.ReadAllLines(@"C:\temp\data.txt");

            foreach (string line in lines)
            {
                // 用 | 符號拆開
                string[] parts = line.Split('|');
                // 建立 TodoItem
                todolist item = new todolist();

                item.date.Text       = parts[1];
                item.itemName.Text   = parts[2];
                item.moneyCount.Text = parts[3];

                ToDoStack.Children.Add(item);
            }
            int sum = 0;

            foreach (todolist item in ToDoStack.Children)
            {
                sum       += int.Parse(item.moneyCount.Text);
                Total.Text = sum.ToString();
            }
        }
コード例 #3
0
        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            todolist Item = new todolist();

            // 增加物品
            ToDoStack.Children.Add(Item);
        }
コード例 #4
0
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            // 建立元件
            todolist item = new todolist();

            // 放入到 StackPanel
            todoitemlist.Children.Add(item);
        }