WPF-Listbox-Listbox Item 더블 클릭 이벤트 구현 - MVVM 모드

2992 단어

                            
                                
                                    
                                        
                                            
                                        
                                    
                                
                            
                        
DataContext.EsCanSelectListMouseDoubleClickCommand   C#              
ElementName=w            w     
Path=ExportName  textblock          CanSelectLis               
C#    :
    /// 
    ///          
    /// 
    public class ExportModel
    {
        public int ExportID { get; set; } 
        public string ExportName { get; set; }
    }
      VeiwModel
public class ExportSettingVeiwModel:ViewModels
    {
        private ObservableCollection canSelectList;
        /// 
        ///      
        /// 
        public ObservableCollection CanSelectList
        {
            get { return canSelectList; }
            set 
            { 
                canSelectList = value;
                RaisePropertyChanged("CanSelectList");
            }
        }

        public ICommand EsCanSelectListMouseDoubleClickCommand { get; set; }
        public ExportSettingVeiwModel()
        {
            EsCanSelectListMouseDoubleClickCommand = new DelegateCommand(EsCanSelectList_MouseDoubleClick);
            CanSelectList = new ObservableCollection();
            ExportModel ceshi = new ExportModel();
            ceshi.ExportID = 1;
            ceshi.ExportName = "ceshi";
            CanSelectList.Add(ceshi);
            
        }


        public void EsCanSelectList_MouseDoubleClick()
        {
            if (CanSelectList.Count > 0 && _exportsetting.EsCanSelectList.SelectedIndex >= 0)
            {


            }
            //{
            //    int selectindex = _exportsetting.EsCanSelectList.SelectedIndex;
            //   // ExportList.Add(CanSelectList[selectindex]);
            //    CanSelectList.RemoveAt(selectindex);
            //    if (selectindex < CanSelectList.Count)
            //    {
            //        _exportsetting.EsCanSelectList.SelectedIndex = selectindex;
            //    }
            //    else
            //    {
            //        _exportsetting.EsCanSelectList.SelectedIndex = selectindex - 1;
            //    }
            //}
        }
}

좋은 웹페이지 즐겨찾기