Note that there are some explanatory texts on larger screens.

plurals
  1. POUser control with richTextBox, bindable richTextBox
    primarykey
    data
    text
    <p>I try make user control with richTextBox because I need bindable richTextbox.</p> <p>I found some solution here: <a href="https://stackoverflow.com/questions/343468/richtextbox-wpf-binding">Richtextbox wpf binding</a>.</p> <p>I would like to use solution of <strong>Arcturus</strong>. Create user control with richTextBox control and use dependency property.</p> <p>In XAML I have only richTextBox control:</p> <pre><code>&lt;UserControl x:Class="WpfApplication2.BindableRichTextBoxControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"&gt; &lt;Grid&gt; &lt;RichTextBox Name="RichTextBox" Grid.Row="0"/&gt; &lt;/Grid&gt; &lt;/UserControl&gt; </code></pre> <p>In CodeBehind:</p> <pre><code>public partial class BindableRichTextBoxControl : UserControl { public static readonly DependencyProperty DocumentProperty = DependencyProperty.Register("Document", typeof(FlowDocument), typeof(BindableRichTextBoxControl), new PropertyMetadata(OnDocumentChanged)); public FlowDocument Document { get { return (FlowDocument)GetValue(DocumentProperty); } set { SetValue(DocumentProperty, value); } } private static void OnDocumentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var control = (BindableRichTextBoxControl)d; if (e.NewValue == null) control.RichTextBox.Document=new FlowDocument(); //? control.RichTextBox.Document = document; } public BindableRichTextBoxControl() { InitializeComponent(); } } </code></pre> <p>I am little confuse with last line in OnDocumentChanged method. </p> <pre><code> control.RichTextBox.Document = document; </code></pre> <p>I can’t identify what is varibale <strong>document</strong>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload