question

EduardoGomez-1870 avatar image
0 Votes"
EduardoGomez-1870 asked RuCoder-7726 commented

SQLLite problem

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-wpf
· 8
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The code you provided is missing some parts[eg:materialDesign,InputDialog,Operation.Read()...] ,and I cannot analyze your problem. Can you provide a complete demo that reproduce the problem?

0 Votes 0 ·

Hi, in your demo is not Users.db. Exception: Library e_sqlite3 not found.

0 Votes 0 ·
Show more comments

1 Answer

DaisyTian-1203 avatar image
0 Votes"
DaisyTian-1203 answered RuCoder-7726 commented

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



13.gif (84.3 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TThanks, that was helpful!

 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");
                  }
              }
          }

I was also thinking if that was an incident or problem according to itil terminology (getting ready to pass an exam)


0 Votes 0 ·