From d99314710793f8960096c3283baf0c4aa1dfebc4 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 7 Dec 2020 18:37:24 +0800 Subject: [PATCH] fix: INotifyPropertyChanged event not raised when IsActive changed --- src/UI/Launcher.xaml | 2 +- src/UI/Launcher.xaml.cs | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/UI/Launcher.xaml b/src/UI/Launcher.xaml index e9a81106..dd4b4325 100644 --- a/src/UI/Launcher.xaml +++ b/src/UI/Launcher.xaml @@ -79,7 +79,7 @@ - + diff --git a/src/UI/Launcher.xaml.cs b/src/UI/Launcher.xaml.cs index f3acfe70..bbbd7ec2 100644 --- a/src/UI/Launcher.xaml.cs +++ b/src/UI/Launcher.xaml.cs @@ -21,18 +21,32 @@ namespace SourceGit.UI { /// Tab data. /// public class Tab : INotifyPropertyChanged { + private bool isActive = false; + public string Title { get; set; } public string Tooltip { get; set; } - public bool IsActive { get; set; } public Git.Repository Repo { get; set; } public object Page { get; set; } - public bool IsRepo => Repo != null; + + public bool IsRepo { + get { return Repo != null; } + } + public int Color { get { return Repo == null ? 0 : Repo.Color; } set { if (Repo == null || Repo.Color == value) return; Repo.Color = value; - PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Color")); + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Color")); + } + } + + public bool IsActive { + get { return isActive; } + set { + if (isActive == value) return; + isActive = value; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsActive")); } }