Example #1
0
        public void ButtonInContentPresenter()
        {
            var b1 = new RadioButton {
                GroupName = "CP"
            };
            var b2 = new RadioButton {
                GroupName = "CP"
            };

            var cp1 = new ContentPresenter {
                Content = b1
            };
            var cp2 = new ContentPresenter {
                Content = b2
            };

            TestPanel.Children.Add(cp1);
            TestPanel.Children.Add(cp2);

            // Force the visual tree to be constructed
            TestPanel.UpdateLayout();

            b1.IsChecked = true;
            b2.IsChecked = true;
            if (MajorVersion >= 3)
            {
                Assert.IsFalse((bool)b1.IsChecked, "#1");
            }
            else
            {
                Assert.IsTrue((bool)b1.IsChecked, "#2");
            }
        }
Example #2
0
        public void ResourceDictionary_AddSubtreeWithElementInRD()
        {
            // If i add element A to the ResourceDictionary on B and then
            // put B in the ResourceDictionary of C, Loaded handlers on A
            // are queued for emission.
            var loaded1 = false;
            var loaded2 = false;

            var subtree = new Canvas();
            var rect1   = new Rectangle();
            var rect2   = new Rectangle();

            rect1.Loaded += (o, e) => loaded1 = true;
            rect2.Loaded += (o, e) => loaded2 = true;

            subtree.Resources.Add("foo2", rect1);
            TestPanel.Resources.Add("foo", subtree);
            TestPanel.Children.Add(rect2);

            Enqueue(() => TestPanel.UpdateLayout());
            Enqueue(() =>
            {
                Assert.IsTrue(loaded1, "#1");
                Assert.IsTrue(loaded2, "#2");
            });
            EnqueueTestComplete();
        }
Example #3
0
        public void NameIsRegisteredTest_VisualTree()
        {
            // Once the template expands and the Items are put
            // in the visual tree, their names are registered.
            string       name = "MyRectInItemsControl";
            ItemsControl c    = (ItemsControl)CurrentControl;

            TestPanel.Children.Add(c);
            c.Items.Add(new Rectangle {
                Name = name
            });
            TestPanel.UpdateLayout();
            Assert.IsNotNull(c.FindName(name), "#1");
        }
Example #4
0
        public void ResourceDictionary_AddToRDFirst()
        {
            var loaded1 = false;
            var loaded2 = false;

            var rect1 = new Rectangle();
            var rect2 = new Rectangle();

            rect1.Loaded += (o, e) => loaded1 = true;
            rect2.Loaded += (o, e) => loaded2 = true;

            TestPanel.Resources.Add("foo", rect1);
            TestPanel.Children.Add(rect2);

            Enqueue(() => TestPanel.UpdateLayout());
            Enqueue(() => {
                Assert.IsTrue(loaded1, "#1");
                Assert.IsTrue(loaded2, "#2");
            });
            EnqueueTestComplete();
        }