Click here to Skip to main content
15,033,650 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: UserControl Pin
Meshack Musundi5-Dec-16 22:23
mvaMeshack Musundi5-Dec-16 22:23 
GeneralRe: UserControl Pin
Kevin Marois6-Dec-16 4:49
professionalKevin Marois6-Dec-16 4:49 
GeneralRe: UserControl Pin
Meshack Musundi6-Dec-16 5:04
mvaMeshack Musundi6-Dec-16 5:04 
AnswerRe: UserControl Pin
Richard Deeming6-Dec-16 2:10
mveRichard Deeming6-Dec-16 2:10 
GeneralRe: UserControl Pin
Kevin Marois6-Dec-16 4:47
professionalKevin Marois6-Dec-16 4:47 
QuestionC# WPF listbox binding to selected item does not update my property Pin
Member 128805954-Dec-16 5:54
MemberMember 128805954-Dec-16 5:54 
AnswerRe: C# WPF listbox binding to selected item does not update my property Pin
Richard Deeming5-Dec-16 1:58
mveRichard Deeming5-Dec-16 1:58 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Member 128805955-Dec-16 9:08
MemberMember 128805955-Dec-16 9:08 
Thank You!
I have modified my code, but my SelectedContact still doesnt update.
The XAML code for the listbox bindings remains the same as in my first post.
What should i do next?
(sorry if its something obvious that i havent noticed)
public class MainViewModel : ViewModelBase
   {
       private Contact selectedContact;

       private ObservableCollection<Contact> contactList;
       private ObservableCollection<Conversation> conversationList;

       public MainViewModel()
       {
           ContactList = new ObservableCollection<Contact>(cbdc.Contacts);
           SelectedContact = ContactList.FirstOrDefault();
       }

       public ObservableCollection<Contact> ContactList
       {
           get
           {
               return contactList;
           }

           private set
           {
               if (contactList != value)
               {
                   contactList = value;
                   RaisePropertyChanged();
               }
           }
       }

       public ObservableCollection<Conversation> ConversationList
       {
           get
           {
               return conversationList;
           }
           private set
           {
               if (conversationList != value)
               {
                   conversationList = value;
                   RaisePropertyChanged();
               }
           }
       }

public Contact SelectedContact
       {
           get
           {
               return selectedContact;
           }

           set
           {
               if (selectedContact != value)
               {
                   selectedContact = value;
                   RaisePropertyChanged();
                   PopulateConversationList();
               }
           }
       }

       public void PopulateConversationList()
       {
           if (selectedContact == null)
           {
               ConversationList = null;
           }
           else
           {
               var conversations = from c in cbdc.Conversations
                                   where c.ContactID == SelectedContact.Id
                                   select c;
               ConversationList = new ObservableCollection<Conversation>(conversations);
           }

       }

   }


public class ViewModelBase: INotifyPropertyChanged
  {
      public ContactLinqToSQLClassesDataContext cbdc = new ContactLinqToSQLClassesDataContext();


      #region INotifyPropertyChanged

      public event PropertyChangedEventHandler PropertyChanged;
      internal void RaisePropertyChanged([CallerMemberName] string propertyName = null)
      {
          var handler = PropertyChanged;
          if (handler != null)
          {
              handler(this, new PropertyChangedEventArgs(propertyName));
          }
      }
      #endregion
  }


public class ViewModelBase: INotifyPropertyChanged
{
    public ContactLinqToSQLClassesDataContext cbdc = new ContactLinqToSQLClassesDataContext();


    #region INotifyPropertyChanged

    public event PropertyChangedEventHandler PropertyChanged;
    internal void RaisePropertyChanged([CallerMemberName] string propertyName = null)
    {
        var handler = PropertyChanged;
        if (handler != null)
        {
            handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
    #endregion
}


public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        MainViewModel cvm = new MainViewModel();
        ContactsLstBx.ItemsSource = cvm.ContactList;
        ConversationLstBx.ItemsSource = cvm.ConversationList;
    }
}

GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Jon McKee5-Dec-16 10:59
professionalJon McKee5-Dec-16 10:59 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Member 128805956-Dec-16 7:38
MemberMember 128805956-Dec-16 7:38 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Jon McKee6-Dec-16 8:23
professionalJon McKee6-Dec-16 8:23 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Member 128805956-Dec-16 9:10
MemberMember 128805956-Dec-16 9:10 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Jon McKee6-Dec-16 10:30
professionalJon McKee6-Dec-16 10:30 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Member 128805957-Dec-16 8:10
MemberMember 128805957-Dec-16 8:10 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Jon McKee5-Dec-16 10:13
professionalJon McKee5-Dec-16 10:13 
AnswerRe: C# WPF listbox binding to selected item does not update my property Pin
Gerry Schmitz5-Dec-16 5:51
mveGerry Schmitz5-Dec-16 5:51 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Member 128805955-Dec-16 9:10
MemberMember 128805955-Dec-16 9:10 
QuestionTabControl views are not disposed Pin
Leif Simon Goodwin23-Nov-16 4:55
mvaLeif Simon Goodwin23-Nov-16 4:55 
AnswerRe: TabControl views are not disposed Pin
Pete O'Hanlon23-Nov-16 5:30
mvePete O'Hanlon23-Nov-16 5:30 
PraiseRe: TabControl views are not disposed Pin
Leif Simon Goodwin23-Nov-16 21:09
mvaLeif Simon Goodwin23-Nov-16 21:09 
QuestionIs there any way to automate the silverlight application using Eclipse-testng-selenium-java frameowork Pin
Ashish khanduri20-Nov-16 18:23
MemberAshish khanduri20-Nov-16 18:23 
AnswerRe: Is there any way to automate the silverlight application using Eclipse-testng-selenium-java frameowork Pin
Mycroft Holmes20-Nov-16 19:39
professionalMycroft Holmes20-Nov-16 19:39 
GeneralRe: Is there any way to automate the silverlight application using Eclipse-testng-selenium-java frameowork Pin
Ashish khanduri20-Nov-16 19:50
MemberAshish khanduri20-Nov-16 19:50 
QuestionSound Command that can intercept the Active Thread Pin
Vimalsoft(Pty) Ltd15-Nov-16 17:56
professionalVimalsoft(Pty) Ltd15-Nov-16 17:56 
AnswerRe: Sound Command that can intercept the Active Thread Pin
Gerry Schmitz16-Nov-16 6:07
mveGerry Schmitz16-Nov-16 6:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.