SQLLite problem

Eduardo Gomez 3,416 Reputation points
2020-06-27T17:04:13.367+00:00

Hello community.

I have an interesting problem that I do not know why is happening

I have a database, that saves the data from a Window and then I have
I made a method named Read and Insert

I made a list in my VM and , and the list will get the data from the read

BUT IN MY XAML MY LIST VIEW DOSENT READ ANYTHING

https://pastebin.com/b8myiTvs

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,672 questions
{count} votes

Accepted answer
  1. DaisyTian-1203 11,616 Reputation points
    2020-06-30T03:21:42.867+00:00

    You need add two parts for your project:
    Part1 :Add NotifyObject.cs

     public class NotifyObject : INotifyPropertyChanged  
        {  
            public event PropertyChangedEventHandler PropertyChanged;  
            public void RaisePropertyChanged(string propertyName)  
            {  
                if (PropertyChanged != null)  
                {  
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));  
                }  
            }  
        }  
    

    Part2 : Make the MainWindowViewModel.cs inherits from NotifyObject,delete public ObservableCollection<User> Users { get; set; } and add like below:

    class MainWindowViewModel:NotifyObject   
        {  
      
            //delete public ObservableCollection<User> Users { get; set; }  
      
            private ObservableCollection<User> _users;  
            public ObservableCollection<User> Users  
            {  
                get { return _users; }  
                set  
                {  
                    if (_users != value)  
                    {  
                        _users = value;  
                        RaisePropertyChanged("Users");  
                    }  
                }  
            }  
    

    Then you can get the data in the main UI like this:

    11062-13.gif


0 additional answers

Sort by: Most helpful