[英]C# WPF create dynamic textbox for each row of ListView
I would like to know, how to create dynamic textboxes for each row of a ListView.我想知道如何为 ListView 的每一行创建动态文本框。 I'm using a MVVM for my WPF Application.
我正在为我的 WPF 应用程序使用 MVVM。 If you have any Questions, then please ask me.
如果您有任何问题,请问我。
Let's say this is my ListView:假设这是我的 ListView:
And i would like to have a ListView and TextBoxes like this:我想要一个像这样的 ListView 和 TextBoxes:
The Cells right to the ListView are my TextBoxes. ListView 右侧的单元格是我的文本框。 Now my problem is: I want to create dynamiclly two TextBoxes for each row of my ListView.
现在我的问题是:我想为我的 ListView 的每一行动态创建两个文本框。 I'm new with WPF and i really would to know, how to create dynamic TextBoxes with the range of the rows in a ListView.
我是 WPF 的新手,我真的很想知道如何使用 ListView 中的行范围创建动态文本框。
I hope for help, grettings Nankatzu.我希望得到帮助,问候 Nankatzu。
I hope this can help.我希望这能有所帮助。 This must be for VB.Net part.
这必须是针对 VB.Net 的部分。 Maybe you can change it to C#
也许你可以把它改成 C#
For x = 0 To 4
Dim GridView1 As New GridViewColumn()
Dim datatemple1 As New DataTemplate()
Dim Textbox1 = New FrameworkElementFactory(GetType(TextBox))
datatemple1.VisualTree = Textbox1
GridView1.Header = "Employee No." & x
GridView1.Width = 100
GridView1.CellTemplate = datatemple1
UGridview1.Columns.Add(GridView1)
ListView1.Items.Add(datatemple1)
Next
ListView1.View = UGridview1
XAML part must like this: XAML 部分必须像这样:
<ListView x:Name="ListView1">
<ListView.View>
<GridView x:Name="UGridview1" >
</GridView>
</ListView.View>
</ListView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.