Unplanned
Last Updated: 12 Mar 2019 09:42 by ADMIN
ADMIN
Nasko
Created on: 22 Apr 2015 15:05
Category: ListBox
Type: Bug Report
5
ListBox: The scroll moves when it is not needed, only if ScrollViewer.CanContentScroll="False"

		
2 comments
ADMIN
Martin Ivanov
Posted on: 12 Mar 2019 09:42
Hello Shanthosh,

I am not sure that I understand what is the issue on your side. If it is related to this bug report, may I ask you to share some additional description by answering the following questions?
  • What is the expected result?
  • What is the exact issue?
  • How is reproduced?

If the issue is not related to this concrete bug report, I would ask you to open a new support ticket or a forum and post the description there.

Thank you for the cooperation.

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Shanthosh
Posted on: 05 Mar 2019 11:45

here im using telerik radlistbox, inside list box was not working, i tried using a parent control but it has no use...try to get me some idea to work inside a lstbox scroll.

Note : attached the o/p file

 

XAML CODE:

<UserControl x:Class="View.RoomTemplate"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:View"
             xmlns:vm="clr-namespace:ViewModel"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="800">
    <UserControl.Resources>
        <ObjectDataProvider x:Key="RoomTemplateViewModel" ObjectType="{x:Type vm:RoomTemplateViewModel}"
              MethodName="GetInstance"/>
    </UserControl.Resources>
    <ScrollViewer  VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" >
        <Grid DataContext="{StaticResource RoomTemplateViewModel}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="5"/>
                <ColumnDefinition MinWidth="200"/>
                <ColumnDefinition MinWidth="200"/>
                <ColumnDefinition Width="5"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="5"/>
                <RowDefinition MinHeight="350"/>
                <RowDefinition Height="50"/>
                <RowDefinition MinHeight="50"/>
                <RowDefinition Height="20"/>
                <RowDefinition MinHeight="50"/>
                <RowDefinition Height="5"/>
                <RowDefinition />
            </Grid.RowDefinitions>

            <local:Room x:Name="RoomView" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" />
            <Label FontWeight="Bold" FontSize="20" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" Content="Available Rooms" />

            <telerik:RadListBox Grid.Column="1" Grid.Row="5" Grid.ColumnSpan="2" ItemsSource="{Binding RoomsList}" HorizontalAlignment="Left" Name="ListRooms" ScrollViewer.VerticalScrollBarVisibility="Visible"  PreviewMouseWheel="RoomView_OnPreviewMouseWheel">
                <telerik:RadListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                          <WrapPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </telerik:RadListBox.ItemsPanel>
                <telerik:RadListBox.ItemTemplate>
                    <DataTemplate >
                        <StackPanel>
                            <CheckBox Content="{Binding RoomInformation[0].RoomNumber}" IsChecked="{Binding RoomInformation[0].RoomChecked}"/>
                        </StackPanel>
                    </DataTemplate>
                </telerik:RadListBox.ItemTemplate>
            </telerik:RadListBox>

            <StackPanel Grid.Column="1" Grid.Row="3" Grid.ColumnSpan="2" Orientation="Horizontal" VerticalAlignment="Center">
                <CheckBox IsThreeState="False" Content="Select All" IsChecked="{Binding SelectAllCheck}" Command="{Binding SelectAllCommand}"/>
                <Button Margin="15,0,0,0" Height="25" Width="100" Content="Apply" Command="{Binding ApplySettingCommand}"></Button>
            </StackPanel>
        </Grid>
    </ScrollViewer>
</UserControl>

 

C# CODE:

 private void RoomView_OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            var scrollViewer = (RadListBoxItem)sender;
            var list = GetChildOfType<ScrollViewer>(scrollViewer);
            
            if (list != null)
            {
                if (e.Delta < 0)
                {
                    list.ScrollToVerticalOffset(list.VerticalOffset +e.Delta);
                }
                else if (e.Delta > 0)
                {
                    list.ScrollToVerticalOffset(list.VerticalOffset - e.Delta);
                }
            }
        }


        private static T GetChildOfType<T>(DependencyObject depObj) where T : DependencyObject
        {
            if (depObj == null) return null;

            for (var i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
            {
                var child = VisualTreeHelper.GetChild(depObj, i);

                var result = (child as T) ?? GetChildOfType<T>(child);
                if (result != null) return result;
            }
            return null;
        }   
Attached Files: