Ejemplo n.º 1
0
        public void WriteIn(object sender, MouseButtonEventArgs e)
        {
            var       listView   = sender as ListView;
            todo_list _todo_list = listView.SelectedItem as todo_list;

            if (_todo_list != null && listView != null)
            {
                //当前文本框可用
                foreach (var item in todo_list)
                {
                    if (item == _todo_list)
                    {
                        item.IsEnabled_TODO = true;
                    }
                    else
                    {
                        item.IsEnabled_TODO = false;
                    }
                }

                resElement = new List <FrameworkElement>();
                FindChildByType(listView, typeof(TextBox));
                var cur_box = resElement[_todo_list.num];
                if (cur_box is TextBox)
                {
                    Keyboard.Focus(cur_box);//使得当前文本框获得光标
                }
            }
        }
Ejemplo n.º 2
0
        private void DONE_ListView_Drop(object sender, DragEventArgs e)
        {
            try
            {
                Point         pos    = e.GetPosition(DONE_ListView);
                HitTestResult result = VisualTreeHelper.HitTest(DONE_ListView, pos);
                if (result == null)
                {
                    return;
                }

                //获取拖动的控件的数据
                todo_list data = (todo_list)e.Data.GetData(typeof(ContentControl));

                var       model = DONE_ListView.DataContext as MainWindowViewModel;
                done_list list  = new done_list();
                list.content   = data.content;
                list.num       = data.num;
                list.box_color = "#BBBBBB";
                model.done_list.Add(list);
                DONE_ListView.Height = DONE_ListView.Height + 50;//递加DONE_ListView高度

                model.todo_list.Remove(data);
                var i = 0;

                foreach (var item in model.todo_list)
                {
                    item.num = i;
                    i       += 1;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }