Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VMs do not raise navigation methods when used in CarouselView #749

Closed
adrianknight89 opened this issue Aug 29, 2016 · 4 comments
Closed

Comments

@adrianknight89
Copy link

I'm testing out the new XF CarouselView. I wanted to display a content page as a carousel item; however, view models do not raise navigation events.

VM property:

public ObservableCollection<Page> Pages { get; set; }

In VM constructor:

Pages = new ObservableCollection<Page>
{
    new Page1 {Title = "Title1"},
    new Page2 {Title = "Title2"},
    new Page3 {Title = "Title3"},
    new Page4 {Title = "Title4"},
    new Page5 {Title = "Title5"}
};

Navigation events are called on the carousel VM but not in each individual page VM. Is this expected behavior or can we improve upon this?

@joacar
Copy link

joacar commented Aug 29, 2016

If I remember correctly the CarouselView is available as separate NuGet and not part of Xamarin.Forms. Check #650 where I think the CarouselView is discussed.

@brianlagunas
Copy link
Member

A CarouselView is not a Page, but rather a control on a Page and therefore will not receive navigation events.

@dansiegel
Copy link
Member

@adrianknight89 As mentioned CarouselView is part of a separate package so even if it made sense to do something it couldn't be supported in any of the existing packages without creating a new dependency that most people aren't using, and it would have require Prism to be in preview since the CarouselView package is only a preview currently.

I'm not going to try to get into good design vs bad design debates here, but note that because the CarouselView is a child element on a page, the CarouselView's children would be sharing the same BindingContext (ViewModel). Assuming you take care of any necessary design issues here, you can accomplish what you're looking for by implementing a behavior for the CarouselView similar to PR #712. Note that all of the events that you would need are specifically tied to the CarouselView and not the ItemsView that it derives from so you would have to implement the behavior for the CarouselView specifically.

@lock
Copy link

lock bot commented Jan 30, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants