本文整理汇总了C#中System.DelegateCommand.RaiseCanExecuteChanged方法的典型用法代码示例。如果您正苦于以下问题:C# DelegateCommand.RaiseCanExecuteChanged方法的具体用法?C# DelegateCommand.RaiseCanExecuteChanged怎么用?C# DelegateCommand.RaiseCanExecuteChanged使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DelegateCommand
的用法示例。
在下文中一共展示了DelegateCommand.RaiseCanExecuteChanged方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
private void Init(Model model) {
this.DataContext = model;
var applyCommand = new DelegateCommand(
() => Success(new Result.Apply(model)),
() => {
if (repeatedPassword != model.password) {
return false;
}
return true;
}
);
OnRepeatedPasswordChanged += () => applyCommand.RaiseCanExecuteChanged();
ApplyCommand = applyCommand;
var cancelCommand = new DelegateCommand(
() => Success(new Result.Cancel()),
() => true
);
CancelCommand = cancelCommand;
repeatedPassword = model.password;
InitializeComponent();
userNameCaption.CreateBinding(Label.ContentProperty, this.Strings, s => s.nameCaption);
userNameValue.CreateBinding(TextBox.TextProperty, model, m => m.name);
passwordCaption.CreateBinding(Label.ContentProperty, this.Strings, s => s.passwordCaption);
repeatPasswordCaption.CreateBinding(Label.ContentProperty, this.Strings, s => s.repeatPasswordCaption);
passwordValue.CreateBinding(
TextBox.TextProperty, model,
m => m.password,
(m, v) => {
m.password = String.IsNullOrEmpty(v) ? null : v;
applyCommand.RaiseCanExecuteChanged();
}
);
//repeatPasswordCaption.CreateBinding(Label.ContentProperty, this.Strings, s => s.repeatPassword);
repeatPasswordValue.Text = repeatedPassword;
repeatPasswordValue.TextChanged += (s, a) => {
repeatedPassword = String.IsNullOrEmpty(repeatPasswordValue.Text) ? null : repeatPasswordValue.Text;
};
roleCaption.CreateBinding(Label.ContentProperty, this.Strings, s => s.roleCaption);
roleValue.ItemsSource = EnumHelper.GetValues<UserLevel>().Where(v => v != UserLevel.anonymous && v != UserLevel.extended);
roleValue.CreateBinding(ComboBox.SelectedValueProperty, model, m => m.level, (m, v) => m.level = v);
applyButton.Command = ApplyCommand;
applyButton.CreateBinding(Button.ContentProperty, SaveCancel, s => s.apply);
cancelButton.Command = CancelCommand;
cancelButton.CreateBinding(Button.ContentProperty, SaveCancel, s => s.cancel);
}
示例2: AddParticleDlgViewModel
public AddParticleDlgViewModel(IParticlesManager particleManager, Type targetType, IBlockManager blockManager)
{
_particleManager = particleManager;
_blockManager = blockManager;
AddParticleVm = new AddParticleViewViewModel(_particleManager, Visibility.Collapsed);
OkCommand = new DelegateCommand<Window>((wnd) =>
{
if (AddParticleVm.UseNewParticle)
{
var particle = _particleManager.CreateParticle(AddParticleVm.NewParticle.Material,
AddParticleVm.NewParticle.Begin, AddParticleVm.NewParticle.End);
_blockManager.AddParticleToBlock(_block, particle);
}
else if (AddParticleVm.UseExistParticle && AddParticleVm.ExistParticle.HasValue)
{
var particle = _particleManager.GetParticleById(AddParticleVm.ExistParticle.Value);
_blockManager.AddParticleToBlock(_block, particle);
}
wnd.DialogResult = true;
wnd.Close();
}, wnd => _block != null && (AddParticleVm.UseNewParticle || AddParticleVm.UseExistParticle));
SelectIdeaCommand = new DelegateCommand(() =>
{
var dlg = new SelectTagDlg(targetType);
var res = dlg.ShowDialog();
if (res.HasValue && res.Value && dlg.Id.HasValue)
{
_block = _blockManager.GetBlockById(dlg.Id.Value);
BlockCaption = _block.Caption;
OkCommand.RaiseCanExecuteChanged();
}
});
}
示例3: DemoViewModel
public DemoViewModel(IDemoProfileActivator demoListener)
{
_demoListener = demoListener;
_activateIdentityCommand = new DelegateCommand(ActivateIdentity, IsIdentityValid);
this.PropertyChanges(vm => vm.Identity).Subscribe(_ => _activateIdentityCommand.RaiseCanExecuteChanged());
}
示例4: TestCanExecuteChanged2
public void TestCanExecuteChanged2()
{
bool actioned1 = false;
var command1 = new DelegateCommand(() => { });
command1.CanExecuteChanged += (s, e) => actioned1 = true;
command1.RaiseCanExecuteChanged();
Assert.True(actioned1);
}
示例5: CanExecuteChangedWithMultipleCommands
public void CanExecuteChangedWithMultipleCommands()
{
var command1 = new DelegateCommand(() => { }, () => true);
var command2 = new DelegateCommand<int>(i => { }, _ => true);
var compositeCommand = new CompositeCommand();
bool canExecuteEventFired = false;
EventHandler eventHandler = (sender, eventArgs) =>
{
Assert.AreSame(compositeCommand, sender);
Assert.IsNotNull(eventArgs);
canExecuteEventFired = true;
};
compositeCommand.CanExecuteChanged += eventHandler;
compositeCommand.RegisterCommand(command1);
compositeCommand.RegisterCommand(command2);
Assert.IsFalse(EventConsumer.EventCalled);
command1.RaiseCanExecuteChanged();
Assert.IsTrue(canExecuteEventFired);
canExecuteEventFired = false;
command2.RaiseCanExecuteChanged();
Assert.IsTrue(canExecuteEventFired);
canExecuteEventFired = false;
compositeCommand.UnregisterCommand(command1);
Assert.IsTrue(canExecuteEventFired); // Unregister also raises CanExecuteChanged.
canExecuteEventFired = false;
command1.RaiseCanExecuteChanged();
Assert.IsFalse(canExecuteEventFired);
command2.RaiseCanExecuteChanged();
Assert.IsTrue(canExecuteEventFired);
canExecuteEventFired = false;
compositeCommand.UnregisterCommand(command2);
Assert.IsTrue(canExecuteEventFired); // Unregister also raises CanExecuteChanged.
canExecuteEventFired = false;
command1.RaiseCanExecuteChanged();
command2.RaiseCanExecuteChanged();
Assert.IsFalse(canExecuteEventFired);
}
示例6: PackageViewModel
public PackageViewModel(DynamoViewModel dynamoViewModel, Package model)
{
this.dynamoViewModel = dynamoViewModel;
this.Model = model;
ToggleTypesVisibleInManagerCommand = new DelegateCommand(ToggleTypesVisibleInManager, CanToggleTypesVisibleInManager);
GetLatestVersionCommand = new DelegateCommand(GetLatestVersion, CanGetLatestVersion);
PublishNewPackageVersionCommand = new DelegateCommand(PublishNewPackageVersion, CanPublishNewPackageVersion);
PublishNewPackageCommand = new DelegateCommand(PublishNewPackage, CanPublishNewPackage);
UninstallCommand = new DelegateCommand(Uninstall, CanUninstall);
DeprecateCommand = new DelegateCommand(this.Deprecate, CanDeprecate);
UndeprecateCommand = new DelegateCommand(this.Undeprecate, CanUndeprecate);
this.dynamoViewModel.Model.NodeAdded += (node) => UninstallCommand.RaiseCanExecuteChanged();
this.dynamoViewModel.Model.NodeDeleted += (node) => UninstallCommand.RaiseCanExecuteChanged();
this.dynamoViewModel.Model.WorkspaceHidden += (ws) => UninstallCommand.RaiseCanExecuteChanged();
this.dynamoViewModel.Model.Workspaces.CollectionChanged += (sender, args) => UninstallCommand.RaiseCanExecuteChanged();
}
示例7: RaiseCanExecuteChanged_Fires_Event
public void RaiseCanExecuteChanged_Fires_Event()
{
var command = new DelegateCommand(() => { });
bool changedWasRaised = false;
command.CanExecuteChanged += (s, e) => changedWasRaised = true;
command.RaiseCanExecuteChanged();
Assert.That(changedWasRaised);
}
示例8: Package
public Package(string directory, string name, string versionName)
{
this.Loaded = false;
this.RootDirectory = directory;
this.Name = name;
this.VersionName = versionName;
this.LoadedTypes = new ObservableCollection<Type>();
this.Dependencies = new ObservableCollection<PackageDependency>();
this.LoadedCustomNodes = new ObservableCollection<CustomNodeInfo>();
ToggleTypesVisibleInManagerCommand = new DelegateCommand(ToggleTypesVisibleInManager, CanToggleTypesVisibleInManager);
GetLatestVersionCommand = new DelegateCommand(GetLatestVersion, CanGetLatestVersion);
PublishNewPackageVersionCommand = new DelegateCommand(PublishNewPackageVersion, CanPublishNewPackageVersion);
PublishNewPackageCommand = new DelegateCommand(PublishNewPackage, CanPublishNewPackage);
UninstallCommand = new DelegateCommand(Uninstall, CanUninstall);
DeprecateCommand = new DelegateCommand(this.Deprecate, CanDeprecate);
UndeprecateCommand = new DelegateCommand(this.Undeprecate, CanUndeprecate);
dynSettings.Controller.DynamoModel.NodeAdded += (node) => UninstallCommand.RaiseCanExecuteChanged();
dynSettings.Controller.DynamoModel.NodeDeleted += (node) => UninstallCommand.RaiseCanExecuteChanged();
dynSettings.Controller.DynamoModel.WorkspaceHidden += (ws) => UninstallCommand.RaiseCanExecuteChanged();
dynSettings.Controller.DynamoModel.Workspaces.CollectionChanged += (sender, args) => UninstallCommand.RaiseCanExecuteChanged();
}
示例9: BluetoothSetupViewModel
public BluetoothSetupViewModel(IBluetoothService bluetoothService, IBluetoothProfileActivator bluetoothProfileActivator, ISchedulerProvider schedulerProvider)
{
_bluetoothService = bluetoothService;
_bluetoothProfileActivator = bluetoothProfileActivator;
_schedulerProvider = schedulerProvider;
_roDevices = new ReadOnlyObservableCollection<IBluetoothDevice>(_devices);
_scanForDevicesCommand = new DelegateCommand(ScanForDevices, CanScanForDevices);
_status = ViewModelStatus.Error(Resources.Bluetooth_NoDevices_RequiresScan);
_bluetoothProfileActivator.PropertyChanges(bs => bs.IsEnabled)
.Subscribe(_ =>
{
OnPropertyChanged("IsEnabled");
_scanForDevicesCommand.RaiseCanExecuteChanged();
});
}
示例10: EditViewModelBase
protected EditViewModelBase(IService service)
: base(service)
{
_service = service;
SaveCommand = new DelegateCommand<object>(OnSave, CanSave);
AbortCommand = new DelegateCommand<object>(OnAbort, CanAbort);
if (_service != null)
{
_service.PropertyChanged += (o, e) =>
{
if (!e.PropertyName.Equals("HasChanges", StringComparison.OrdinalIgnoreCase)) return;
SaveCommand.RaiseCanExecuteChanged();
AbortCommand.RaiseCanExecuteChanged();
};
}
}
示例11: CommandsInit
private void CommandsInit()
{
AddAddressCommand = new DelegateCommand(RaiseAddAddressRequest);
EditAddressCommand = new DelegateCommand<Address>(RaiseEditAddressRequest);
DeleteAddressCommand = new DelegateCommand(DeleteAddress);
ShowAddEmailCommand = new DelegateCommand(ShowAddEmail);
SaveNewEmailCommand = new DelegateCommand(SaveNewEmail, CanSaveNewEmail);
DeleteEmailCommand = new DelegateCommand(DeleteEmail);
CancelSaveEmailCommand = new DelegateCommand(CancelSaveEmail);
ShowAddPhoneCommand = new DelegateCommand(ShowAddPhone);
SaveNewPhoneCommand = new DelegateCommand(SaveNewPhone, CanSaveNewPhone);
DeletePhoneCommand = new DelegateCommand(DeletePhone);
CancelSavePhoneCommand = new DelegateCommand(CancelSavePhone);
SaveNewEmailCommand.RaiseCanExecuteChanged();
SaveNewPhoneCommand.RaiseCanExecuteChanged();
}
示例12: EventsViewModel
public EventsViewModel()
{
SearchCommand = new DelegateCommand(Search, () => CanSearch);
UndoFilterCommand = new DelegateCommand(UndoFilter, () => CanUndoFilter);
//Get Distances
DistanceOptions = new ObservableCollection<int>();
GetDistanceOptions(false);
//Get Page sizes
PageSizeOptions = new ObservableCollection<int>();
GetPageSizes(false);
//Get Categories
CategoryOptions = new ObservableCollection<Models.Category>();
GetCategories(true);
SearchResults = new ObservableCollection<Result>();
SearchResults.CollectionChanged += (s, e) =>
{
OnPropertyChanged("SearchResults");
UndoFilterCommand.RaiseCanExecuteChanged();
};
}
示例13: ShouldUpdateEnabledStateIfCanExecuteChangedRaisesOnDelegateCommandAfterCollect
public void ShouldUpdateEnabledStateIfCanExecuteChangedRaisesOnDelegateCommandAfterCollect()
{
var clickableObject = new MockClickableObject();
var command = new DelegateCommand<object>(delegate { }, o => true);
var behavior = new ButtonBaseClickCommandBehavior(clickableObject);
behavior.Command = command;
clickableObject.IsEnabled = false;
GC.Collect();
command.RaiseCanExecuteChanged();
Assert.IsTrue(clickableObject.IsEnabled);
}
示例14: Init
private void Init(Model model) {
OnCompleted += () => {
disposables.Dispose();
};
this.DataContext = model;
var userManagementEventArgs = activityContext.container.Resolve<IUserManagementEventArgs>();
var createUserCommand = new DelegateCommand(
() => Success(new Result.CreateUser(model)),
() => true
);
var deleteUserCommand = new DelegateCommand(
() => Success(new Result.DeleteUser(model)),
() => model.selection != null
);
var modifyUserCommand = new DelegateCommand(
() => Success(new Result.ModifyUser(model)),
() => model.selection != null
);
disposables.Add(
model
.GetPropertyChangedEvents(m => m.selection)
.Subscribe(v => {
modifyUserCommand.RaiseCanExecuteChanged();
deleteUserCommand.RaiseCanExecuteChanged();
})
);
var downloadPoliciesCommand = new DelegateCommand(
() => {
var dlg = new SaveFileDialog();
dlg.FileName = userManagementEventArgs.Manufacturer + "-" + userManagementEventArgs.DeviceModel + "-policies.txt";
dlg.Filter = "Text files (*.txt) |*.txt|All files (*.*)|*.*";
if (dlg.ShowDialog() == true) {
Success(new Result.DownloadPolicy(model, dlg.FileName));
}
},
() => true
);
var uploadPoliciesCommand = new DelegateCommand(
() => {
var dlg = new OpenFileDialog();
if (dlg.ShowDialog() == true) {
Success(new Result.UploadPolicy(model, dlg.FileName));
}
},
() => true
);
InitializeComponent();
Localization();
usersList.ItemsSource = model.users;
usersList.CreateBinding(
ListBox.SelectedValueProperty, model,
m => m.selection,
(m, v) => m.selection = v
);
createUserButton.Command = createUserCommand;
modifyUserButton.Command = modifyUserCommand;
deleteUserButton.Command = deleteUserCommand;
uploadPoliciesButton.Command = uploadPoliciesCommand;
downloadPoliciesButton.Command = downloadPoliciesCommand;
}
示例15: InitializeCommands
protected void InitializeCommands()
{
OpenItemCommand = new DelegateCommand(RiseOpenItemCommand);
MinimizeCommand = new DelegateCommand(() => MinimizableViewRequestedEvent(this, null));
SaveChangesCommand = new DelegateCommand<object>(RaiseSaveInteractionRequest, x => IsValid);
CancelCommand = new DelegateCommand<object>(RaiseCancelInteractionRequest);
CancelConfirmRequest = new InteractionRequest<Confirmation>();
SaveConfirmRequest = new InteractionRequest<Confirmation>();
ResolveAndSaveCommand = new DelegateCommand<object>(RaiseResolveAndSaveInteractionRequest,
(x) => CanRaiseResolveAndSaveChangedInteractionRequest());
ProcessAndSaveCommand = new DelegateCommand<object>(RaiseProcessAndSaveInteractionRequest,
(x) => CanRaiseProcessAndSaveInteractionRequest());
ResolveAndSaveCommand.RaiseCanExecuteChanged();
ProcessAndSaveCommand.RaiseCanExecuteChanged();
OpenCaseCommand = new DelegateCommand<Case>(RiseOpenCaseInteractionRequest,
x => x != null && x.CaseId != InnerItem.CaseId);
SwitchContactNameEditModeCommand = new DelegateCommand(SwitchContactNameEditMode);
CreateNewCaseForCurrentContactCommand = new DelegateCommand(CreateNewCaseForCurrentContact);
DeleteCurrentContactCommand = new DelegateCommand(DeleteCurrentContact, () => _authContext.CheckPermission(PredefinedPermissions.CustomersDeleteCustomer));
CreateCustomerInteractionRequest = new InteractionRequest<ConditionalConfirmation>();
CommonInfoRequest = new InteractionRequest<ConditionalConfirmation>();
DisplayNameUpdateCommand = new DelegateCommand(DisplayNameUpdate);
RefreshContactOrdersPanelCommand = new DelegateCommand(RefreshContactOrdersPanel);
LoadCompletedCommand = new DelegateCommand(LoadCompleted);
DeleteCaseCommand = new DelegateCommand<string>(DeleteCase);
}