开发者

Does the FlowDocument contain any user text?

开发者 https://www.devze.com 2023-01-29 01:24 出处:网络
How can you tell if a FlowDocument contains any text that the user typed in or not? I have an application that auto-commits changes for each screen. I want to know if the FlowDocument obtained from a

How can you tell if a FlowDocument contains any text that the user typed in or not?

I have an application that auto-commits changes for each screen. I want to know if the FlowDocument obtained from a RichTextBox contains any user input or if it is blank. I convert the FlowDocument to binary xaml and commit it to db. If the FlowDocument contains no user text then I do not want to add a new FlowDocument to the db.

I don't want to parse the xaml to check if开发者_JAVA百科 there is any user text.


The way to do this is:

var range = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd);
if (!range.IsEmpty)
{
    // commit changes
}
0

精彩评论

暂无评论...
验证码 换一张
取 消