How to remove NewItemPlaceholder at TreeView wpf

后端 未结 4 560
野性不改
野性不改 2021-01-16 05:04

I bind ObservableCollection to ListView and I get {NewItemPlaceholder} line at the end. How can I hide or remove that line?

4条回答
  •  一整个雨季
    2021-01-16 05:42

    Like alot of people, I had the same issues but after some thinking, it occured to me that I could just create a bool property in the ViewModel and bind it to the DataGrid CanUserAddRows Property like below. Then I can make the property true or false as needed:

    private bool _canUserAddRows;
        public bool CanUserAddRows
        {
            get { return _canUserAddRows; }
            set
            {
                _canUserAddRows = value;
    
                NotifyPropertyChanged("CanUserAddRows");
            }
        }
    

    <--!--DataGrid property --!-->
    CanUserAddRows="{Binding CanUserAddRows,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"

    This is easier and works very well. Hope it helps you.

提交回复
热议问题