Skip to main content

Microsoft Silverlight

Answered Question Behavior of simple elements (TextBlock, Rectangle...)RSS Feed

(0)

e-statik
e-statik

Member

Member

0 points

11 Posts

Behavior of simple elements (TextBlock, Rectangle...)

I can't figure out, how to make TextBlock changing its style on mouseover event for example.

Its easy for the button, because it already has some necessary states, such as "MouseOver", "Pressed"... I can create states for the texblock or Rectangle, bu how can i link them to events or activate them?

Thanks!

HarshBardhan
HarshBar...

Star

Star

9908 points

1,719 Posts

Re: Behavior of simple elements (TextBlock, Rectangle...)

For every silverlight Control There are Some event like MouseEnter(similar to MouseOver),MouseLeave(similar to mouse out),MouseLeftButtonDown etc.You Can change Style In these Events and You can use that .

 

Mark it as answer if it answers your Question..

Mark as answer if this post answered your question.

Harsh Bardhan

e-statik
e-statik

Member

Member

0 points

11 Posts

Re: Re: Behavior of simple elements (TextBlock, Rectangle...)

You mean, i should change style programmatically in codebehind file? Yes, i know that and I think its wrong way. I'm using styles, placed in resources and hardcoding style names or color values (for example) in code is bad solution.

Allen Chen – MSFT
Allen Ch...

Star

Star

13862 points

1,803 Posts

Re: Re: Behavior of simple elements (TextBlock, Rectangle...)

Hi

Currently style can only be set once. If you want to change the style you have to change each property separately. Please post your current code if you have further questions.

Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

e-statik
e-statik

Member

Member

0 points

11 Posts

Re: Re: Behavior of simple elements (TextBlock, Rectangle...)

But i dont want to change style. I just wanna know how to change states of my TextBlock, like i can do with Button, for example.

Mark Rideout
Mark Rid...

Contributor

Contributor

2357 points

273 Posts

MicrosoftModerator
Answered Question

Re: Re: Behavior of simple elements (TextBlock, Rectangle...)

Only elements that derive from Control support visual states and template. A TextBlock or an Image derives from FrameworkElement which does not support this.

-mark
Silverlight Program Manager
Microsoft
This post is provided "as-is"

e-statik
e-statik

Member

Member

0 points

11 Posts

Re: Re: Re: Behavior of simple elements (TextBlock, Rectangle...)

Ok, thanks.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities