locked
Scrolling problem RRS feed

  • Question

  • Hi all

    I have made a UserControl that contains a ListView with items that have to be selectable.

    I need to put a number of these UserControls into a ScrollViewer and be able to scroll through the list of UserControls.

    But when my mouse is over a ListView within my UserControls, I can't scroll (using the mouse wheel).

    Here is the UserControl code (with coloured blocks instead of data items):

    <UserControl
        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"
        mc:Ignorable="d"
        x:Class="SmallCardPlay.CardType2"
        x:Name="UserControl">
        <Border>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <TextBlock Text="Items that can be selected"/>
                <ListView
                    HorizontalAlignment="Stretch"
                    IsSynchronizedWithCurrentItem="True"
                    Grid.Row="1"
                    ScrollViewer.CanContentScroll="False"
                    ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                    ScrollViewer.VerticalScrollBarVisibility="Auto"
                    SelectionMode="Single">
                    <ListView.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel
                                Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </ListView.ItemsPanel>
                    <Rectangle Width="100" Height="100" Fill="Red"/>
                    <Rectangle Width="100" Height="100" Fill="Blue"/>
                    <Rectangle Width="100" Height="100" Fill="Green"/>
                </ListView>
            </Grid>
        </Border>
    </UserControl>

    And here is the ScrollViewer:

    <Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="SmallCardPlay.Window2"
        x:Name="Window"
        Title="Window2"
        Width="640" Height="480"
        xmlns:SmallCardPlay="clr-namespace:SmallCardPlay"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        d:DesignWidth="778"
        d:DesignHeight="629">

        <ScrollViewer >
                <StackPanel VerticalAlignment="Top" Height="Auto">
                    <SmallCardPlay:CardType2/>
                    <SmallCardPlay:CardType2/>
                    <SmallCardPlay:CardType2/>
                    <SmallCardPlay:CardType2/>
                    <SmallCardPlay:CardType2/>                   
                </StackPanel>
        </ScrollViewer>
       
    </Window>

    How can I allow scrolling to be controlled by the outer ScrollViewer only?

    Any help/suggestions will be appreciated.

    Regards

    Carien





    Tuesday, December 9, 2008 9:09 AM