WPF实战学习笔记06-设置待办事项界面

设置待办事项界面

创建待办待办事项集合并初始化

  • TodoViewModel:
using Mytodo.Common.Models;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mytodo.ViewModels
{
    public class TodoViewModel:BindableBase
    {
		private ObservableCollection? todoDtos;

		/// 
		/// todo集合
		/// 
		public ObservableCollection? TodoDtos
        {
			get { return todoDtos; }
			set { todoDtos = value; RaisePropertyChanged(); }
		}
        public TodoViewModel()
        {
            //创建测试数据
            CreatTestData();
            OpenRightContentCmd = new DelegateCommand(Add);
        }

        void CreatTestData()
        {
            TodoDtos = new ObservableCollection();

            for (int i = 0; i < 20; i++)
            {
                TodoDtos.Add(new ToDoDto() { Title = "待办" + i, Content = "正在处理中....." });
            }
        }

    }
}

创建绑定右侧命令、变量

private bool isRightOpen;

public bool IsRightOpen
{
    get { return isRightOpen; }
    set { isRightOpen = value; RaisePropertyChanged(); }
}
public DelegateCommand OpenRightContentCmd { set; get; }
void Add()
{
    IsRightOpen = true;
}
public TodoViewModel()
{
    //创建测试数据
    OpenRightContentCmd = new DelegateCommand(Add);
}

设置界面


    
        
            
                
                    
                    
                        
                        
                            
                            
                        
                    
                    
                    
                
            
            
                
                    
                    
                

                
                    
                    
                    
                        
                        
                        
                    


                
                

你可能感兴趣的:(WPF实战学习笔记,wpf,学习,笔记)