diff --git a/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerSearchViewModel.cs b/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerSearchViewModel.cs index 73939d10f02..99c37c5c633 100644 --- a/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerSearchViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerSearchViewModel.cs @@ -647,12 +647,26 @@ private void PopulateMyPackages() var pkgs = PackageManagerClientViewModel.CachedPackageList.Where(x => x.Maintainers != null && x.Maintainers.Contains(name)).ToList(); foreach(var pkg in pkgs) { - myPackages.Add(new PackageManagerSearchElementViewModel(pkg, false)); + var p = new PackageManagerSearchElementViewModel(pkg, false); + p.RequestDownload += this.PackageOnExecuted; + + myPackages.Add(p); } SearchMyResults = new ObservableCollection(myPackages); } + private void ClearMySearchResults() + { + if (this.SearchMyResults == null) return; + foreach (var ele in this.SearchMyResults) + { + ele.RequestDownload -= PackageOnExecuted; + } + + this.SearchMyResults = null; + } + /// /// Sort the default package results in the view based on the sorting key and sorting direction. /// @@ -1116,7 +1130,6 @@ internal void ClearSearchResults() { ele.RequestDownload -= PackageOnExecuted; } - this.SearchResults.Clear(); } @@ -1570,6 +1583,8 @@ internal void Close() InitialResultsLoaded = false; // reset the loading screen settings RequestShowFileDialog -= OnRequestShowFileDialog; nonHostFilter.ForEach(f => f.PropertyChanged -= filter_PropertyChanged); + + ClearMySearchResults(); } } }