Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Copy TextBlock from SilverLight web application RSS

4 replies

Last post Sep 28, 2008 10:23 AM by GearWorld

(0)
  • GearWorld

    GearWorld

    Participant

    1784 Points

    2078 Posts

    Copy TextBlock from SilverLight web application

    Sep 27, 2008 12:25 AM | LINK

    A good feature would be to be able to copy TextBlock from SilverLight web site.  This is a very comon task when you see text, and want to search for it on the web or take a text because you don't want to retype it in an email or anything like that

  • lingbing

    lingbing

    Contributor

    2249 Points

    406 Posts

    Re: Copy TextBlock from SilverLight web application

    Sep 27, 2008 02:33 AM | LINK

    If you want the text to be copied, use textbox instead of textblock, and if you don't want to user edit the text, set the textbox's isreadonly property as true.

    Ling Bing
    Bei Jing University of Aeronautics and Astronautics
    Bei Jing, China
  • GearWorld

    GearWorld

    Participant

    1784 Points

    2078 Posts

    Re: Copy TextBlock from SilverLight web application

    Sep 27, 2008 03:58 PM | LINK

    I see.  :)  Nice trick.  But does it looks like a label, with no border and no frame ?

     

  • lingbing

    lingbing

    Contributor

    2249 Points

    406 Posts

    Re: Copy TextBlock from SilverLight web application

    Sep 28, 2008 02:21 AM | LINK

    If you really want this, please change the textbox's style. Put the following Xaml code in App.xaml or some other resource:

    <Style x:Key="TextBoxStyle" TargetType="TextBox">
       <Setter Property="Template">
        <Setter.Value>
         <ControlTemplate TargetType="TextBox">
          <Grid x:Name="RootElement">       
           <ScrollViewer x:Name="ContentElement" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" BorderThickness="0"/>       
          </Grid>
         </ControlTemplate>
        </Setter.Value>
       </Setter>
      </Style>

    Then set your textbox's style as "{StaticResource TextBoxStyle}", and set IsReadOnly property as true, your textbox will look like a textblock but it can be copied.

    Ling Bing
    Bei Jing University of Aeronautics and Astronautics
    Bei Jing, China
  • GearWorld

    GearWorld

    Participant

    1784 Points

    2078 Posts

    Re: Copy TextBlock from SilverLight web application

    Sep 28, 2008 10:23 AM | LINK

    Oh.  That's great.  Thank you