In the MainWindow.xaml, I've these:
<FlowDocumentScrollViewer x:Name="scroll" PreviewMouseDoubleClick="onSelectionChanged">
<FlowDocument x:Name="doc" FontSize="20"/>
</FlowDocumentScrollViewer>
and in MainWindow.cs these:
public partial class MainWindow : Window
{
public MainWindow() {
InitializeComponent();
for (int i = 1; i < 51; i++) {
doc.Blocks.Add(new Paragraph() {
Tag = i,
Inlines = { new Run(i +") " + "Para No. " + i) }
});
}
}
void onSelectionChanged(object sender, MouseButtonEventArgs e) {
//Here I want to access the Paragraph in which Selection's made
//var start = scroll.Selection.Start;
//var end = scroll.Selection.End;
//var range = new TextRange(start, end);
//Debug.WriteLine(range.Text);
}
}
I want to access the paragraph, where a word is selected by double clicking, to get the Tag no and the selected word's position (by splitting the text with the space).