Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to Login to my Database from C#? Pin
Gerry Schmitz2-Dec-16 8:00
mveGerry Schmitz2-Dec-16 8:00 
Questionc#webservice insert into Unity3d Pin
Member 128822191-Dec-16 19:26
Member 128822191-Dec-16 19:26 
AnswerRe: c#webservice insert into Unity3d Pin
Richard MacCutchan1-Dec-16 21:40
mveRichard MacCutchan1-Dec-16 21:40 
QuestionWPF Importing Raw Data From Excel And Want to Retain The Exact Date Format Pin
Mark McArdle1-Dec-16 4:54
Mark McArdle1-Dec-16 4:54 
AnswerRe: WPF Importing Raw Data From Excel And Want to Retain The Exact Date Format Pin
Richard Deeming1-Dec-16 5:33
mveRichard Deeming1-Dec-16 5:33 
GeneralRe: WPF Importing Raw Data From Excel And Want to Retain The Exact Date Format Pin
Mark McArdle1-Dec-16 5:38
Mark McArdle1-Dec-16 5:38 
Questionc# WPF Binding a listbox to another listbox's selected item Pin
Member 1288059530-Nov-16 22:11
Member 1288059530-Nov-16 22:11 
AnswerRe: c# WPF Binding a listbox to another listbox's selected item Pin
Pete O'Hanlon30-Nov-16 23:23
mvePete O'Hanlon30-Nov-16 23:23 
Normally I would point you to the correct forum for this type of question (we have a dedicated WPF/Silverlight forum that this is best suited for). In this case, I'll let you off Smile | :) .

The thing you are missing is that you don't have a selected item in your contact list, so you have no way of triggering this. The first thing to do is to add a property to your ContactViewModel that you will bind your selected item from the ListBox to. So, change your VM to this:
C#
public class ContactViewModel : ViewModelBase
{
  private Contact selectedContact;
  public ObservableCollection<Contact> ContactList;
 
  public ContactViewModel()
  {
    ContactList = new ObservableCollection<Contact>(cbdc.Contacts);
    SelectedContact = ContactList.FirstOrDefault(); // Do this if you automatically want a selected item
  }

  public Contact SelectedContact
  {
    get { return selectedContact; }
    set
    {
      if (selectedContact == value) return;
      selectedContact = value;
      RaisePropertyChanged("SelectedContact");
    }
  }
}
Then, you change the relevant ListBox to include
XML
SelectedItem="{Binding SelectedContact}"
Now, that gets the selected contact binding properly and you'll need to handle this to select the items somehow. What I can't see, anywhere in your code, is the logical connection between these two ViewModels. I can't see any code that actually links the two. If I were doing this, I would combine them into one VM and have the second ObservableCollection updated from the change in SelectedContact.
This space for rent

GeneralRe: c# WPF Binding a listbox to another listbox's selected item Pin
Member 128805951-Dec-16 1:46
Member 128805951-Dec-16 1:46 
Questionauto delete file Pin
Member 1287946030-Nov-16 18:41
Member 1287946030-Nov-16 18:41 
AnswerRe: auto delete file Pin
OriginalGriff30-Nov-16 20:10
mveOriginalGriff30-Nov-16 20:10 
AnswerRe: auto delete file Pin
Afzaal Ahmad Zeeshan1-Dec-16 7:20
professionalAfzaal Ahmad Zeeshan1-Dec-16 7:20 
GeneralRe: auto delete file Pin
Eddy Vluggen1-Dec-16 8:27
professionalEddy Vluggen1-Dec-16 8:27 
AnswerRe: auto delete file Pin
Gerry Schmitz1-Dec-16 9:09
mveGerry Schmitz1-Dec-16 9:09 
QuestionCan change Excel file to Object in C# window application Pin
Rosy mm30-Nov-16 15:33
Rosy mm30-Nov-16 15:33 
AnswerRe: Can change Excel file to Object in C# window application Pin
OriginalGriff30-Nov-16 20:13
mveOriginalGriff30-Nov-16 20:13 
GeneralMessage Closed Pin
30-Nov-16 22:12
Rosy mm30-Nov-16 22:12 
GeneralRe: Can change Excel file to Object in C# window application Pin
OriginalGriff30-Nov-16 22:57
mveOriginalGriff30-Nov-16 22:57 
GeneralRe: Can change Excel file to Object in C# window application Pin
Rosy mm1-Dec-16 19:01
Rosy mm1-Dec-16 19:01 
GeneralRe: Can change Excel file to Object in C# window application Pin
Richard Deeming1-Dec-16 2:07
mveRichard Deeming1-Dec-16 2:07 
AnswerRe: Can change Excel file to Object in C# window application Pin
Gerry Schmitz1-Dec-16 9:20
mveGerry Schmitz1-Dec-16 9:20 
Questionrdl report Pin
Member 1048416229-Nov-16 17:07
Member 1048416229-Nov-16 17:07 
AnswerRe: rdl report Pin
Richard Deeming30-Nov-16 2:19
mveRichard Deeming30-Nov-16 2:19 
Questionhow to get modified record from database to c# application Pin
Member 308047028-Nov-16 20:06
Member 308047028-Nov-16 20:06 
QuestionRe: how to get modified record from database to c# application Pin
Richard MacCutchan28-Nov-16 21:41
mveRichard MacCutchan28-Nov-16 21:41 

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.