0

I have a windows phone 8 silverlight application and I'm using MVVM Light RelayCommands bound to the items of a LongListSelector.

The RelayCommands are declared like this

    private RelayCommand _goToDetailsCommand;
    public RelayCommand GoToDetailsCommand
    {
        get
        {
            return _goToDetailsCommand ?? (_goToDetailsCommand = new RelayCommand(ExecuteGoToDetailsCommand, () => !SessionVM.IsLoading));
        }
    }

My problem is that according to the CanExecute of the RelayCommands the UI is Disabled or Enabled (which is the default behavior). Can I opt out of that behavior and still use the CanExecute of the RelayCommand??

Corcus
  • 1,070
  • 7
  • 25
  • Why would you use it otherwise? –  Jul 15 '15 at 15:32
  • @Will The reasons I want to get rid of the effect is two fold. 1) according to the design of the app the items should never appear disabled. 2) Sometimes it causes a LayoutCycleException – Corcus Jul 15 '15 at 15:37
  • Okay, but that's the only (normal) use of `CanExecute`. What are you using it for? See, for me, I'd just `x => true` that sucker so it's always true, then use whatever would normally go in there elsewhere. Sounds like you're wanting to leave it so you can use it elsewhere, but not in the UI. It don't make no sense. –  Jul 15 '15 at 15:39
  • @Will At the moment that's pretty much what I'm doing, in the commands where the problem arrises. However everywhere else in my application i use the CanExecute so I wanted to have more consistent code. – Corcus Jul 15 '15 at 15:41
  • 1
    So... you want a helmet because you're uniformly hitting things with your hammer, including your head? Hit the nails with the hammer, and when you don't need to hit something, don't worry about an inconsistent use of your tool. Use the tools the way they were designed. –  Jul 15 '15 at 15:43
  • 1
    @Will That's a pretty graphic way of putting it but yes :) . – Corcus Jul 15 '15 at 15:51

0 Answers0