New to Telerik UI for WPF? Download free 30-day trial

Use RadRichTextBox in Tooltip

Environment

Product Version 2019.2.618
Product RadRichTextBox for WPF

Description

To bind content to a RadRichTextBox, you need to use one of the available data providers. However, popups have their separate visual tree and name scope, so binding outside of it is not possible with ElementName/RelativeSource, due to a limitation in the framework.

Solution

To have this binding work, you can pass the data through the Content property, the value of which will serve as a DataContext to the controls that are placed in the ContentTemplate. Here is how you can achieve that for a Grid's ToolTip:

The Name is a property of the object used as a DataContext for the ToolTip.

<Grid.ToolTip> 
    <ToolTip Content="{Binding}"> 
        <ToolTip.ContentTemplate> 
            <DataTemplate> 
                <Grid> 
                    <telerik:HtmlDataProvider RichTextBox="{Binding Path=., ElementName=radRichTextBox}" Html="{Binding Path=Name}}" /> 
                    <telerik:RadRichTextBox Name="radRichTextBox"  Height="400" Width="1000" /> 
                </Grid> 
            </DataTemplate> 
        </ToolTip.ContentTemplate> 
    </ToolTip> 
</Grid.ToolTip> 

See Also

Data Providers

In this article