Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Commands in the Xamarin forms demos will not fire when added to the details page #58

Closed
ghost opened this issue Oct 19, 2016 · 16 comments
Closed

Comments

@ghost
Copy link

ghost commented Oct 19, 2016

To help us fix your issue, please provide the information in the below template.

Note: There is often little we can do without a minimal reproducible sample of the issue, so please provide that in a standalone git repository and link it here.

Please only file bugs verified on latest version of MvvmCross and stable Xamarin tools

Steps to reproduce

  1. Open the Xamarin forms example xaml or c# version
  2. Add a command to the todoviewmodel
  3. Add button on the todopage, make sure you setup the command binding.
  4. Run sample , click the new button

Expected behavior

Commands should fire like they do with the rest of mvvmcross

Actual behavior

and does not fire

Configuration

Version: 4.x

Platform: iOS/Android/Windows UWP

All platforms . iOS, android and uwp

@Cheesebaron
Copy link
Member

Please provide a description of how exactly you add the command binding

@ghost
Copy link
Author

ghost commented Oct 19, 2016

C#

goButton.SetBinding(Button.CommandProperty, new Binding("NavigateToReminder"));

XAML:

<Button Text="Open Reminder page" Command="{Binding NavigateToReminder}"/>

ViewModel command:

 public ICommand NavigateToReminder
        {
            get
            {
                               //code does not get this far as command not firing
                return new MvxCommand(async () =>
                {
                    //code does not get this far as command not firing
                });
            }
        }

@Cheesebaron
Copy link
Member

I've formatted your post. Also there is a MvxAsyncCommand for async operations which you might want to use instead.

Will take a look if I can reproduce your issue.

@ghost
Copy link
Author

ghost commented Oct 19, 2016

MasterDetailPage-MvvmCross-master 4.zip

Attached example with code aboved added to the todolistpage & todolistviewmodel.

really appreciate if you can help resolve as this is a blocker for us moving forward.

@Cheesebaron
Copy link
Member

Your sample uses unsupported and outdated nuget packages. Please update them to non-HotTuna.

Anyways. When navigating to the TodoListPage, and checking the BindingContext in OnAppearing, its BindingContext is MainViewModel and not TodoListViewModel. This is your problem.

Why this is the case, I have no idea. At least you now know what is going on...

@ghost
Copy link
Author

ghost commented Oct 20, 2016

Sample is directly from the Xamarin mvvmcross forms git repository.

Hence I think the issue is in the mvvmcross forms demo the team provided with mvvmcross forms.

@ghost
Copy link
Author

ghost commented Oct 20, 2016

Do you know who the mvvmcross forms owners is, maybe they can ahead some light on the issue.

Looks like all the detail view models are bound to the mainviewmodel.

Alternatively, how to force binding it to correct one after the fact. From what I recall there is a way to bind a page to multiple viewmodels

@Cheesebaron
Copy link
Member

What is the link for that sample? I dunno who submitted it, a git blame could maybe reveal something.

@ghost
Copy link
Author

ghost commented Oct 20, 2016

Do you by any chance have another example where masterdetail is used with Xamarin forms version of mvvmcross .
I like the examples on this Git location but no master detail example .

That will solve it for us

@ghost
Copy link
Author

ghost commented Oct 20, 2016

@ghost
Copy link
Author

ghost commented Oct 20, 2016

Apologies : here is the MVVM Cross forms one :https://github.com/robinmj/MasterDetailPage-MvvmCross

@Cheesebaron
Copy link
Member

Which is not an official source. You could try ask the author of the sample. I don't think we have a sample showing MasterDetailPage. A PR showing this would be appreciated.

@farlop
Copy link

farlop commented Nov 7, 2016

Hi! I'm working on a way to use a MasterDetailPage with MvxForms using a custom Presenter. I think that I could provide a PR with implementation and an example. Do you agree with this?

@Cheesebaron
Copy link
Member

PRs are welcome.

@farlop
Copy link

farlop commented Nov 8, 2016

OK, The PR is live now #60 Please check it to see if everything is fine.

@ghost
Copy link
Author

ghost commented Nov 21, 2016

When can PR #60 be merged and pushed to nuget store.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants