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?