Ejemplo n.º 1
0
 private void OnLoaded(object sender, RoutedEventArgs args)
 {
     // If the NavViewItem is not prepared in an ItemPresenter it will be missing a reference to NavigationView, so adding that here.
     if (m_navigationView == null)
     {
         SetNavigationViewParent(SharedHelpers.GetAncestorOfType <NavigationView>(this));
     }
 }
Ejemplo n.º 2
0
        private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args)
        {
            var tabView = SharedHelpers.GetAncestorOfType <TabView>(VisualTreeHelper.GetParent(this));

            if (tabView != null)
            {
                var internalTabView = tabView;
                internalTabView.UpdateTabContent();
            }
        }
        NavigationViewItem GetNavigationViewItem()
        {
            NavigationViewItem navigationViewItem = null;

            var item = SharedHelpers.GetAncestorOfType <NavigationViewItem>(VisualTreeHelper.GetParent(this));

            if (item != null)
            {
                navigationViewItem = item;
            }
            return(navigationViewItem);
        }
Ejemplo n.º 4
0
        protected override void OnItemsChanged(object item)
        {
            base.OnItemsChanged(item);

            var tabView = SharedHelpers.GetAncestorOfType <TabView>(VisualTreeHelper.GetParent(this));

            if (tabView != null)
            {
                var internalTabView = tabView;
                internalTabView.OnItemsChanged(item);
            }
        }
Ejemplo n.º 5
0
        // TODO Uno specific: ensure the items are updated for ItemsSource change as Items are not yet in sync with ItemsSource properly

        internal override void OnItemsSourceSingleCollectionChanged(object sender, NotifyCollectionChangedEventArgs args, int section)
        {
            base.OnItemsSourceSingleCollectionChanged(sender, args, section);

            var tabView = SharedHelpers.GetAncestorOfType <TabView>(VisualTreeHelper.GetParent(this));

            if (tabView != null)
            {
                var internalTabView   = tabView;
                var vectorChangedArgs = args.ToVectorChangedEventArgs();
                internalTabView.OnItemsChanged(vectorChangedArgs);
            }
        }
Ejemplo n.º 6
0
        private void RequestClose()
        {
            var tabView = SharedHelpers.GetAncestorOfType <TabView>(VisualTreeHelper.GetParent(this));

            if (tabView != null)
            {
                var internalTabView = tabView;
                if (internalTabView != null)
                {
                    internalTabView.RequestCloseTab(this, false);
                }
            }
        }
Ejemplo n.º 7
0
        private NavigationViewItem GetNavigationViewItem()
        {
            NavigationViewItem navigationViewItem = null;

            DependencyObject obj = this;

            var item = SharedHelpers.GetAncestorOfType <NavigationViewItem>(VisualTreeHelper.GetParent(obj));

            if (item != null)
            {
                navigationViewItem = item;
            }
            return(navigationViewItem);
        }
Ejemplo n.º 8
0
        internal NavigationView GetNavigationView()
        {
            //Because of Overflow popup, we can't get NavigationView by SharedHelpers::GetAncestorOfType
            NavigationView navigationView     = null;
            var            navigationViewList = GetNavigationViewList();

            if (navigationViewList != null)
            {
                navigationView = navigationViewList.GetNavigationViewParent();
            }
            else
            {
                // Like Settings, it's NavigationViewItem, but it's not in NavigationViewList. Give it a second chance
                navigationView = SharedHelpers.GetAncestorOfType <NavigationView>(VisualTreeHelper.GetParent(this));
            }
            return(navigationView);
        }
Ejemplo n.º 9
0
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            var itemContainer = (TabViewItem)element;
            var tvi           = itemContainer;

            // Due to virtualization, a TabViewItem might be recycled to display a different tab data item.
            // In that case, there is no need to set the TabWidthMode of the TabViewItem or its parent TabView
            // as they are already set correctly here.
            //
            // We know we are currently looking at a TabViewItem being recycled if its parent TabView has already been set.
            if (tvi.GetParentTabView() == null)
            {
                var tabView = SharedHelpers.GetAncestorOfType <TabView>(VisualTreeHelper.GetParent(this));
                if (tabView != null)
                {
                    tvi.OnTabViewWidthModeChanged(tabView.TabWidthMode);
                    tvi.SetParentTabView(tabView);
                }
            }

            base.PrepareContainerForItemOverride(element, item);
        }
Ejemplo n.º 10
0
 private void SynchronizeMenuBar()
 => m_menuBar = SharedHelpers.GetAncestorOfType <MenuBar>(VisualTreeHelper.GetParent(this));
Ejemplo n.º 11
0
 internal NavigationViewList GetNavigationViewList()
 {
     // Find parent NavigationViewList
     return(SharedHelpers.GetAncestorOfType <NavigationViewList>(VisualTreeHelper.GetParent(this)));
 }
Ejemplo n.º 12
0
        protected override void OnApplyTemplate()
        {
            var popupRadius = (CornerRadius)ResourceAccessor.ResourceLookup(this, c_overlayCornerRadiusKey);

            var tabView         = SharedHelpers.GetAncestorOfType <TabView>(VisualTreeHelper.GetParent(this));
            var internalTabView = tabView ?? null;

            Button GetCloseButton(TabView internalTabView)
            {
                var closeButton = (Button)GetTemplateChild("CloseButton");

                if (closeButton != null)
                {
                    // Do localization for the close button automation name
                    if (string.IsNullOrEmpty(AutomationProperties.GetName(closeButton)))
                    {
                        var closeButtonName = ResourceAccessor.GetLocalizedStringResource(SR_TabViewCloseButtonName);
                        AutomationProperties.SetName(closeButton, closeButtonName);
                    }

                    if (internalTabView != null)
                    {
                        // Setup the tooltip for the close button
                        var tooltip = new ToolTip();
                        tooltip.Content = internalTabView.GetTabCloseButtonTooltipText();
                        ToolTipService.SetToolTip(closeButton, tooltip);
                    }

                    closeButton.Click += OnCloseButtonClick;
                }
                return(closeButton);
            }

            m_closeButton = GetCloseButton(internalTabView);

            OnIconSourceChanged();

            if (tabView != null)
            {
                if (SharedHelpers.IsThemeShadowAvailable())
                {
                    if (internalTabView != null)
                    {
                        var shadow = new ThemeShadow();
                        if (!SharedHelpers.Is21H1OrHigher())
                        {
                            if (internalTabView.GetShadowReceiver() is UIElement shadowReceiver)
                            {
                                shadow.Receivers.Add(shadowReceiver);
                            }
                        }
                        m_shadow = shadow;

                        double shadowDepth = (double)SharedHelpers.FindInApplicationResources(TabView.c_tabViewShadowDepthName, TabView.c_tabShadowDepth);

                        var currentTranslation = Translation;
                        var translation        = new Vector3(currentTranslation.X, currentTranslation.Y, (float)shadowDepth);
                        Translation = translation;

                        UpdateShadow();
                    }
                }

                tabView.TabDragStarting  += OnTabDragStarting;
                tabView.TabDragCompleted += OnTabDragCompleted;
            }

            UpdateCloseButton();
            UpdateWidthModeVisualState();
        }