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

查看:255
本文介绍了在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天全站免登陆