RichTextBox editor determine if selection is image
I have an editor similar to the one described here:
http://msdn.microsoft.com/en-us/library/ff426926(v=vs.95).aspx
I am trying to determine if the user's selection in the rtb is an image so they can edit the properties without deleting it and re-adding it.
I have already implemented this feature for a hyperlink with this code:
I am hoping to be able to do the same thing with an image, but I am not successful when I try the same approach.
I have an editor similar to the one described here:
http://msdn.microsoft.com/en-us/library/ff426926(v=vs.95).aspx
I am trying to determine if the user's selection in the rtb is an image so they can edit the properties without deleting it and re-adding it.
I have already implemented this feature for a hyperlink with this code:
private void RichTextBoxEditor_SelectionChanged(object sender, RoutedEventArgs e) { Inline parent = this.RichTextBoxEditor.Selection.Start.Parent as Inline; if (parent != null) { Hyperlink hyperlink = parent.ElementStart.Parent as Hyperlink; if (hyperlink == null) { this.tbUrlEditor.Visibility = Visibility.Collapsed; } else { this.tbUrlEditor.Visibility = Visibility.Visible; this.tbUrlEditor.Text = hyperlink.NavigateUri.ToString(); } } }So, when the user's caret or selection is a hyperlink, they are able to edit its Uri in my TextBox "tbUrlEditor".
I am hoping to be able to do the same thing with an image, but I am not successful when I try the same approach.
Answers & Comments...
Answer: 1
You can try to set a breakpoint at ( parent.ElementStart.Parent as Image) to find if there is retured an Image or not, it there is, you may try get the image's size or name.
Best Regards,
Answer: 1
Hi bherdrick,
bherdrick
So, when the user's caret or selection is a hyperlink, they are able to edit its Uri in my TextBox "tbUrlEditor".
I am hoping to be able to do the same thing with an image, but I am not successful when I try the same approach.
You can try to set a breakpoint at ( parent.ElementStart.Parent as Image) to find if there is retured an Image or not, it there is, you may try get the image's size or name.
Best Regards,
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog