Reputation: 2204
When displaying FlowDocument
in WPF, how do I disable the right-click context menu of the FlowDocumentScrollViewer
, FlowDocumentPageViewer
, or FlowDocumentReader
?
I'd like a pure-XAML solution that can be used in a style, not one that requires a code-behind.
Upvotes: 2
Views: 273
Reputation: 1557
You can use ContextMenuService.IsEnabled
property.
<FlowDocumentPageViewer ContextMenuService.IsEnabled="False" />
Or set context menu to null using {x:Null}
markup extension.
<FlowDocumentPageViewer ContextMenu="{x:Null}" />
I personally prefer first one because is more readable.
Above methods doesn't work for FlowDocumentReader
, try using this:
<FlowDocumentReader>
<FlowDocument>
<FlowDocument.ContextMenu>
<ContextMenu Visibility="Collapsed" />
</FlowDocument.ContextMenu>
</FlowDocument>
</FlowDocumentReader>
Upvotes: 1