sparaflAsh
sparaflAsh

Reputation: 656

Removing scrollviewer from Pivotviewer

Don't know why, but moving my pivotviewer application from Silverlight 4 to Silverlight 5 changed some things.

When I used to switch to graphview my categories used to group together into some ranges like in this figure (in SL4)

enter image description here

Now something changed and each category has its own column in graphview.

enter image description here

I would like to go back to the old behaviour, but I don't know how to disable it. Moreover a scrollviewer is on the bottom of the pivotviewer.

Tried to play with ScrollViewer like this.

<pivot:PivotViewer x:Name="PivotMainPage" ItemsSource="{Binding}" ScrollViewer.VerticalScrollBarVisibility="Hidden" />

It seems like it doesn't want to work. Any suggestion?

I suspect that it has something to do with the width and height of containers. It seems like the minimum MinHeight = 250 e MinWidth = 450 affect the pivotviewer to exceed the border of the column.

Edit. I cut out all the useless things and just discovered that Pivotviewer arbitrarily decides when to use the scrollviewer. I can find a way to disable it. Now the behaviour is a mix between the old SL4 (some items are grouped) and the new SL5 (even if items are grouped the scrollbar is available).

Here is an example of the first picture in SL5!

enter image description here

This is the new code:

<UserControl x:Class="PVClean.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:pivot="clr-namespace:System.Windows.Controls.Pivot;assembly=System.Windows.Controls.Pivot"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">

            <pivot:PivotViewer x:Name="PivotMainPage" ItemsSource="{Binding}" ScrollViewer.VerticalScrollBarVisibility="Hidden"  />


    </Grid>
</UserControl>

This is the code behind:

public MainPage()
        {
            InitializeComponent();
            PivotMainPage.Loaded += pViewer_Loaded;
        }



        void pViewer_Loaded(object sender, RoutedEventArgs e)
        {
            _cxml = new CxmlCollectionSource(new Uri("http://pivot.blob.core.windows.net/msdn-magazine/msdnmagazine.cxml", UriKind.Absolute));
            _cxml.StateChanged += _cxml_StateChanged;
        }

        void _cxml_StateChanged(object sender,
                               CxmlCollectionStateChangedEventArgs e)
        {
            if (e.NewState == CxmlCollectionState.Loaded)
            {
                PivotMainPage.PivotProperties =
                           _cxml.ItemProperties.ToList();
                PivotMainPage.ItemTemplates =
                           _cxml.ItemTemplates;
                PivotMainPage.ItemsSource =
                           _cxml.Items;
            }
        }

Upvotes: 0

Views: 189

Answers (1)

Steven M
Steven M

Reputation: 594

There is a limit coded into the SL5 PivotViewer which determines (perhaps based on the width of the control) how many "buckets" are the maximum. If you have more than this maximum, it will start grouping them.

However, to answer your question, I'd agree - the way they coded it wasn't perfect - it still shows a scrollbar even if the items are grouped. This is yet one more thing we'll have to live with, unless the release a new version. One feature I miss from SL4 is that you were able to specify the sorting for the Histogram (rather than A-Z).

Upvotes: 1

Related Questions