//------------------------------------------------------------------- 
        //  Constructors
        //-------------------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="tab">Reference to parent <see cref="TabControl"/>.</param>
        private TabItemGeneratorBehavior(TabControl tab)
        {
            if (null == tab)
                throw new ArgumentNullException("Only hosts of type TabControl are supported.");

            _tabControl = tab;
            _tabControl.Loaded += OnTabLoaded;
            _tabControl.SetBinding(TabControl.SelectedItemProperty,
                                        new Binding("SelectedTabItem") { Source = this });
        }
        public void ControlWithExistingBindingOnItemsSourceWithNullValueThrows()
        {
            var tabControl = new TabControl();
            Binding binding = new Binding("Enumerable");
            binding.Source = new SimpleModel() { Enumerable = null };
            tabControl.SetBinding(ItemsControl.ItemsSourceProperty, binding);

            IRegionAdapter adapter = new TestableTabControlRegionAdapter();

            try
            {
                var region = (MockRegion)adapter.Initialize(tabControl, "region");
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(InvalidOperationException));
                StringAssert.Contains(ex.Message, "ItemsControl's ItemsSource property is not empty.");
            }
        }