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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Bindable SpandAdv inside DocumentAdv Object

Thread ID:

Created:

Updated:

Platform:

Replies:

127429 Nov 15,2016 02:35 PM UTC Nov 17,2016 05:50 AM UTC WPF 3
loading
Tags: SfRichTextBoxAdv
Francesco Roccamo
Asked On November 15, 2016 02:35 PM UTC

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
        Get
            Return DirectCast(GetValue(RunTextProperty), String)
        End Get
        Set
            SetValue(RunTextProperty, Value)
        End Set
    End Property

    Public Sub New()
        MyBase.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)
            spanAdv2.OnRunTextChanged(e)
        End If
    End Sub
    Private Sub OnRunTextChanged(e As DependencyPropertyChangedEventArgs)
        MyBase.Text = DirectCast(e.NewValue, String)
    End Sub
End Class
Then inside the XAML:

<DocumentAdv>
....
<ParagraphAdv>
<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?


Venkatesan Mani [Syncfusion]
Replied On 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:
https://www.syncfusion.com/kb/6233/how-to-bind-sfrichtextboxadv-contents-using-mvvm-framework

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.

Regards,
Venkatesan M.


Francesco Roccamo
Replied On 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">
    <Paragraph>
      A UIElement element may be embedded directly in flow content
      by enclosing it in a BlockUIContainer element.
    </Paragraph>
    <BlockUIContainer>
      <Button>Click me!</Button>
    </BlockUIContainer>
    <Paragraph>
      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.
    </Paragraph>
    <BlockUIContainer>
      <StackPanel>
        <Label Foreground="Blue">Choose a value:</Label>
        <ComboBox>
          <ComboBoxItem IsSelected="True">a</ComboBoxItem>
          <ComboBoxItem>b</ComboBoxItem>
          <ComboBoxItem>c</ComboBoxItem>
        </ComboBox>
        <Label Foreground ="Red">Choose a value:</Label>
        <StackPanel>
          <RadioButton>x</RadioButton>
          <RadioButton>y</RadioButton>
          <RadioButton>z</RadioButton>
        </StackPanel>
        <Label>Enter a value:</Label>
        <TextBox>
          A text editor embedded in flow content.
        </TextBox>
      </StackPanel>
    </BlockUIContainer>
  </Section>
</FlowDocument>

Is it possible to realize something like this?

Venkatesan Mani [Syncfusion]
Replied On 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

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents 

Regards,
Venkatesan M.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;