Wpf 将Richtextbox第一行与文本块绑定
如何将TextBlock数据绑定到richtextbox的第一行 提前感谢。Wpf 将Richtextbox第一行与文本块绑定,wpf,Wpf,如何将TextBlock数据绑定到richtextbox的第一行 提前感谢。 确保在代码中设置INotify或DependencyProperty 设置数据上下文 XAML 依赖属性 您可以在运行时执行同样的操作吗?无法将flowdocument直接添加到rtb。无法在“Run”类型的“Text”属性上设置“Binding”。只能对DependencyObject的DependencyProperty设置“绑定”。 <FlowDocument> <Paragraph&
- 确保在代码中设置INotify或DependencyProperty
- 设置数据上下文
您可以在运行时执行同样的操作吗?无法将flowdocument直接添加到rtb。无法在“Run”类型的“Text”属性上设置“Binding”。只能对DependencyObject的DependencyProperty设置“绑定”。
<FlowDocument>
<Paragraph>
<TextBlock Text="{Binding FirstLine}"/>
</Paragraph>
</FlowDocument>
DataContext = this;
public static readonly DependencyProperty FirstLineProperty =
DependencyProperty.Register("FirstLine", typeof(string), typeof(CLASS));
public string FirstLine
{
get { return (string)GetValue(FirstLineProperty); }
set { SetValue(FirstLineProperty, value); }
}