在wpf中的列表框内绑定文本框列表 [英] Bind textbox list inside listbox in wpf

查看:27
本文介绍了在wpf中的列表框内绑定文本框列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须制作带有文本框的列表框...而且它必须是动态的.我在后面的代码中有可观察的集合,我想为列表框绑定它.我想要动态列表框,这个列表应该有可编辑的文本框.所以,基本上我想从列表框中绑定 multiplr 文本框.任何帮助将不胜感激

I have to make listbox with textbox in it... and it has to be dynamic. I have observable collection in code behind and I want to bind that for listbox. I want dynamic listbox and this list should have editable textbox in it. So, basically I want to bind multiplr textbox from listbox. Any help would be appreciated

<ListBox HorizontalAlignment="Left" Name="ListTwo" Height="100" Margin="286.769,165.499,0,0" VerticalAlignment="Top" Width="100" ItemsSource="{Binding Source=obs}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <TextBox Name="TextBoxList"></TextBox>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

通过这样做,我的文本框数量与可观察集合中的项目相同,但未设置文本框的文本.

By doing this, I have number of textbox same as items in observable collection but textbox's text is not set up.

推荐答案

您必须将您的文本框绑定到您已绑定的可观察集合的类中的属性

You will have to Bind your textbox to the property in your class of which observable collection you have bound

<ListBox HorizontalAlignment="Left" Name="ListTwo" Height="100" Margin="286.769,165.499,0,0" VerticalAlignment="Top" Width="100" ItemsSource="{Binding Source=obs}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <TextBox Binding="{Binding PROPERTYINCLASS}"></TextBox>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

这篇关于在wpf中的列表框内绑定文本框列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆