Sign In|Join
Home/Silverlight.NET Forums/General Silverlight Programming/Programming with .NET - General/Disable & Enable TextBlock that ha a mouse event
Last post May 08, 2008 01:33 PM by sladapter
Member
54 Points
48 Posts
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
All-Star
43609 Points
7910 Posts
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
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?
Star
14968 Points
2799 Posts
May 08, 2008 11:08 AM | LINK
RobHoz something like txtTextBlock.Disabled?
You can use "IsReadOnly" property.
Example:
txt.IsReadOnly = true;
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.
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
Http://www.amazooz.com
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
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
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?
Http://www.amazooz.com
mchlSync
Star
14968 Points
2799 Posts
Re: Re: Disable & Enable TextBlock that ha a mouse event
May 08, 2008 11:08 AM | LINK
You can use "IsReadOnly" property.
Example:
txt.IsReadOnly = true;
Regards,
Michael Sync
Silverlight MVP
Blog : http://michaelsync.net
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.
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question