I can attach a mouse-click event to a TextBlock object like this:
TextBlock tb = new TextBlock();
tb.Text = "click here";
tb.MouseLeftButtonDown += new MouseButtonEventHandler(tb_MouseLeftButtonDown);
But I would like to instead attach the mouse-click to individual Run objects inside the TextBlock object so that various parts of the TextBlock are clickable, like this:
TextBlock tb = new TextBlock();
tb.FontSize = 15;
Run run1 = new Run();
run1.Text = "This should be clickable";
run1.MouseLeftButtonDown += new MouseButtonEventHandler(run1_MouseLeftButtonDown);
Run run2 = new Run();
run2.Text = " but not this.";
tb.Inlines.Add(run1);
tb.Inlines.Add(run2);
How can I attach a mouse event to a Run object?