public void CommandBehaviorMonitorsCanExecuteChangedToUpdateEnabledWhenCanExecuteChangedIsRaised() { var page = new PhoneApplicationPage(); var bar = new ApplicationBar(); var button = new ApplicationBarIconButton(new Uri("/foo.png", UriKind.Relative)); button.Text = "Foo"; bar.Buttons.Add(button); page.ApplicationBar = bar; var command = new ApplicationBarButtonCommand(); command.ButtonText = "Foo"; var bindingSource = new MyCommandHolder(); var binding = new Binding("Command") { Source = bindingSource, Mode = BindingMode.OneWay }; command.CommandBinding = binding; Interaction.GetBehaviors(page).Add(command); bindingSource.CanExecute = true; var initialState = button.IsEnabled; bindingSource.CanExecute = false; var finalState = button.IsEnabled; Assert.IsTrue(initialState); Assert.IsFalse(finalState); }
public void CommandBehaviorMonitorsCanExecuteChangedToUpdateEnabledWhenCanExecuteChangedIsRaised() { var page = new PhoneApplicationPage(); var bar = new ApplicationBar(); var button = new ApplicationBarIconButton(new Uri("/foo.png", UriKind.Relative)); button.Text = "Foo"; bar.Buttons.Add(button); page.ApplicationBar = bar; var command = new ApplicationBarButtonCommand(); command.ButtonText = "Foo"; var bindingSource = new MyCommandHolder(); command.CommandBinding = bindingSource.Command; Interaction.GetBehaviors(page).Add(command); bindingSource.CanExecute = true; var initialState = button.IsEnabled; bindingSource.CanExecute = false; var finalState = button.IsEnabled; Assert.IsTrue(initialState); Assert.IsFalse(finalState); }
public void CommandBehaviorMonitorsCanExecuteToSetEnabledWhenCanExecuteIsTrue() { var page = new PhoneApplicationPage(); var bar = new ApplicationBar(); var button = new ApplicationBarIconButton(new Uri("/foo.png", UriKind.Relative)); button.Text = "Foo"; bar.Buttons.Add(button); page.ApplicationBar = bar; var command = new ApplicationBarButtonCommand(); command.ButtonText = "Foo"; var bindingSource = new MyCommandHolder(); command.CommandBinding = bindingSource.Command; Interaction.GetBehaviors(page).Add(command); bindingSource.CanExecute = true; Assert.IsTrue(button.IsEnabled); }