Пример #1
0
        /// <summary>
        /// 更新窗口标题的绑定
        /// </summary>
        internal void UpdateHeader()
        {
            Pane dockItem = Content as Pane;

            if (dockItem == null)
            {
                return;
            }

            IEnumerable <Tabs> sects = from sect in dockItem.GetAllTabs()
                                       where sect != null && sect.Visibility == Visibility.Visible
                                       select sect;

            if (sects.Count() == 1)
            {
                // 窗口中只一个Tabs时,隐藏Tabs标题,在窗口标题显示
                Tabs sect = sects.First();
                sect.ShowHeader = false;

                Binding bind = new Binding();
                bind.Path   = new PropertyPath("SelectedItem.Title");
                bind.Source = sect;
                SetBinding(HeaderProperty, bind);
            }
            else
            {
                foreach (Tabs sect in sects)
                {
                    sect.ShowHeader = true;
                }
                ClearValue(HeaderProperty);
            }
        }