Example #1
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            ScrollViewer = this.GetTemplateChild("ScrollViewer") as ScrollViewer;

            // NativePanel may not exist if we're using a non-virtualizing ItemsPanel.
            if (NativePanel != null)
            {
                NativePanel.XamlParent = this;
                // Propagate the DataContext manually, since ItemsPanelRoot isn't really part of the visual tree
                ItemsPanelRoot.SetValue(DataContextProperty, DataContext, DependencyPropertyValuePrecedences.Inheritance);
                OnApplyTemplatePartial();

                if (ScrollViewer?.Style?.Precedence == DependencyPropertyValuePrecedences.ImplicitStyle)
                {
                    throw new InvalidOperationException($"Performance hit: {this} is using a ScrollViewer in its template with a default style, which would break virtualization. A Style containing {nameof(ListViewBaseScrollContentPresenter)} must be used.");
                }

                if (ScrollViewer != null)
                {
                    NativePanel.HorizontalScrollBarVisibility = ScrollViewer.HorizontalScrollBarVisibility;
                    NativePanel.VerticalScrollBarVisibility   = ScrollViewer.VerticalScrollBarVisibility;
                }
            }
            else
            {
                if (ScrollViewer?.Style == Uno.UI.GlobalStaticResources.ListViewBaseScrollViewerStyle)
                {
                    // We're not using NativeListViewBase so we need a 'real' ScrollViewer
                    ScrollViewer.Style = Uno.UI.GlobalStaticResources.DefaultScrollViewerStyle;
                }
            }
        }
Example #2
0
        partial void OnApplyTemplatePartial()
        {
            // NativePanel may not exist if we're using a non-virtualizing ItemsPanel.
            if (NativePanel != null)
            {
                // Propagate the DataContext manually, since ItemsPanelRoot isn't really part of the visual tree
                ItemsPanelRoot.SetValue(DataContextProperty, DataContext, DependencyPropertyValuePrecedences.Inheritance);

                if (ScrollViewer?.Style == null)
                {
                    throw new InvalidOperationException($"Performance hit: {this} is using a ScrollViewer in its template with a default style, which would break virtualization. A Style containing {nameof(ListViewBaseScrollContentPresenter)} must be used.");
                }

                if (ScrollViewer != null)
                {
                    NativePanel.HorizontalScrollBarVisibility = ScrollViewer.HorizontalScrollBarVisibility;
                    NativePanel.VerticalScrollBarVisibility   = ScrollViewer.VerticalScrollBarVisibility;
                }
            }
            else
            {
                if (ScrollViewer?.Style != null && ScrollViewer.Style == ResourceResolver.GetSystemResource <Style>("ListViewBaseScrollViewerStyle"))                //TODO: this, too, properly
                {
                    // We're not using NativeListViewBase so we need a 'real' ScrollViewer, remove the internal custom style
                    ScrollViewer.Style = null;
                }
            }
        }
Example #3
0
        internal protected override void OnDataContextChanged(DependencyPropertyChangedEventArgs e)
        {
            base.OnDataContextChanged(e);

            // Propagate the DataContext manually, since ItemsPanelRoot isn't really part of the visual tree
            ItemsPanelRoot?.SetValue(DataContextProperty, DataContext, DependencyPropertyValuePrecedences.Inheritance);

            OnDataContextChangedPartial();
        }
Example #4
0
 /// <summary>
 /// Re-size the ListView's Panel when the SplitView is compact so the items
 /// will fit within the visible space and correctly display a keyboard focus rect.
 /// </summary>
 private void OnPaneToggled()
 {
     if (splitView.IsPaneOpen)
     {
         ItemsPanelRoot.ClearValue(WidthProperty);
         ItemsPanelRoot.ClearValue(HorizontalAlignmentProperty);
     }
     else if (splitView.DisplayMode == SplitViewDisplayMode.CompactInline || splitView.DisplayMode == SplitViewDisplayMode.CompactOverlay)
     {
         ItemsPanelRoot.SetValue(WidthProperty, splitView.CompactPaneLength);
         ItemsPanelRoot.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Left);
     }
 }
Example #5
0
 /// <summary>
 /// Re-size the ListView's Panel when the SplitView is compact so the items
 /// will fit within the visible space and correctly display a keyboard focus rect.
 /// </summary>
 private void OnPaneToggled()
 {
     if (_splitViewHost.IsPaneOpen)
     {
         ItemsPanelRoot.ClearValue(FrameworkElement.WidthProperty);
         ItemsPanelRoot.ClearValue(FrameworkElement.HorizontalAlignmentProperty);
     }
     else if (this._splitViewHost.DisplayMode == SplitViewDisplayMode.CompactInline ||
              this._splitViewHost.DisplayMode == SplitViewDisplayMode.CompactOverlay)
     {
         ItemsPanelRoot.SetValue(FrameworkElement.WidthProperty, this._splitViewHost.CompactPaneLength);
         ItemsPanelRoot.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Left);
     }
 }