![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| | |||||||
| | Vista - Enabling commands with SelectedItems |
| |
| 06-15-2007 | #1 |
| | Enabling commands with SelectedItems I'm implementing an application in the DataModel-ViewModel-View pattern and I'm having some trouble with commands bound to a listbox. What I'd like to happen is for a given command to be enabled/disabled based on the number of SelectedItems. Here's some of the relevant code so far: <StackPanel> <Button Command="{Binding Path=MyCommand}" CommandParameter="{Binding Source=ListBox1, Path=SelectedItems}" > Command </Button> <ListBox x:Name="ListBox1" ItemsSource="..."/> </StackPanel> In my code-behind I have a class derived from ICommand that implements CanExecute() and Execute(). CanExecute() is called on creation of the command and immediately before it is invoked by clicking the button, but it is not called when SelectedItems changes. I thought that CanExecute() would be called each time SelectedItems changed and should enable/disable the button as appropriate. Am I missing something? Cheers, Keith |
| My System Specs |
| 06-16-2007 | #2 |
| | Re: Enabling commands with SelectedItems Answered my own question: CanExecuteChanged must be called by the ICommand implementation. |
| My System Specs |
| 06-16-2007 | #3 |
| | Re: Enabling commands with SelectedItems Answered my own question: CanExecuteChanged must be called by the ICommand implementation. |
| My System Specs |
![]() |
| Thread Tools | |
| |
| Similar Threads for: Enabling commands with SelectedItems | ||||
| Thread | Forum | |||
| Enabling S.M.A.R.T | Software | |||
| UAC re-enabling itself? | Vista General | |||
| UAC re-enabling itself? | Vista security | |||
| Enabling fonts. | Vista performance & maintenance | |||
| enabling PAE on RC2 | Vista General | |||