Tree and DataGrid on Silverlight 3

Nov 29, 2009 at 6:01 AM

Hi,

I have been evaluated white on siverlight by Silverlight Toolkit. Since I found some problems, I report.
Silverlight Toolkit find http://silverlight.codeplex.com/.

1.  Control DataGrid on Silverlight 3
I want you to return ByAnyOfControlTypes in AutomationSearchCondition.cs deleted by Release-0.19.
Because, it is neccessary searching a child element with the Cell type of those other than Text with DataGrid.


2. Control Tree on Silverlight 3

1) Regist WPFTreeNode class in dictionary for Silverlight.
* ControlDictionary.cs

    public class ControlDictionary
    {
        private ControlDictionary()
        {
              :
            items.Add(ControlDictionaryItem.SilverlightSecondary(typeof(WPFTreeNode), ControlType.TreeItem));
              :
        }
    }


2) In Silverlight, CheckBox is created as a new child element.

* WPFListItem.cs

    public class WPFListItem : ListItem
    {

        private CheckBox CheckBox
        {
            get
            {
                if (this.Framework.Equals(Constants.SilverlightFrameworkId))
                {
                    Button b = (Button)factory.Create(SearchCriteria.ByControlType(ControlType.Button), actionListener);
                    return new CheckBox(b.AutomationElement, b.ActionListener);
                }
                return (CheckBox)factory.Create(SearchCriteria.ByControlType(ControlType.CheckBox), actionListener);
            }
        }

3) It is necessary to search a Cell element not only with ControlType.Text but with ControlType.Custom.

* ListViewRow.cs

    public class ListViewRow : UIItem
    {
        ......
        public virtual ListViewCells Cells
        {
            get
            {
                AutomationElementCollection collection;
                if (this.AutomationElement.Current.ControlType == ControlType.DataItem)
                {
                    collection = finder.Children(AutomationSearchCondition.ByControlType(ControlType.Custom));
                }
                else
                {
                    actionListener.ActionPerforming(this);
                    collection = finder.Children(AutomationSearchCondition.ByControlType(ControlType.Text));
                }
                return new ListViewCells(collection, actionListener, header);
            }
        }
        ......
    }

4) A Text attribute is accessed for the Raw information on a grandchild element.

* TreeNode.cs

    public abstract class TreeNode : UIItem
    {
          :
        // The reference from WPFTreeNode is enabled.
        protected readonly AutomationElementFinder finder;
          :
    }


* WPFTreeNode.cs

using White.Core.AutomationElementSearch;

    public class WPFTreeNode : TreeNode
    {
        ......
        public override string Text
        {
            get
            {
                if (string.IsNullOrEmpty(Name))
                {
                    AutomationElement textElement = finder.FindDescendantRaw(AutomationSearchCondition.ByControlType(ControlType.Text));
                    return textElement == null ? string.Empty : textElement.Current.Name;
                }
                return Name;
            }
        }
    }


Regards.