Binding DataForm inside a TabControl ContentTemplate

3 posts, 1 answers
  1. Mats
    Mats avatar
    10 posts
    Member since:
    Mar 2011

    Posted 05 May 2011 Link to this post

    Hi!
    I'm creating a project using Prism 4 and have a view where I edit data in a RadDataForm but I'm having problems getting the data bound.

    Inside my view I have a RadFluidContentControl that contains a RadTabControl inside the Large-template. The tabcontrol is bound to a list of objects where each object gets a tab.
    Inside the ContentTemplate I then have a RadDataForm that should display the data for the object that is shown in the tab.

    If I add a TextBlock next to my RadDataForm I can bind it to the object but nothing is showing up in the dataform.

    Here is my XAML (sorry that's quite a lot...):
    <UserControl.Resources>
        <DataTemplate x:Key="TabHeaderTemplate">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Namn}"/>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="HuvudmanFormTemplate">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition/>           
                    <RowDefinition/>           
                    <RowDefinition/>           
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <telerik:DataFormDataField Label="Förnamn"
                                           DataMemberBinding="{Binding Namn, Mode=TwoWay}" />
                <telerik:DataFormDataField Label="Efternamn"
                                           Grid.Column="1" DataMemberBinding="{Binding Efternamn, Mode=TwoWay}" />
                <telerik:DataFormDataField Label="Personnummer"
                                           Grid.Row="1" DataMemberBinding="{Binding Personnummer, Mode=TwoWay}" />
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="TabItemTemplate">
            <telerik:RadDataForm x:Name="HuvudmanDataForm"
                                    ReadOnlyTemplate="{StaticResource HuvudmanFormTemplate}"
                                    EditTemplate="{StaticResource HuvudmanFormTemplate}"
                                    NewItemTemplate="{StaticResource HuvudmanFormTemplate}"
                                    AutoGenerateFields="False" />                                   
        </DataTemplate>
    </UserControl.Resources>
    <telerik:RadFluidContentControl x:Name="FluidContentControl" ContentChangeMode="Manual" State="Large">
        <telerik:RadFluidContentControl.SmallContent>
            <StackPanel Orientation="Vertical">
                <TextBlock Text="Huvudmän" Margin="2" FontWeight="Bold"/>
                <ItemsControl ItemsSource="{Binding Akt.Huvudmän}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Namn}" Margin="2, 0, 2, 2"/>
                        </DataTemplate>
                        </ItemsControl.ItemTemplate>
                </ItemsControl>
            </StackPanel>
        </telerik:RadFluidContentControl.SmallContent>
        <telerik:RadFluidContentControl.LargeContent>
            <telerik:RadTabControl ItemTemplate="{StaticResource TabHeaderTemplate}"
                                    ContentTemplate="{StaticResource TabItemTemplate}"
                                    ItemsSource="{Binding Akt.Huvudmän}">
            </telerik:RadTabControl>
        </telerik:RadFluidContentControl.LargeContent>
    </telerik:RadFluidContentControl>
  2. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 09 May 2011 Link to this post

    Hi Mats,

    You need to bind the CurrentItem of the RadDataForm:

    <telerik:RadDataForm x:Name="HuvudmanDataForm"
                                     CurrentItem="{Binding}"
                                     ReadOnlyTemplate="{StaticResource HuvudmanFormTemplate}"
                                     EditTemplate="{StaticResource HuvudmanFormTemplate}"
                                     NewItemTemplate="{StaticResource HuvudmanFormTemplate}"
                                     AutoGenerateFields="False" />

     

    All the best,
    Maya
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Mats
    Mats avatar
    10 posts
    Member since:
    Mar 2011

    Posted 09 May 2011 Link to this post

    Great! That was exactly what I needed.

    Thanks!
Back to Top