We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Bindable SpandAdv inside DocumentAdv Object

Hello, i would like to know if there is the possibility to bind a property to a SpanAdv inside a DocumentAdv. In order to achieve this goal, i tried to create a subclass of SpanAdv that brings a property called "RunText". But there is no way to let it work. 

Here it is my code:

Public Class SpanAdv2
    Inherits SpanAdv
    Public Property RunText() As String
            Return DirectCast(GetValue(RunTextProperty), String)
        End Get
            SetValue(RunTextProperty, Value)
        End Set
    End Property

    Public Sub New()
    End Sub
    ' Using a DependencyProperty as the backing store for RunText.  This enables animation, styling, binding, etc...
    Public Shared ReadOnly RunTextProperty As DependencyProperty = DependencyProperty.Register("RunText", GetType(String), GetType(SpanAdv2), New PropertyMetadata(String.Empty, New PropertyChangedCallback(AddressOf OnRunTextChanged)))

    Private Shared Sub OnRunTextChanged(d As DependencyObject, e As DependencyPropertyChangedEventArgs)
        If d IsNot Nothing Then
            Dim spanAdv2 As SpanAdv2 = TryCast(d, SpanAdv2)
        End If
    End Sub
    Private Sub OnRunTextChanged(e As DependencyPropertyChangedEventArgs)
        MyBase.Text = DirectCast(e.NewValue, String)
    End Sub
End Class
Then inside the XAML:

<SpanAdv2 RunText="{Binding MyProp}"/>

At runtime it gives me this error: System.Windows.Data Error: 2 :Cannot find governing FrameworkElement or FrameworkContentElement for target element.

Can you suggest me something?

3 Replies

VM Venkatesan Mani Syncfusion Team November 16, 2016 09:18 AM UTC

Hi Francesco,

Thank you for using Syncfusion products.

The SpanAdv may be edited or removed while editing the content in SfRichTextBoxAdv. Hence it is not advisable to add binding for the properties of SpanAdv.

If your requirement is to bind the contents of SfRichTextBoxAdv similar to TextBox.Text property, you can achieve it by writing an extension class for SfRichTextBoxAdv. Please check our online KB from following link.

KB link:

If you provide more information about the scenario you wish to bind Text property? So that we can analyze further and provide you the appropriate solution at the earliest.

Venkatesan M.

MO Main Office Srl November 16, 2016 02:24 PM UTC

Hello and thanks for the support, i wish to implement an alternative to the InlineUIContainer property of the standard FlowDocument.

I need to embed a binded UIcontrol inside a SfDocument.

Here an example:
<FlowDocument ColumnWidth="400">
  <Section Background="GhostWhite">
      A UIElement element may be embedded directly in flow content
      by enclosing it in a BlockUIContainer element.
      <Button>Click me!</Button>
      The BlockUIContainer element may host no more than one top-level
      UIElement.  However, other UIElements may be nested within the
      UIElement contained by an BlockUIContainer element.  For example,
      a StackPanel can be used to host multiple UIElement elements within
      a BlockUIContainer element.
        <Label Foreground="Blue">Choose a value:</Label>
          <ComboBoxItem IsSelected="True">a</ComboBoxItem>
        <Label Foreground ="Red">Choose a value:</Label>
        <Label>Enter a value:</Label>
          A text editor embedded in flow content.

Is it possible to realize something like this?

VM Venkatesan Mani Syncfusion Team November 17, 2016 05:50 AM UTC

Hi Francesco,

Thank you for your update.

At present there is no support to embed the UIControl in SfRichTextBoxAdv document. A support incident to track the status of this feature has been created under your account. Please log on to our support website to check for further updates


Venkatesan M.

Live Chat Icon For mobile
Up arrow icon