public MainWindowViewModel(
            IDirectoryLogic directoryLogic,
            string currentDirectory)
        {
            this.directoryLogic = directoryLogic;
            CurrentDirectory    = currentDirectory;

            Entries = directoryLogic.CollectDirectoryEntries(currentDirectory);

            SelectEntryCommand = new RelayCommand(
                () => {
                this.directoryLogic.SelectEntry(SelectedEntry);     // MUST reference the datafield!
            });

            // ONLY if there is time:
            // IF free variable = closure = can use hard reference since 5.4.0
            // PROBLEM: possible memory leak, this will be detailed in the lecture
            // http://galasoft.ch/s/mvvmweakaction

            /*
             * SelectEntryCommand = new RelayCommand(
             *  () => {
             *      directoryLogic.SelectEntry(SelectedEntry);  // uses the parameter, not the datafield!
             *  }, true);
             */
        }
Beispiel #2
0
        public MainWindowViewModel(IDirectoryLogic directoryLogic, string currentDirectory)
        {
            this.directoryLogic = directoryLogic;
            CurrentDirectory    = currentDirectory;

            Entries = directoryLogic.CollectDirectoryEntries(currentDirectory);

            SelectEntryCommand = new RelayCommand(() =>
            {
                this.directoryLogic.SelectEntry(SelectedEntry); // MUSZÁJ az adattagra hivatkozni (azaz this . dirlogic)!
            });

            LogCurrentCommand = new RelayCommand(() =>
            {
                this.directoryLogic.LogCurrent(CurrentDirectory); // currentDirectory a belső változót jelenti, úgy nem lesz jó!
            });
        }
Beispiel #3
0
        public MainWindowViewModel(IDirectoryLogic directoryLogic, string currentDirectory)
        {
            this.directoryLogic = directoryLogic;
            CurrentDirectory    = currentDirectory;

            Entries = directoryLogic.CollectDirectoryEntries(currentDirectory);

            TestDCCommand = new RelayCommand(() =>
            {
                this.directoryLogic.SelectEntry(SelectedEntry);
            });

            SelectEntryCommand = new RelayCommand(() =>
            {
                this.directoryLogic.SelectEntry(SelectedEntry);
            });

            LogCurrentCommand = new RelayCommand(() =>
            {
                this.directoryLogic.LogCurrent(CurrentDirectory);
            });
        }