weianweigan / RevitLookupWpf

a lookup tool based on wpf
MIT License
67 stars 16 forks source link

Problem with menu context open new windows #26

Closed chuongmep closed 2 years ago

chuongmep commented 2 years ago

Describe the bug Problem with menu context open new windows when add feature #24

To Reproduce Steps to reproduce the behavior:

  1. Right click menu context Open new window
  2. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots image

weianweigan commented 2 years ago

This problem may be not associate with #24. I check the code. There is a commit changed the line

public RelayCommand OpenInNewWindowCommand => _openInNewWindowCommand ??(_openInNewWindowCommand = new RelayCommand(OpenInNewWindow, CanOpenInNewWindow));

https://github.com/weianweigan/RevitLookupWpf/blob/0840d80fbc9b1cc40fab954e7865b265fff54856/RevitLookup/ViewModel/LookupViewModel.cs#L120

the new code is clear and shorter. However, i guess the new code produce a new relaycommand object when call

OpenInNewWindowCommand.RaiseCanExecuteChanged();

every time. So the command may not get right CanExecute result.