This is a migrated thread and some comments may be shown as answers.

Binding DataForm inside a TabControl ContentTemplate

2 Answers 161 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Mats
Top achievements
Rank 1
Mats asked on 05 May 2011, 03:23 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 09 May 2011, 10:34 AM
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
0
Mats
Top achievements
Rank 1
answered on 09 May 2011, 11:52 AM
Great! That was exactly what I needed.

Thanks!
Tags
DataForm
Asked by
Mats
Top achievements
Rank 1
Answers by
Maya
Telerik team
Mats
Top achievements
Rank 1
Share this question
or