From 2efcbd060aeb238ba06f9d1b0129eb1b1274d4bc Mon Sep 17 00:00:00 2001 From: Colin Liu Date: Fri, 19 Feb 2016 22:55:58 +0800 Subject: [PATCH] Implement ToString and GetHashCode methods for ResultItemViewModel --- Wox/ViewModel/ResultItemViewModel.cs | 20 +++++++++++++------- Wox/ViewModel/ResultPanelViewModel.cs | 6 ++++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Wox/ViewModel/ResultItemViewModel.cs b/Wox/ViewModel/ResultItemViewModel.cs index bac2548f38..07092df8df 100644 --- a/Wox/ViewModel/ResultItemViewModel.cs +++ b/Wox/ViewModel/ResultItemViewModel.cs @@ -119,14 +119,20 @@ namespace Wox.ViewModel ResultItemViewModel r = obj as ResultItemViewModel; if (r != null) { - var equality = string.Equals(r.Title, Title) && - string.Equals(r.SubTitle, SubTitle); - return equality; - } - else - { - return false; + return _result.Equals(r.RawResult); } + + return false; + } + + public override int GetHashCode() + { + return _result.GetHashCode(); + } + + public override string ToString() + { + return _result.ToString(); } public event EventHandler ResultOpened; diff --git a/Wox/ViewModel/ResultPanelViewModel.cs b/Wox/ViewModel/ResultPanelViewModel.cs index 77bbc63ae9..e2046e0237 100644 --- a/Wox/ViewModel/ResultPanelViewModel.cs +++ b/Wox/ViewModel/ResultPanelViewModel.cs @@ -79,7 +79,7 @@ namespace Wox.ViewModel } set { - if (value != _selectedResult) + if (null != value) { if (null != _selectedResult) { @@ -93,8 +93,10 @@ namespace Wox.ViewModel _selectedResult.IsSelected = true; } - OnPropertyChanged("SelectedResult"); } + + OnPropertyChanged("SelectedResult"); + } }