The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Avalon Control Collection - UIElementCollection

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jason Nadal

Posts: 184
Nickname: jnadal
Registered: Dec, 2003

Jason Nadal is an asp.net developer, dabbling in winforms from time to time.
Avalon Control Collection - UIElementCollection Posted: Feb 21, 2004 4:58 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Jason Nadal.
Original Post: Avalon Control Collection - UIElementCollection
Feed Title: Jason Nadal
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/jnadal/Rss.aspx
Feed Description: Restless C#ding
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Jason Nadal
Latest Posts From Jason Nadal

Advertisement

One of the first things I noticed when trying to iterate through the controls of a Longhorn form looking for a control was the absence of the Controls class.  In its place is the UIElementCollection, a member of the MSAvalon.Windows.Controls namespace for the PDC build. This is an array which you can use to gain access to the child controls of an element from the codebehind.  For example, if you had this scenario in the XAML document:

<Canvas ID=”FunControls” Width=”100%” Height=”100%”>

<Button ID=“B0“>I am button 1</Button>
<Button ID=“B1“>I am button 2</Button>

</Canvas>

You may get to the child elements of that Canvas with the following in the codebehind:

UIElementCollection ec = FunControls.Children;
//now I would like to find all of the buttons
for (int i=0; i < ec.Count; i++)
{

//note this namespace will change in future builds...
if (ec[i].GetType.ToString() == “MSAvalon.Windows.Controls.Button” )
{

MSAvalon.Windows.Controls.Button b = (MSAvalon.Windows.Controls.Button)ec[i];
//do something with the button here :)

}

}

Very easy, but the syntax is slightly different from past WinForms programming

Read: Avalon Control Collection - UIElementCollection

Topic: ASP.NET Resource Kit, Exposing Windows SharePoint Services over the Internet, Microsoft's... Previous Topic   Next Topic Topic: Weekend off

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use