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

Readonly Header and Footer

2 Answers 113 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Nicolas
Top achievements
Rank 1
Nicolas asked on 13 Sep 2011, 03:57 PM
Hi,
Is there a way to set header and footer as readonly ?
I need this functionnality because I set header and footer in code-behind and I don't want user to edit them.
I have already remove the "Header & Footer" tab but we can always double-click to change header or footer content.

Thanks.

2 Answers, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 16 Sep 2011, 06:02 PM
Hi Nicolas,
The first thing you have to do is to disable the command in the context menu which shows on right click over the header/footer. This can be done by applying custom ContextMenuContentBuilder (as demonstrated in the attached project).
The second step could be to block the clicks which activate the header/footer edit mode by adding an additional rectangle to the Header/Footer presenter template:
<telerik:RadRichTextBox Name="radRichTextBox" Grid.Row="2" LayoutMode="Paged">
    <telerik:RadRichTextBox.Resources>
        <Style TargetType="telerik:HeaderPresenter">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Grid>
                            <StackPanel x:Name="WrappingStackPanel">
                                <telerik:RadRichTextBox x:Name="BodyRichTextBox"
                                    AllowScaling="False"
                                    BorderThickness="0"
                                    Background="Transparent"
                                    Margin="0"
                                    Padding="0"
                                    MouseOverBorderThickness="0"/>
                            </StackPanel>
                            <Rectangle x:Name="FadingRectangle" Fill="#80FFFFFF" />
                            <Rectangle Fill="#00FFFFFF" Margin="-1" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="telerik:FooterPresenter">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Grid>
                            <StackPanel x:Name="WrappingStackPanel">
                                <telerik:RadRichTextBox x:Name="BodyRichTextBox"
                                    AllowScaling="False"
                                    BorderThickness="0"
                                    Background="Transparent"
                                    Margin="0"
                                    Padding="0"
                                    MouseOverBorderThickness="0"/>
                            </StackPanel>
                            <Rectangle x:Name="FadingRectangle" Fill="#80FFFFFF" />
                            <Rectangle Fill="#00FFFFFF" Margin="-1" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </telerik:RadRichTextBox.Resources>
</telerik:RadRichTextBox>
This can be examined in the attached project too.

Don't hesitate to contact us if you have other questions.

All the best,
Boby
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Nicolas
Top achievements
Rank 1
answered on 21 Sep 2011, 04:56 PM
It work perfectly, thanks.
Tags
RichTextBox
Asked by
Nicolas
Top achievements
Rank 1
Answers by
Boby
Telerik team
Nicolas
Top achievements
Rank 1
Share this question
or