This is a migrated thread and some comments may be shown as answers.

CanExecuteChanged not monitored?

8 Answers 176 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bernhard König
Top achievements
Rank 2
Bernhard König asked on 19 Jun 2012, 11:20 PM
Hi,

can it be that the TextBox control does not monitor the CanExecuteChanged of the bound ActionButtonCommand?

I can see that my code that decides if the command can be executed is called initially, but never again when I manually call RaiseCanExecuteChanged() on the command.

Don't find another reason why this could not work ...

Thanks,
Bernhard

8 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 20 Jun 2012, 02:46 PM
Hi Bernhard,

Thank you for your question.

The CanExecute logic is executed everytime before the command is executed, so everytime the button is tapped the CanExecute logic should be executed. If it isn't, I would like to ask you to prepare a small application that is illustrating the issue. However, while testing I noticed that the button doesn't change its state to disabled when CanExecute returns false. This has already been fixed and you will see the change if you download our internal build that will be available for download from the Downloads section of your account later today.

Regards,
Todor
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Bernhard König
Top achievements
Rank 2
answered on 20 Jun 2012, 02:56 PM
Hi Todor,

thanks for your response!

Is it really the case that the CanExecute logic is only executed when the button is tapped? This would explain my problem. In my case, the button is initially disabled correctly (by the initial call to the CanExecute logic which returns false), so it isn't possible to tap it as it's disabled now.

In my scenario I want to have the CanExecute-logic re-executed everytime the user enters something into a textbox. So in the Keypress-event of the textbox, I call the Command.RaiseCanExecuteChanged() method everytime. This should raise an event on the Command and then the RadTextBlock should execute the CanExecute logic again and enable (or disable) the button depending on the result without having the user to press the button.

I hope I explained it well ... else I could send you a small sample app of course!

Thanks,
Bernhard

0
Accepted
Todor
Telerik team
answered on 21 Jun 2012, 11:51 AM
Hi Bernard,

I'd like to let you know that the internal build is now available, so you can get it from the downloads section of your account. Now CanExecute is called everytime the CommandParameter (by default this is the text) is changed, so you won't need to call RaiseCanExecuteChanged.

Let me know if the internal build fixes your issue.

All the best,
Todor
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
bc3tech
Top achievements
Rank 2
answered on 01 Feb 2014, 04:47 AM
So if the parameter to ActionButtonCommand is NOT blank (eg: some other object) then how can I get the ActionButton to refresh? The object that is the parameter IS attempting to fire CanExecuteChanged but the handler is showing as 'null' which tells me it never got subscribed to.

Any hints?
0
Todor
Telerik team
answered on 05 Feb 2014, 05:32 PM
Hello Brandon,

When the parameter is changed, the ActionButton will refresh its state depending on the value returned by the command's CanExecute method. If this doesn't work correctly on your side, please send us a sample that we can use to reproduce the issue.

Let us know if you need further assistance.

Regards,
Todor
Telerik
If you want to get updates on new releases, tips and tricks and sneak peek previews directly from the developers working on the UI for Windows Phone, subscribe to the blog feed now.
0
bc3tech
Top achievements
Rank 2
answered on 05 Feb 2014, 08:14 PM
[quote]Todor said:Hello Brandon,

When the parameter is changed, the ActionButton will refresh its state depending on the value returned by the command's CanExecute method. If this doesn't work correctly on your side, please send us a sample that we can use to reproduce the issue.

Let us know if you need further assistance.

Regards,
Todor
Telerik
 
If you want to get updates on new releases, tips and tricks and sneak peek previews directly from the developers working on the UI for Windows Phone, subscribe to the blog feed now.
 
[/quote]
Sure i'll see if I can come up w/ a simple example to emulate what I was getting. If I can't then maybe it'll help me figure out what I was doing wrong at least!

I'll report back either way.
0
Todor
Telerik team
answered on 06 Feb 2014, 08:15 AM
Great!

I'm looking forward to your reply, then.

Regards,
Todor
Telerik
If you want to get updates on new releases, tips and tricks and sneak peek previews directly from the developers working on the UI for Windows Phone, subscribe to the blog feed now.
0
bc3tech
Top achievements
Rank 2
answered on 07 Feb 2014, 08:55 PM
Quick update; I built a very simple bare bones app emulating what I was trying to do (view, view model, command as property, data binding it all together) and the action button worked as expected. Guess i'll have to check out my other app a bit more closely!

thanks for the response
Tags
TextBox
Asked by
Bernhard König
Top achievements
Rank 2
Answers by
Todor
Telerik team
Bernhard König
Top achievements
Rank 2
bc3tech
Top achievements
Rank 2
Share this question
or