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

ContentTemplate example

3 Answers 148 Views
Window
This is a migrated thread and some comments may be shown as answers.
Russell Mason
Top achievements
Rank 1
Russell Mason asked on 14 Dec 2009, 10:01 PM
Hi

Do you have an example of how to set the ContentTemplate of a RadWindow? I want to have information above and below the actual Content as set by the property but when I set the ContentTemplate the actual Content disappears. I'm obviously doing something wrong.

Thanks
Russell Mason

3 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 15 Dec 2009, 01:01 PM
Hi Russell,

 Here is an example of a ContentTemplate of the RadWindow control:

<DataTemplate>
    <Grid Background="White">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
         
        <TextBlock Text="Some Header" Grid.Row="0" />
        <ContentPresenter Grid.Row="1" Content="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" />
        <TextBlock Text="Some Footer" Grid.Row="2" />
    </Grid>
</DataTemplate>


All the best,
Miroslav Nedyalkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Derek
Top achievements
Rank 1
answered on 17 Oct 2013, 12:49 PM
HI,
This is my first post so please forgive me if I do not provide enough information!  I would like to do the same thing as shown below but with the added complication of binding data.

Example ({Binding HeaderText}):
<DataTemplate>
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="{Binding HeaderText}" Grid.Row="0" />
<ContentPresenter Grid.Row="1" Content="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" />
<TextBlock Text="Some Footer" Grid.Row="2" />
</Grid>
</DataTemplate>

How is this accomplished?  My requirements are actually for a list of mulitple items as shown below:

 

<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" MaxHeight="100" MinHeight="100" MinWidth="100">
    <ItemsControl ItemsSource="{Binding NonInstructAccounts}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding [AccountNumber].TextValue}" />
                    <TextBlock Text="{Binding [AccountNameLine1].TextValue}" Margin="10,0,0,0" />
                </StackPanel>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</ScrollViewer>

0
Kalin
Telerik team
answered on 21 Oct 2013, 01:37 PM
Hi Derek,

In order to display a collection of Items you would need to set the ContentTemplate of the ContentPresenter the desired way. It should look like follows:
...
<ContentPresenter Grid.Row="1" Content="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}">
    <ContentPresenter.ContentTemplate>
        <DataTemplate>
            <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" MaxHeight="100" MinHeight="100" MinWidth="100">
                <ItemsControl ItemsSource="{Binding NonInstructAccounts}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding [AccountNumber].TextValue}" />
                                <TextBlock Text="{Binding [AccountNameLine1].TextValue}" Margin="10,0,0,0" />
                            </StackPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </ScrollViewer>
        </DataTemplate>
    </ContentPresenter.ContentTemplate>
</ContentPresenter>
...

Hope this helps. If you have any other questions let us know.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Window
Asked by
Russell Mason
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Derek
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or