私の推測では、添付プロパティを正しく理解していません。RichTextBox の FlowDocument をビュー モデルの HTML 文字列プロパティに変換しようとしています。クラスを使用している 2 つの RichTextBox があります(このブログ投稿RichTextBoxAssistant
のおかげです)。
<RichTextBox x:Name="rtb_description"
local:RichTextBoxAssistant.BoundDocument="{Binding MyVM.Description,
ValidatesOnDataErrors=True}"/>
<RichTextBox x:Name="rtb_descriptionHowTo"
local:RichTextBoxAssistant.BoundDocument="{Binding MyVM.DescriptionHowTo,
ValidatesOnDataErrors=True}" />
私のRichTextBoxAssistant
クラスには、次の依存関係プロパティがあります。
public static readonly DependencyProperty BoundDocument =
DependencyProperty.RegisterAttached(
"BoundDocument",
typeof(string),
typeof(RichTextBoxAssistant),
new FrameworkPropertyMetadata(
null,
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
boundDocumentChanged
)
);
問題はboundDocumentChanged
、最初の RichTextBox の値を変更するとメソッドがヒットするが、 の値を変更するとヒットしrtb_description
ないことですrtb_descriptionHowTo
。テキストを変更したり、何かを行ったりするとrtb_descriptionHowTo
、 に到達しませんboundDocumentChanged
。RichTextBoxAssistant
これは静的クラスの結果ですか? RichTextBoxAssistant
複数の RichTextBoxes で使用できるように修正するにはどうすればよいですか?