Wpf – XBAP Select Page Text

wpfxbap

Took over an XBAP browser application. XBAP was chosen over HTML for some clipboard actions, and the application was well received.

Recently a user asked why he cannot select screen text (and copy to clipboard) like a regular HTML page. Wow, didn't see that coming, but totally understand where they are coming from.

The XBAP application has many forms that have labels and textblocks of information. The user needs to select and copy this text.

Do I have any options? I don't want to move the data to textboxes.

Best Answer

AFAIK, you can't make labels/textblocks selectable. It's an old Windows UI tradition. You can either style textboxes like labels:

<Style x:Key="FauxLabel" TargetType="{x:Type TextBox}"> 
    <Setter Property="Background" Value="Transparent"/> 
    <Setter Property="BorderBrush" Value="{x:Null}"/> 
    <Setter Property="BorderThickness" Value="4"/> 
    <Setter Property="IsTabStop" Value="False"/> 
</Style>

or you can change part of your UI to the WebBrowser control and provide it with proper HTML. You lose fine-grained data bindings in that case, you'll have to reload that whole page on every data change, and it might not be suitable for every scenario. But usually copy/paste is needed for some "reporting" part, then you can make this report in the HTML format...

HTH. I'd like to know better ways myself =(

Related Topic