Click here to Skip to main content
15,895,011 members
Home / Discussions / C#
   

C#

 
AnswerRe: can some one encrypt these codes Pin
Nathan Minier2-Dec-16 1:27
professionalNathan Minier2-Dec-16 1:27 
AnswerRe: can some one encrypt these codes PinPopular
Pete O'Hanlon2-Dec-16 2:25
mvePete O'Hanlon2-Dec-16 2:25 
GeneralRe: can some one encrypt these codes Pin
OriginalGriff2-Dec-16 2:33
mveOriginalGriff2-Dec-16 2:33 
GeneralRe: can some one encrypt these codes Pin
Pete O'Hanlon2-Dec-16 2:38
mvePete O'Hanlon2-Dec-16 2:38 
AnswerRe: can some one encrypt these codes Pin
Jochen Arndt2-Dec-16 3:09
professionalJochen Arndt2-Dec-16 3:09 
AnswerRe: can some one encrypt these codes Pin
Gerry Schmitz2-Dec-16 6:45
mveGerry Schmitz2-Dec-16 6:45 
GeneralRe: can some one encrypt these codes Pin
OriginalGriff2-Dec-16 8:17
mveOriginalGriff2-Dec-16 8:17 
GeneralRe: can some one encrypt these codes Pin
Gerry Schmitz2-Dec-16 8:36
mveGerry Schmitz2-Dec-16 8:36 
AnswerRe: can some one encrypt these codes Pin
Afzaal Ahmad Zeeshan2-Dec-16 9:40
professionalAfzaal Ahmad Zeeshan2-Dec-16 9:40 
AnswerRe: can some one encrypt these codes Pin
Patrice T5-Dec-16 10:47
mvePatrice T5-Dec-16 10:47 
GeneralRe: can some one encrypt these codes Pin
Member 128824725-Dec-16 16:43
Member 128824725-Dec-16 16:43 
GeneralRe: can some one encrypt these codes Pin
Dave Kreskowiak12-Dec-16 5:02
mveDave Kreskowiak12-Dec-16 5:02 
AnswerRe: can some one encrypt these codes Pin
237415-Dec-16 13:18
237415-Dec-16 13:18 
QuestionHow to Login to my Database from C#? Pin
Member 128803401-Dec-16 19:59
Member 128803401-Dec-16 19:59 
AnswerRe: How to Login to my Database from C#? Pin
Pete O'Hanlon1-Dec-16 21:36
mvePete O'Hanlon1-Dec-16 21:36 
GeneralRe: How to Login to my Database from C#? Pin
Member 128803401-Dec-16 22:15
Member 128803401-Dec-16 22:15 
GeneralRe: How to Login to my Database from C#? Pin
Pete O'Hanlon1-Dec-16 22:28
mvePete O'Hanlon1-Dec-16 22:28 
SuggestionRe: How to Login to my Database from C#? Pin
Richard Deeming2-Dec-16 2:09
mveRichard Deeming2-Dec-16 2:09 
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 
Hello!
I am trying to make a Contact Book, where i can have my contacts and conversations(+other activities related to them) in C# WPF.I am also trying to learn MVVM withg this.

I have 2 listboxes each bound to an observable collection populated from a database using LinqToSQL.
Listbox 1(ContactsLstBx) is displaying a list of contact names, and in Listbox 2(ConversationLstBx), i want to display the conversations i had with the selected contact in Listbox 1.

The problem is that i dont know how to get the Listbox 1 selectedItem.Id(the contact's id) so that i can use it in a query to select the conversations i had with the selected contact.

Also, any advice regarding what i am doing is highly appreciated.



C#:
C#
public class ContactViewModel : ViewModelBase
    {
        public ObservableCollection<Contact> ContactList;

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

public class ConversationViewModel : ViewModelBase
    {
        public ObservableCollection<Conversation> ConversationList;

        public ConversationViewModel()
        {
            ConversationList = new ObservableCollection<Conversation>(cbdc.Conversations);
        }

    }

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


        #region INotifyPropertyChanged

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


XAML:
XML
<ListBox x:Name="ContactsLstBx" HorizontalAlignment="Left" Height="289" Margin="10,50,0,0" VerticalAlignment="Top" Width="115" ItemsSource="{Binding ContactList}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Path=Name}" />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <ListBox x:Name="ConversationLstBx" HorizontalAlignment="Left" Height="134" Margin="333,50,0,0" VerticalAlignment="Top" Width="115" ItemsSource="{Binding ConversationList}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Path=Title}" />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>



Thank You!

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.