CanExecuteChanged not monitored?

9 posts, 1 answers
  1. Bernhard König
    Bernhard König avatar
    78 posts
    Member since:
    Nov 2009

    Posted 19 Jun 2012 Link to this post

    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
  2. Todor
    Admin
    Todor avatar
    778 posts

    Posted 20 Jun 2012 Link to this post

    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 >>

  3. DevCraft banner
  4. Bernhard König
    Bernhard König avatar
    78 posts
    Member since:
    Nov 2009

    Posted 20 Jun 2012 Link to this post

    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

  5. Answer
    Todor
    Admin
    Todor avatar
    778 posts

    Posted 21 Jun 2012 Link to this post

    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 >>

  6. bc3tech
    bc3tech avatar
    14 posts
    Member since:
    Oct 2011

    Posted 31 Jan 2014 Link to this post

    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?
  7. Todor
    Admin
    Todor avatar
    778 posts

    Posted 05 Feb 2014 Link to this post

    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.
  8. bc3tech
    bc3tech avatar
    14 posts
    Member since:
    Oct 2011

    Posted 05 Feb 2014 in reply to Todor Link to this post

    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.
     

    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.
  9. Todor
    Admin
    Todor avatar
    778 posts

    Posted 06 Feb 2014 Link to this post

    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.
  10. bc3tech
    bc3tech avatar
    14 posts
    Member since:
    Oct 2011

    Posted 07 Feb 2014 in reply to Todor Link to this post

    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
Back to Top
DevCraft banner