Ejemplo n.º 1
0
        public void CanvasSubclassNamescope()
        {
            CanvasSubclassContainer cc = new CanvasSubclassContainer();

            // the name defined in the definition namescope for the usercontrol is visible
            Assert.IsNotNull(cc.FindName("localNameForCanvas"), "1");

            // the overridden name takes priority here
            Assert.IsNotNull(cc.FindName("containerLocalName"), "2");

            // see what happens when we add two
            // UserControl4's with their default names
            // into the same canvas.
            Canvas c = (Canvas)XamlReader.Load(@"
<Canvas
    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" />
");

            c.Children.Add(new CanvasSubclass());
            Assert.Throws <ArgumentException> (() => c.Children.Add(new CanvasSubclass()), "3");

            c = new Canvas();
            c.Children.Add(new CanvasSubclass());
            c.Children.Add(new CanvasSubclass());
        }
Ejemplo n.º 2
0
		public void CanvasSubclassNamescope ()
		{
			CanvasSubclassContainer cc = new CanvasSubclassContainer();

			// the name defined in the definition namescope for the usercontrol is visible
			Assert.IsNotNull (cc.FindName("localNameForCanvas"), "1");

			// the overridden name takes priority here
			Assert.IsNotNull (cc.FindName("containerLocalName"), "2");

			// see what happens when we add two
			// UserControl4's with their default names
			// into the same canvas.
			Canvas c = (Canvas)XamlReader.Load (@"
<Canvas
    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" />
");

			c.Children.Add (new CanvasSubclass());
			Assert.Throws<ArgumentException> ( () => c.Children.Add (new CanvasSubclass()), "3");

			c = new Canvas ();
			c.Children.Add (new CanvasSubclass());
			c.Children.Add (new CanvasSubclass());
		}