Content Page in SlideView?

4 posts, 0 answers
  1. Rodney
    Rodney avatar
    4 posts
    Member since:
    Jan 2014

    Posted 06 Nov 2018 Link to this post

    Is it possible to have a Content Page inside a SlideView?

    I have a SlideView with three ContentViews. each has Xamarin Forms controls on them. I need to reuse the code on one of the content views. What's the best way to do that? I have a page which lists items. Some of the items need to go to this ContentView and other items need to go to a new page with a copy of this ContentView. How do I make the best reuse of this code? 

  2. Lance | Technical Support Engineer, Principal
    Admin
    Lance | Technical Support Engineer, Principal avatar
    1022 posts

    Posted 06 Nov 2018 Link to this post

    Hello Rodney,

    It is not possible to use a ContentPage in the place where a ContentView type is required.

    Ultimately, to answer your question, the best way to reuse a ContentView content is to just define that ContentView as a File (Visual Studio  > Add > New Item > ContentView). Then, you can even use multiple instances of that ContentView in the same SlideView. 

    For example, let's say you named the ContentView file "MyView", you can define the SlideView as:

    <telerikPrimitives:RadSlideView x:Name="slideView">
        <telerikPrimitives:RadSlideView.ItemsSource>
            <x:Array Type="{x:Type ContentView}">
                <local:MyView/>
                <local:MyView/>
                <local:MyView/>
            </x:Array>
        </telerikPrimitives:RadSlideView.ItemsSource>
    </telerikPrimitives:RadSlideView>

    For a runnable demo project that takes this approach, see my forum post reply from earlier today.

    Regards,
    Lance | Tech Support Engineer, Sr.
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Rodney
    Rodney avatar
    4 posts
    Member since:
    Jan 2014

    Posted 08 Nov 2018 in reply to Lance | Technical Support Engineer, Principal Link to this post

    How would you pass data to a child Content View? 

    Let say that this page has an particular ID you want to pass into the child content view. 

    how would you do something like this:

    <local:MyView Channel="{Binding channelId} />

    or any other properties? (May be a dumb questions but I"m new to Xamarin and Telerik)

    is it possible?

     

     

  4. Lance | Technical Support Engineer, Principal
    Admin
    Lance | Technical Support Engineer, Principal avatar
    1022 posts

    Posted 08 Nov 2018 Link to this post

    Hello Rodeny,

    You can't do this because the control is not in a databound mode. Those  ContentViews do not have any scope to the ContentPage instance. If you follow the approach I've shared with you in this forum post, then you can use data binding in the Datatemplate's element.

    You would "pass" the ID to the content via the bound object, in this case the MySlideViewItem object.

    Regards,
    Lance | Tech Support Engineer, Sr.
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top