Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can make ScrollViewer scroll when mouse is over *any* content
    primarykey
    data
    text
    <p>The reason I stress 'any' is because <code>CanContentScroll</code> is not fully working in my <code>ScollViewer</code>. Let me explain the scenario: I have a <code>ScrollViewer</code> that has three Labels followed by a <code>ListBox</code> each. The reason I have this content inside the <code>ScrollViewer</code> is because I don't want each <code>ListBox</code> to have a <code>ScrollBar</code>, I just want one "global" <code>ScrollBar</code>. The problem is that when the cursor is over the the <code>ListBox</code> the <code>ScrollViewer</code> doesn't scroll. I've tried to set <code>CanContentScroll</code> property to true in the ScrollViewer, the ListBox and on the ListBoxItem style, without success. Is there other Control type I should use? Here is my code sample:</p> <pre><code>&lt;UserControl x:Class="Telbit.TeStudio.View.Controls.TestStepsView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:my="clr-namespace:Telbit.TeStudio.View.Controls"&gt; &lt;UserControl.Resources&gt; &lt;DataTemplate DataType="{x:Type my:TestStepsStepViewModel}"&gt; &lt;my:TestStepsStepView HorizontalAlignment="Stretch"/&gt; &lt;/DataTemplate&gt; &lt;Style x:Key="StepItemStyle" TargetType="{x:Type ListBoxItem}"&gt; &lt;Setter Property="SnapsToDevicePixels" Value="true"/&gt; &lt;Setter Property="OverridesDefaultStyle" Value="true"/&gt; &lt;Setter Property="IsSelected" Value="{Binding Mode=TwoWay, Path=IsSelected}"/&gt; &lt;Setter Property="ScrollViewer.CanContentScroll" Value="True"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="ListBoxItem"&gt; &lt;Border Name="Border" SnapsToDevicePixels="true" Background="Transparent" BorderThickness="0" Padding="1"&gt; &lt;ContentPresenter/&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsSelected" Value="true"&gt; &lt;Setter TargetName="Border" Property="Background" Value="#40a0f5ff"/&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsKeyboardFocusWithin" Value="True"&gt; &lt;Setter Property="IsSelected" Value="True" /&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/UserControl.Resources&gt; &lt;UserControl.Background&gt; &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt; &lt;GradientStop Color="#FFF2F2F2"/&gt; &lt;GradientStop Color="Gainsboro" Offset="1"/&gt; &lt;/LinearGradientBrush&gt; &lt;/UserControl.Background&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="30"/&gt; &lt;RowDefinition Height="*"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;HeaderedContentControl Grid.Row="0" &gt; &lt;HeaderedContentControl.Header&gt; &lt;Grid Background="#e8f2f8"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="30"/&gt; &lt;ColumnDefinition MinWidth="200" Width="*" /&gt; &lt;ColumnDefinition Width="75"/&gt; &lt;ColumnDefinition Width="60"/&gt; &lt;ColumnDefinition Width="60"/&gt; &lt;ColumnDefinition Width="60"/&gt; &lt;ColumnDefinition Width="60"/&gt; &lt;ColumnDefinition Width="120"/&gt; &lt;ColumnDefinition Width="130"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Label Grid.Column="0" Content="#" BorderBrush="#70add4" BorderThickness="2 2 0 2"/&gt; &lt;Label Grid.Column="1" Content="Folder\Name" BorderBrush="#70add4" BorderThickness="0 2 0 2"/&gt; &lt;Label Grid.Column="2" Content="Type" BorderBrush="#70add4" BorderThickness="0 2 0 2" Margin="-20 0 0 0"/&gt; &lt;Label Grid.Column="3" Content="Auto Start" BorderBrush="#70add4" BorderThickness="0 2 0 2" Margin="-20 0 0 0"/&gt; &lt;Label Grid.Column="4" Content="Run After" BorderBrush="#70add4" BorderThickness="0 2 0 2" Margin="-20 0 0 0"/&gt; &lt;Label Grid.Column="5" Content="Stop After" BorderBrush="#70add4" BorderThickness="0 2 0 2" Margin="-20 0 0 0"/&gt; &lt;Label Grid.Column="6" Content="Delay (s)" BorderBrush="#70add4" BorderThickness="0 2 0 2" Margin="-20 0 0 0"/&gt; &lt;Label Grid.Column="7" Content="Timestamp" BorderBrush="#70add4" BorderThickness="0 2 0 2" Margin="-20 0 0 0"/&gt; &lt;Label Grid.Column="8" Content="Edited by" BorderBrush="#70add4" BorderThickness="0 2 2 2" Margin="-20 0 0 0"/&gt; &lt;/Grid&gt; &lt;/HeaderedContentControl.Header&gt; &lt;/HeaderedContentControl&gt; &lt;ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1" VerticalAlignment="Top" CanContentScroll="True"&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="30"/&gt; &lt;RowDefinition Height="3*"/&gt; &lt;RowDefinition Height="30"/&gt; &lt;RowDefinition Height="3*"/&gt; &lt;RowDefinition Height="30"/&gt; &lt;RowDefinition Height="3*"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;Label Name="lblSetup" Grid.Row="0" VerticalContentAlignment="Center" BorderBrush="DarkGray" BorderThickness="0 0 0 1" TextBlock.FontSize="10pt" TextBlock.FontWeight="Bold" TextBlock.Foreground="#949494" Content="Setup" AllowDrop="True"/&gt; &lt;ListBox Name="itmCtrlSetupSteps" Grid.Row="1" BorderThickness="0" Background="Transparent" ItemsSource="{Binding SetupSteps}" SelectionMode="Single" HorizontalContentAlignment="Stretch" ItemContainerStyle="{StaticResource StepItemStyle}" SelectionChanged="manageStep_SelectionChanged" ScrollViewer.CanContentScroll="True" /&gt; &lt;Label Name="lblTest" Grid.Row="2" VerticalContentAlignment="Center" BorderBrush="DarkGray" BorderThickness="0 0 0 1" TextBlock.FontSize="10pt" TextBlock.FontWeight="Bold" TextBlock.Foreground="#949494" Content="Test" AllowDrop="True"/&gt; &lt;ListBox Name="itmCtrlTestSteps" Grid.Row="3" BorderThickness="0" Background="Transparent" ItemsSource="{Binding TestSteps}" SelectionMode="Single" HorizontalContentAlignment="Stretch" ItemContainerStyle="{StaticResource StepItemStyle}" SelectionChanged="manageStep_SelectionChanged" /&gt; &lt;Label Name="lblTearDown" Grid.Row="4" VerticalContentAlignment="Center" BorderBrush="DarkGray" BorderThickness="0 0 0 1" TextBlock.FontSize="10pt" TextBlock.FontWeight="Bold" TextBlock.Foreground="#949494" Content="Tear Down" AllowDrop="True"/&gt; &lt;ListBox Name="itmCtrlTearDownSteps" Grid.Row="5" BorderThickness="0" Background="Transparent" ItemsSource="{Binding TearDownSteps}" SelectionMode="Single" HorizontalContentAlignment="Stretch" ItemContainerStyle="{StaticResource StepItemStyle}" SelectionChanged="manageStep_SelectionChanged" /&gt; &lt;/Grid&gt; &lt;/ScrollViewer&gt; &lt;/Grid&gt; &lt;/UserControl&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload