简体   繁体   English

在wpf中如何在列表框中绑定动态文本框

[英]In wpf How to bind dynamic textbox in listbox

I created a Listbox in XAML page. 我在XAML页面中创建了一个Listbox。 when I click the listbox double click it will turns the listitem to textbox.I want to modify the text using textbox. 当我单击列表框双击它会将listitem转为textbox。我想使用文本框修改文本。 when click the enter button, the textbox turns to listitem. 单击“输入”按钮时,文本框将变为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. 您正在谈论使ListBoxItem可编辑。 You can refer here 你可以参考这里

Or just search for "Editable Listbox WPF" for better results. 或者只是搜索“可编辑列表框WPF”以获得更好的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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