wpf ListView上下左右滚动条取消

1.上下滚动条取消

ScrollViewer.VerticalScrollBarVisibility=“Disabled”

2.左右滚动条取消

ScrollViewer.HorizontalScrollBarVisibility=“Disabled”

3.禁止滚动

IsEnabled=“False”

4.ListView数据居中


   

5.界面(红色框是里面1、2、3、4有解释)

wpf ListView上下左右滚动条取消_第1张图片


    
        
            
                
            
            
                
                    
                    
                    
                
            
        

    

6.代码

代码图片:
wpf ListView上下左右滚动条取消_第2张图片
代码:

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace wpfListView滚动使用
{
    /// 
    /// MainWindow.xaml 的交互逻辑
    /// 
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("ID");
        dt.Columns.Add("Name");
        dt.Columns.Add("SEX");


        for (int i = 0; i < 10; i++)
        {
            DataRow row = dt.NewRow();
            row["ID"] = i + 1;
            row["Name"] = "姓名" + i + 1;

            row["SEX"] = "男";

            dt.Rows.Add(row);
        }

        ListV.ItemsSource = dt.DefaultView;
    }
  } 
}

你可能感兴趣的:(WPFJobLearn,ListView滚动条取消,ListView水平滚动条取消,ListView垂直滚动条取消,ListView禁用滚动轮滚动,ListView所有滚动条取消)