Fixed inactive Next button when validating credentials. Fixes #1784
authorPanagiotis Kanavos <pkanavos@gmail.com>
Sat, 7 Jan 2012 14:52:57 +0000 (16:52 +0200)
committerPanagiotis Kanavos <pkanavos@gmail.com>
Sat, 7 Jan 2012 14:52:57 +0000 (16:52 +0200)
trunk/Pithos.Client.WPF/Preferences/AddAccountView.xaml
trunk/Pithos.Client.WPF/Preferences/AddAccountView.xaml.cs

index c0d28a9..ac31199 100644 (file)
@@ -9,7 +9,7 @@
         <my:InverseBoolConverter x:Key="InverseBool" />
         <BooleanToVisibilityConverter x:Key="BoolToVisible" />
     </Window.Resources>
-    <extToolkit:Wizard FinishButtonClosesWindow="True" Name="AccountWizard" PageChanged="AccountWizard_PageChanged">
+    <extToolkit:Wizard FinishButtonClosesWindow="True" Name="AccountWizard" PageChanged="AccountWizard_PageChanged" HelpButtonVisibility="Collapsed">
         <extToolkit:WizardPage x:Name="IntroPage" 
                                    Title="Add new Pithos Account"
                                    Description="This Wizard will walk you through adding a new Pithos account and retrieving an authentication token" 
@@ -51,7 +51,8 @@
                                    Description="Please enter the account credentials and press &quot;Validate Credentials&quot;"
                                NextPage="{Binding ElementName=AccountPathPage}"                               
                                FinishButtonVisibility="Collapsed"
-                               CanSelectNextPage="{Binding HasValidCredentials}" 
+                               CanSelectNextPage="{Binding HasValidCredentials,NotifyOnTargetUpdated=True}" 
+                               TargetUpdated="OnTargetUpdated"
                                >
             <extToolkit:BusyIndicator x:Name="ManualBusyIndicator" IsBusy="{Binding IsWorking,NotifyOnSourceUpdated=true}" DisplayAfter="0" >
                 <extToolkit:BusyIndicator.BusyContent>
         </extToolkit:WizardPage>
         <extToolkit:WizardPage x:Name="AutoAccountPage" PageType="Interior"
                                    Title="Add an account automatically"
-                                   Description="By clicking on the button below you will be taken to the Pithos web site where you can login with your username and password."
-                               NextPage="{Binding ElementName=AutoConfirmedPage}"                               
+                                   Description="By clicking on the button below you will be taken to the Pithos web site where you can login with your username and password."                               
                                FinishButtonVisibility="Collapsed"
-                               CanSelectNextPage="{Binding HasValidCredentials}"                               
+                               CanSelectNextPage="{Binding HasValidCredentials,NotifyOnTargetUpdated=true}"                               
+                               TargetUpdated="OnTargetUpdated"
                                >
             <extToolkit:BusyIndicator x:Name="AutoBusyIndicator" IsBusy="{Binding IsWorking}" DisplayAfter="0">
                 <extToolkit:BusyIndicator.BusyContent>
index 85172e7..681d264 100644 (file)
@@ -22,10 +22,6 @@ namespace Pithos.Client.WPF.Preferences
         public AddAccountView()
         {
             InitializeComponent();
-            
-            //When the busy indicator changes, force a focus change. Workaround for delayed change of the Next button's visibility
-            ManualBusyMessage.IsVisibleChanged += (sender, evt) => Token.Focus();
-            ValidationMessage.IsVisibleChanged += (sender, evt) => ValidationMessage.Focus();
         }
 
 
@@ -61,5 +57,14 @@ namespace Pithos.Client.WPF.Preferences
             _history.Push(AccountWizard.CurrentPage);
 
         }
+
+        private void OnTargetUpdated(object sender, DataTransferEventArgs e)
+        {
+            //It is not enough to change the value of the CanSelectNextPage property of the page to enable
+            //the next page button.
+            //Must force the re-evaluation of the NextPage command's CanExecute method             
+            if (e.Property == WizardPage.CanSelectNextPageProperty)
+                CommandManager.InvalidateRequerySuggested();
+        }
     }
 }