示例#1
0
        /// <summary>
        /// 构造一个 FocusTrackerAdorner 对象,并指定它所在的 AdornerLayer 及所在范围。
        /// </summary>
        /// <param name="layerRoot">layer 对应的根控件。</param>
        /// <param name="layer">本 Adorner 所添加到的 Layer。</param>
        /// <param name="scope">最外层的范围控件。</param>
        /// <param name="scopeLayer">最外层的范围控件对应的 AdornerLayer。</param>
        private FocusTrackerAdorner(UIElement layerRoot, AdornerLayer layer, UIElement scope, AdornerLayer scopeLayer)
            : base(layerRoot)
        {
            if (scope == null)
            {
                throw new ArgumentNullException("scope");
            }
            if (layer == null)
            {
                throw new ArgumentNullException("layer");
            }

            _scope      = scope;
            _scopeLayer = scopeLayer;
            _layerRoot  = layerRoot;
            _layer      = layer;

            _children = new UIElementCollection(this, this);
            _tracker  = new FocusTrackerControl {
                Adorner = this
            };
            _children.Add(_tracker);

            this.Loaded            += OnLoaded;
            scope.GotKeyboardFocus += scope_GotKeyboardFocus;
        }
示例#2
0
        /// <summary>
        /// 构造一个 FocusTrackerAdorner 对象,并指定它所在的 AdornerLayer 及所在范围。
        /// </summary>
        /// <param name="layerRoot">layer 对应的根控件。</param>
        /// <param name="layer">本 Adorner 所添加到的 Layer。</param>
        /// <param name="scope">最外层的范围控件。</param>
        /// <param name="scopeLayer">最外层的范围控件对应的 AdornerLayer。</param>
        private FocusTrackerAdorner(UIElement layerRoot, AdornerLayer layer, UIElement scope, AdornerLayer scopeLayer)
            : base(layerRoot)
        {
            if (scope == null) throw new ArgumentNullException("scope");
            if (layer == null) throw new ArgumentNullException("layer");

            _scope = scope;
            _scopeLayer = scopeLayer;
            _layerRoot = layerRoot;
            _layer = layer;

            _children = new UIElementCollection(this, this);
            _tracker = new FocusTrackerControl { Adorner = this };
            _children.Add(_tracker);

            this.Loaded += OnLoaded;
            scope.GotKeyboardFocus += scope_GotKeyboardFocus;
        }