ScrollViewer的滚动问题(ScrollViewer里添加stackPanel,再加俩个listbox无法滚动的问题)

转自


http://blog.csdn.net/haylhf/article/details/8351203

如果scrollviewr里有一个listbox可以滚动,如果加个面板,放俩个listbox就无法滚动。两天都没进展,突然眼前一亮搜出来,代码搬运工的悲哀......,感谢前辈了。

每次都换个关键字搜索下试试。搜来搜去就喷到了。。。。。。

我的页面为

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" WindowState="Maximized" Loaded="Window_Loaded">
   
       
           
           
       

       
       

               
                   
                       
                   

                   
                       
                   

                   
                       
                   

                   
                       
                   

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

           

           
               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

               
                   
               

           

           
   
       


cs为

        public void bindLBX()
        {
       
       
            LB1.PreviewMouseWheel += (sender, e) =>
            {

                var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);

                eventArg.RoutedEvent = UIElement.MouseWheelEvent;

                eventArg.Source = sender;

                this.LB1.RaiseEvent(eventArg);
               
            };

            LB2.PreviewMouseWheel += (sender, e) =>
            {

                var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);

                eventArg.RoutedEvent = UIElement.MouseWheelEvent;

                eventArg.Source = sender;

                this.LB2.RaiseEvent(eventArg);

            };
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            bindLBX();
        }



你可能感兴趣的:(个人)