Use DataForm with TabView

2 posts, 0 answers
  1. Vikram
    Vikram avatar
    1 posts
    Member since:
    Jun 2016

    Posted 06 Feb 2018 Link to this post

    Is this currently possible, and if so how? 

     

    I assumed I could Create the RadTabView, and for each of my tabs have a separate dataform, and just create code like this?

     

            <telerikInput:RadDataForm.Source>
                <local:SourceItem />
            </telerikInput:RadDataForm.Source>
        </telerikInput:RadDataForm>

     

    However, my compiler errors out saying 'local' is an underclared prefix.

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

    Posted 08 Feb 2018 Link to this post

    Hi Vikram,

    In that context local: means the namespace of where the SourceItem class is. You'd need to add an xmlns to the page pointing to the "local" namespace.

    Example
    Let's say as an example, your project namespace is "MyProject" and you have a folder named "Models". IN the Models folder you have a class named "Student".

    This is what it would look like if you wanted to use the RadDataForm for Student:

        x:Class="MyProject"
        xmlns:input="clr-namespace:Telerik.XamarinForms.Input;assembly=Telerik.XamarinForms.Input"
        xmlns:local="clr-namespace:MyProject.Models;assembly=MyProject">
     
        <Grid>
            <input:RadDataForm>
                <input:RadDataForm.Source>
                    <local:Student/>
                <input:RadDataForm.Source>
            </input:RadDataForm>
                
        </Grid>
    </ContentPage>


    You can name that namespace whatever you want. In fact a more appropriate xmlns for the Models folder would be "xmlns:models"


        x:Class="MyProject"
        xmlns:input="clr-namespace:Telerik.XamarinForms.Input;assembly=Telerik.XamarinForms.Input"
        xmlns:models="clr-namespace:MyProject.Models;assembly=MyProject">
      
        <Grid>
            <input:RadDataForm>
                <input:RadDataForm.Source>
                    <models:Student/>
                <input:RadDataForm.Source>
            </input:RadDataForm>
                 
        </Grid>
    </ContentPage>


    Code Behind

    If you're not familiar with XAML and how define xmlns, you can set the Source property of the DataForm in the code behind:

    <input:RadDataForm x:Name="myDataForm1">
        <input:RadDataForm.Source>
            <models:Student/>
        <input:RadDataForm.Source>
    </input:RadDataForm>

    myDataForm.Source = new Student();


    View Model

    Lastly, you can also data bind the Source property:

    <input:RadDataForm Source="{Binding SelectedStudent}" />

    and in the view model:

    public class ViewModel
    {
        public Student SelectedStudent { get; set; }
    }



    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