Skip to main content

Microsoft Silverlight

Answered Question Test the .Background color in controlsRSS Feed

(0)

Agnushallard
Agnushal...

Member

Member

53 points

132 Posts

Test the .Background color in controls

How I test the Background color in every control in Usercontrol

Something like this

For Each item As Control In LayoutRoot

If item.Background = Colors.Red Then

Exit For

End If

Next

Using

Visual Studio 2008
Silverlight 3
MySQL

SharpGIS
SharpGIS

Contributor

Contributor

3397 points

611 Posts

Answered Question

Re: Test the .Background color in controls

The background is not a color but a brush.Maybe something like
if(item.Background is SolidColorBrush && ((SolidColorBrush)item.Background).Color == Colors.Red) ...

--
/Morten | blog - twitter
Please click on "Mark as Answer" if this answered your question.

Agnushallard
Agnushal...

Member

Member

53 points

132 Posts

Re: Test the .Background color in controls

But How I test every control??

I try for each item as control in layoutroot and doesn´t work

error: 'System.Windows.Controls.Grid', which is not a collection type. 
 

 

Using

Visual Studio 2008
Silverlight 3
MySQL

Tim Dawson
Tim Dawson

Participant

Participant

1092 points

209 Posts

Answered Question

Re: Test the .Background color in controls

Use the methods in the VisualTreeHelper class to traverse the tree.


Microsoft MVP
Controls for Silverlight, WPF and Windows Forms at http://www.divelements.co.uk
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities