public async Task EventSenderTestCore(bool addControlFirst, bool linearLayout)
        {
            Grid   rootRoot = new Grid();
            Grid   root     = new Grid();
            Button bt       = null;

            if (addControlFirst)
            {
                if (linearLayout)
                {
                    bt = new TestButton()
                    {
                        Name = "bt"
                    };
                    root.Children.Add(bt);
                }
                else
                {
                    bt = new TestButton()
                    {
                        Name = "bt"
                    };
                    rootRoot.Children.Add(bt);
                    rootRoot.Children.Add(root);
                }
            }

            EventToCommandTestClass eventToCommand1 = new EventToCommandTestClass()
            {
                EventName = "SizeChanged"
            };
            EventToCommandTestClass eventToCommand2 = new EventToCommandTestClass()
            {
                EventName = "SizeChanged"
            };

            BindingOperations.SetBinding(eventToCommand2, EventToCommand.SourceObjectProperty, new Binding()
            {
                ElementName = "bt"
            });
            EventToCommandTestClass eventToCommand3 = new EventToCommandTestClass()
            {
                EventName = "SizeChanged", SourceName = "bt"
            };

            EventToCommandTestClass eventToCommand4 = new EventToCommandTestClass()
            {
                EventName = "Loaded"
            };
            EventToCommandTestClass eventToCommand5 = new EventToCommandTestClass()
            {
                EventName = "Loaded"
            };

            BindingOperations.SetBinding(eventToCommand5, EventToCommand.SourceObjectProperty, new Binding()
            {
                ElementName = "bt"
            });
            EventToCommandTestClass eventToCommand6 = new EventToCommandTestClass()
            {
                EventName = "Loaded", SourceName = "bt"
            };

            Interaction.GetBehaviors(root).Add(eventToCommand1);
            Interaction.GetBehaviors(root).Add(eventToCommand2);
            Interaction.GetBehaviors(root).Add(eventToCommand3);
            Interaction.GetBehaviors(root).Add(eventToCommand4);
            Interaction.GetBehaviors(root).Add(eventToCommand5);
            Interaction.GetBehaviors(root).Add(eventToCommand6);

            if (!addControlFirst)
            {
                if (linearLayout)
                {
                    bt = new TestButton()
                    {
                        Name = "bt"
                    };
                    root.Children.Add(bt);
                }
                else
                {
                    bt = new TestButton()
                    {
                        Name = "bt"
                    };
                    rootRoot.Children.Add(bt);
                    rootRoot.Children.Add(root);
                }
            }
            bt.Loaded      += bt_Loaded;
            bt.SizeChanged += bt_SizeChanged;
            if (linearLayout)
            {
                Window.Content = root;
            }
            else
            {
                Window.Content = rootRoot;
            }
            await EnqueueShowWindow();

            EnqueueWindowUpdateLayout();
            EnqueueCallback(() => {
                Assert.AreEqual(1, eventToCommand1.EventCount);
                Assert.AreEqual(root, eventToCommand1.EventSender);
                Assert.AreEqual(EventToCommandType.AssociatedObject, eventToCommand1.Type);

                Assert.IsTrue(eventToCommand2.EventCount > 0);
                Assert.AreEqual(bt, eventToCommand2.EventSender);
                Assert.AreEqual(EventToCommandType.SourceObject, eventToCommand2.Type);

                Assert.AreEqual(1, eventToCommand3.EventCount);
                Assert.AreEqual(bt, eventToCommand3.EventSender);
                Assert.AreEqual(EventToCommandType.SourceName, eventToCommand3.Type);

                Assert.AreEqual(1, eventToCommand4.EventCount);
                Assert.AreEqual(root, eventToCommand4.EventSender);
                Assert.AreEqual(EventToCommandType.AssociatedObject, eventToCommand4.Type);

                Assert.AreEqual(1, eventToCommand5.EventCount);
                Assert.AreEqual(bt, eventToCommand5.EventSender);
                Assert.AreEqual(EventToCommandType.SourceObject, eventToCommand5.Type);

                Assert.AreEqual(1, eventToCommand6.EventCount);
                Assert.AreEqual(bt, eventToCommand6.EventSender);
                Assert.AreEqual(EventToCommandType.SourceName, eventToCommand6.Type);
            });
            EnqueueTestComplete();
        }
        public async Task EventSenderTestCore(bool addControlFirst, bool linearLayout) {
            Grid rootRoot = new Grid();
            Grid root = new Grid();
            Button bt = null;
            if(addControlFirst) {
                if(linearLayout) {
                    bt = new TestButton() { Name = "bt" };
                    root.Children.Add(bt);
                } else {
                    bt = new TestButton() { Name = "bt" };
                    rootRoot.Children.Add(bt);
                    rootRoot.Children.Add(root);
                }
            }

            EventToCommandTestClass eventToCommand1 = new EventToCommandTestClass() { EventName = "SizeChanged" };
            EventToCommandTestClass eventToCommand2 = new EventToCommandTestClass() { EventName = "SizeChanged" };
            BindingOperations.SetBinding(eventToCommand2, EventToCommand.SourceObjectProperty, new Binding() { ElementName = "bt" });
            EventToCommandTestClass eventToCommand3 = new EventToCommandTestClass() { EventName = "SizeChanged", SourceName = "bt" };

            EventToCommandTestClass eventToCommand4 = new EventToCommandTestClass() { EventName = "Loaded" };
            EventToCommandTestClass eventToCommand5 = new EventToCommandTestClass() { EventName = "Loaded" };
            BindingOperations.SetBinding(eventToCommand5, EventToCommand.SourceObjectProperty, new Binding() { ElementName = "bt" });
            EventToCommandTestClass eventToCommand6 = new EventToCommandTestClass() { EventName = "Loaded", SourceName = "bt" };

            Interaction.GetBehaviors(root).Add(eventToCommand1);
            Interaction.GetBehaviors(root).Add(eventToCommand2);
            Interaction.GetBehaviors(root).Add(eventToCommand3);
            Interaction.GetBehaviors(root).Add(eventToCommand4);
            Interaction.GetBehaviors(root).Add(eventToCommand5);
            Interaction.GetBehaviors(root).Add(eventToCommand6);

            if(!addControlFirst) {
                if(linearLayout) {
                    bt = new TestButton() { Name = "bt" };
                    root.Children.Add(bt);
                } else {
                    bt = new TestButton() { Name = "bt" };
                    rootRoot.Children.Add(bt);
                    rootRoot.Children.Add(root);
                }
            }
            bt.Loaded += bt_Loaded;
            bt.SizeChanged += bt_SizeChanged;
            if(linearLayout)
                Window.Content = root;
            else
                Window.Content = rootRoot;
            await EnqueueShowWindow();
            EnqueueWindowUpdateLayout();
            EnqueueCallback(() => {
                Assert.AreEqual(1, eventToCommand1.EventCount);
                Assert.AreEqual(root, eventToCommand1.EventSender);
                Assert.AreEqual(EventToCommandType.AssociatedObject, eventToCommand1.Type);

                Assert.IsTrue(eventToCommand2.EventCount > 0);
                Assert.AreEqual(bt, eventToCommand2.EventSender);
                Assert.AreEqual(EventToCommandType.SourceObject, eventToCommand2.Type);

                Assert.AreEqual(1, eventToCommand3.EventCount);
                Assert.AreEqual(bt, eventToCommand3.EventSender);
                Assert.AreEqual(EventToCommandType.SourceName, eventToCommand3.Type);

                Assert.AreEqual(1, eventToCommand4.EventCount);
                Assert.AreEqual(root, eventToCommand4.EventSender);
                Assert.AreEqual(EventToCommandType.AssociatedObject, eventToCommand4.Type);

                Assert.AreEqual(1, eventToCommand5.EventCount);
                Assert.AreEqual(bt, eventToCommand5.EventSender);
                Assert.AreEqual(EventToCommandType.SourceObject, eventToCommand5.Type);

                Assert.AreEqual(1, eventToCommand6.EventCount);
                Assert.AreEqual(bt, eventToCommand6.EventSender);
                Assert.AreEqual(EventToCommandType.SourceName, eventToCommand6.Type);
            });
            EnqueueTestComplete();
        }