none
Save edited listbox items RRS feed

  • Question

  • In my wpf app, I wrote code for editing contents of listbox items. Edit process is working fine. After editing I want to save those changes on that place only where I changed. so when I visit next time, there should be updated contents there.. How could I do that?

    My listbox consist of Horizontal stackpanel of six textboxes.

    As I used templates in my app, my code is,

        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            DataTemplate tmpl= (DataTemplate)this.FindResource("DefaultDataTemplate");
            if (listBox1.ItemTemplate == tmpl)
            {
                tmpl = (DataTemplate)this.FindResource("EditableDataTemplate");
                listBox1.ItemTemplate = tmpl;
                this.EditButton.Content = "Done Editing";
            }
            else
            {
                tmpl = (DataTemplate)this.FindResource("DefaultDataTemplate");
                listBox1.ItemTemplate = tmpl;
                this.EditButton.Content = "Edit";
            }
    
            // I just want to add here something to save those contents.
        }

    Monday, July 15, 2013 10:35 AM

Answers