简体   繁体   中英

In wpf How to bind dynamic textbox in listbox

I created a Listbox in XAML page. when I click the listbox double click it will turns the listitem to textbox.I want to modify the text using textbox. when click the enter button, the textbox turns to listitem.

 private void lstbxindex_MouseDoubleClick(object sender,MouseButtonEventArgs e)
    {
        System.Windows.Controls.TextBox txtNumber = new System.Windows.Controls.TextBox();
        txtNumber.Name = "ProjectlistItems";

        tb.KeyDown += new System.Windows.Forms.KeyEventHandler(tb_KeyDown);

        }
   private static void tb_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Enter)
        {
            txtNumber.Text = lstbxindex.SelectedItem.ToString();
            lstbxindex.Items.Add(txtNumber);

        }

You are clearly talking about making ListBoxItem Editable. You can refer here

Or just search for "Editable Listbox WPF" for better results.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM