Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Disable & Enable TextBlock that ha a mouse event RSS

4 replies

Last post May 08, 2008 01:33 PM by sladapter

(0)
  • RobHoz

    RobHoz

    Member

    54 Points

    48 Posts

    Disable & Enable TextBlock that ha a mouse event

    May 07, 2008 10:26 PM | LINK

    Hi All,
    Is there a way to disable a textblock that has mouse events attached to it (the events are in the xaml)?
    And when ever i need enabling it again?

    Thanks,
    Robert

  • sladapter

    sladapter

    All-Star

    43609 Points

    7910 Posts

    Re: Disable & Enable TextBlock that ha a mouse event

    May 07, 2008 11:34 PM | LINK

    You can do this:

    theTextblock.MouseLeftButtonDown -=  theTextblock_MouseLeftButtonDown; // Remove event handler

    theTextblock.MouseLeftButtonDown  += new MouseButtonEventHandler(theTextblock_MouseLeftButtonDown); //Enable event handler

     

     

    Sally Xu
    Software Engineer
    Aprimo, Inc

    Please remember to mark the replies as answers if they answered your question
  • RobHoz

    RobHoz

    Member

    54 Points

    48 Posts

    Re: Re: Disable & Enable TextBlock that ha a mouse event

    May 08, 2008 09:25 AM | LINK

    Thank you!

    What if i would like to disable the button without removing the handlres?
    something like txtTextBlock.Disabled?

  • mchlSync

    mchlSync

    Star

    14968 Points

    2799 Posts

    Re: Re: Disable & Enable TextBlock that ha a mouse event

    May 08, 2008 11:08 AM | LINK

    RobHoz

    something like txtTextBlock.Disabled?
     

    You can use "IsReadOnly" property.

    Example:

    txt.IsReadOnly = true; 

    (If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

    Regards,
    Michael Sync
    Silverlight MVP

    Blog : http://michaelsync.net
  • sladapter

    sladapter

    All-Star

    43609 Points

    7910 Posts

    Re: Re: Disable & Enable TextBlock that ha a mouse event

    May 08, 2008 01:33 PM | LINK

     Michael,

    I thought RobHoz said to disable TextBlock not TextBox. TextBlock is read only control. 

    RobHoz,

    If both TextBlock and TextBox does not have Disabled property. TextBox has readonly property.

    Sally Xu
    Software Engineer
    Aprimo, Inc

    Please remember to mark the replies as answers if they answered your question