瀏覽代碼

Make Window a name scope.

Steven Kirk 10 年之前
父節點
當前提交
035f070953
共有 1 個文件被更改,包括 20 次插入2 次删除
  1. 20 2
      src/Perspex.Controls/Window.cs

+ 20 - 2
src/Perspex.Controls/Window.cs

@@ -40,7 +40,7 @@ namespace Perspex.Controls
     /// <summary>
     /// A top-level window.
     /// </summary>
-    public class Window : TopLevel, IStyleable, IFocusScope
+    public class Window : TopLevel, IStyleable, IFocusScope, INameScope
     {
         /// <summary>
         /// Defines the <see cref="SizeToContent"/> property.
@@ -54,8 +54,8 @@ namespace Perspex.Controls
         public static readonly PerspexProperty<string> TitleProperty =
             PerspexProperty.Register<Window, string>(nameof(Title), "Window");
 
+        private NameScope _nameScope = new NameScope();
         private object _dialogResult;
-
         private Size _maxPlatformClientSize;
 
         /// <summary>
@@ -190,6 +190,24 @@ namespace Perspex.Controls
             }
         }
 
+        /// <inheritdoc/>
+        void INameScope.Register(string name, object element)
+        {
+            _nameScope.Register(name, element);
+        }
+
+        /// <inheritdoc/>
+        object INameScope.Find(string name)
+        {
+            return _nameScope.Find(name);
+        }
+
+        /// <inheritdoc/>
+        void INameScope.Unregister(string name)
+        {
+            _nameScope.Unregister(name);
+        }
+
         /// <inheritdoc/>
         protected override Size MeasureOverride(Size availableSize)
         {