![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | 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![]() |
| | #2 (permalink) |
| Guest | Re: Enabling commands with SelectedItems Answered my own question: CanExecuteChanged must be called by the ICommand implementation. |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Enabling commands with SelectedItems Answered my own question: CanExecuteChanged must be called by the ICommand implementation. |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| UAC re-enabling itself? | void.no.spam.com | Vista General | 3 | 05-27-2008 03:18 PM |
| UAC re-enabling itself? | void.no.spam.com | Vista security | 3 | 05-27-2008 03:18 PM |
| Enabling Fonts. | louie | Vista performance & maintenance | 0 | 11-14-2007 11:28 PM |
| enabling PAE on RC2 | Tim Draper | Vista General | 3 | 11-18-2006 05:05 AM |
| enabling right click | =?Utf-8?B?ZmphY2s=?= | Vista General | 0 | 09-17-2006 07:37 AM |