Questions tagged [delegatecommand]

WPF design pattern that provides a generic reusable implementation of ICommand. Versions of this object can be found in the versions of Microsoft Prism.

95 questions
4
votes
3 answers

DelegateCommand throws "Specified cast is not valid"

I want to use a PRISM delegatecommand with a bool as parameter. This is the relevant code: public class ChartViewModel : BindableBase { public DelegateCommand ChangeZoomPanCommand { get; private set; } private bool isInRealtimeMode; …
Jef Patat
  • 909
  • 9
  • 22
4
votes
2 answers

WPF ToggleButton and DelegateCommand

Is there a way to determine if a ToggleButton is Checked/Unchecked via DelegateCommands? TIA, mike XAML code below. I'm using ItemsControl and binding to a collection. I'm basically wanting a way to get the toggle status of each button when it's…
Mike
  • 41
  • 1
  • 3
3
votes
1 answer

Is a DelegateCommand the same as an "Attached Behavior"?

I have been using the DelegateCommand found in the MVVM Visual Studio template at CodePlex. This works very nicely for having Views be able to execute commands on their ViewModel. I read somewhere that in MVVM "attached behaviors" should be used. As…
Edward Tanguay
  • 176,854
  • 291
  • 683
  • 1,015
3
votes
1 answer

How is the standard DelegateCommand CanExecuteChanged event fired in Silverlight?

I want to re-trigger the canExecute functionality from a DelegateCommand after some modifications have been made by the user. How do I do this?
Nathan Tregillus
  • 5,248
  • 2
  • 43
  • 73
3
votes
1 answer

Why do Prism DelegateCommands sometimes cause threading exceptions?

The example below uses the DelegateCommand from Prism 6.1, but I've produced the same issue with 5.0. Using the following view-model (view omitted, just consists of 2 buttons): public class MainWindowViewModel { public DelegateCommand…
Tony Harrison
  • 68
  • 2
  • 6
3
votes
1 answer

Raise CanExecuteChanged when the model changes

In my ViewModel I have an ObservableCollection of Person objects (that implement INotifyPropertyChanged) and a SelectedPerson property. These are bound to a ListBox in my view. There is also the following Prism DelegateCommand in my…
Kurren
  • 760
  • 7
  • 18
2
votes
3 answers

Working with DelegateCommand's CanExecute action

I've a ViewModel class like this in a Prism / WPF project. public class ContentViewModel : ViewModelBase, IContentViewModel { public ContentViewModel(IPersonService personService) { Person = personService.GetPerson(); …
Raj
  • 4,212
  • 11
  • 56
  • 73
2
votes
3 answers

Invalid data in TextBox -- How to disable my command buttons?

Basically I have the following situation:
michael
  • 13,854
  • 24
  • 84
  • 167
2
votes
0 answers

Associate a keyboard shortcut with a DelegateCommand in WPF?

I am using Prism and have a CompositeCommand in an ApplicationCommands.cs class: public CompositeCommand ShowSourceFormattingCommand { get; } = new CompositeCommand(true); I have a DelegateCommand registered to this CompositeCommand: public…
Sheridan
  • 64,785
  • 21
  • 128
  • 175
2
votes
1 answer

PRISM (ViewModel): Ensure a command does not get executed multiple times simultaneously

I'm trying to disable frequent user gestures so the same command does not get executed multiple times simultaneously. private readonly SemaphoreSlim _semaphoreSlim = new SemaphoreSlim(1); public bool MyCommandCanExecute { get; set; } =…
Mark13426
  • 2,429
  • 4
  • 35
  • 72
2
votes
1 answer

CompositeCommand wait for all Child Commands to complete

In my Dialog I have a TabControl with ChildViews using Prism. For the Save Commands I'm using a CompositeCommand. Everything works as expected. The only problem is: I want to wait for every ChildViewModel to complete the async Save process and then…
Johannes Wanzek
  • 2,717
  • 2
  • 27
  • 42
2
votes
2 answers

WPF: CanExecute is Always Disabled

I've got a TextBox for the user to enter a string, and an "Add" button to perform some tasks with the value. I added a CanExecute method to the DelegateCommand so that the button would only work when there was text in the box. However, it's…
Nightmare Games
  • 1,922
  • 5
  • 23
  • 45
2
votes
1 answer

Can't subscribe to DelegateCommand.CanExecuteChanged

I have two ViewModels and one contains another. The inner one has a Microsoft.Practices.Prism.Commands.DelegateCommand called PrintCommand. It is desirable to subscribe to the CanExecuteChanged event of this command. This part is implemented as…
dmigo
  • 2,271
  • 3
  • 32
  • 49
2
votes
1 answer

Why can't I bind my Silverlight Button Click to a Prism DelegateCommand

I have a simple test app in Silverlight 3 and Prism where I'm just trying to bind a button Click to a simple command I have created on a view model. This is a test app just to get commanding working. When I run it I get a binding error telling me…
Michael
  • 41
  • 4
2
votes
1 answer

DelegateCommand vs RoutedCommand and gestures - WPF

is there anyway for DelegateCommand's to support gestures when building a composite WPF app? I'm trying to create a command used by a MenuItem and also a Button, which can be accessed through a keyboard shortcut, but which sits inside a class in a…
devdigital
  • 33,472
  • 8
  • 93
  • 117