Enabling Inline Controls in a FlowDocument

I have a FlowDocument in a standard WPF application window where I have text, and in this text some hyperlinks and buttons.

The problem is that if I put this FlowDocument inside except the FlowDocumentPageViewer, the hyperlinks and buttons are disabled (grayed out).

<FlowDocumentScrollViewer> <FlowDocument> <Paragraph> Hello, World! <Hyperlink NavigateUri="some-uri">click me</Hyperlink> <Button Click="myButton_Click" Content="Click me too!" /> </Paragraph> </FlowDocument> </FlowDocumentScrollViewer> 

The above will work and the link will be available for viewing. However, I do not need the full pageviewer function, since it displays navigation buttons (back / forward), and also has strange column behavior.

I want this in a simple FlowDocumentScrollViewer (or anything else that just displays text without additional fuzz).

EDIT: These are not just problems with hyperlinks. Any control such as Button, ListBox, ComboBox - everything the user can interact with is gray, regardless of the IsEnabled properties, if the FlowDocument is inside the FlowDocumentScrollViewer.

EDIT2: Well, that must have been a mistake or something on my part, because I finished rewriting the controls, and now it works. I suppose there was some kind if IsEnabled = False somewhere in the visual tree that caused this.

+4
source share
2 answers

I use FlowDocumentScrollViewer for my window:

 <FlowDocumentScrollViewer VerticalScrollBarVisibility="Auto"> <FlowDocument> <Paragraph> <!-- ... --> 

I do not have any controls or issues that you mention.

+2
source

I wonder if you are doing something?

 <TextBlock> <Hyperlink> <Run Text="Test link"/> </Hyperlink > 

 </TextBlock> 
0
source

Source: https://habr.com/ru/post/1276794/


All Articles