使用Checkbox和Textbox创建ListView [英] Create a ListView with Checkbox and Textbox
本文介绍了使用Checkbox和Textbox创建ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!我是WPF的新手,我正在尝试创建一个Listview,其中包含带有标签的复选框和复选框旁边的文本框。 XAML标记如下所示:
Hi! I'm quite new to WPF and I'm trying to create a Listview with items that consists of a checkbox with label and a textbox next to the Checkbox. The XAML markup looks like this:
<ListView ItemsSource="{Binding PricingList}" Margin="0,49,0,238" SelectionMode="Extended" x:Name="lvItems">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<CheckBox IsChecked="{Binding IsChecked}" Content="{Binding Path=Item.Display}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked">
</CheckBox>
<TextBox Text="{Binding Path=Item.Menge}" Margin="10,10,0,0">
</TextBox>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
数据绑定效果很好。问题是这些物品看起来很奇怪。我相信标记是灾难性的。我希望有人帮助我...
The databinding works very well. Problem is the items are looking very weird. I believe the markup is rather catastrophic. I hope anyone an help me...
推荐答案
<ListViewItem ItemsSource="{Binding PricingList}" Margin="0,49,0,238" SelectionMode="Extended" x:Name="lvItems">
<CheckBox IsChecked="{Binding IsChecked}" Content="{Binding Path=Item.Display}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Item.Menge}" Margin="10,10,0,0"></TextBlock>
</StackPanel>
</CheckBox>
</ListViewItem>
这篇关于使用Checkbox和Textbox创建ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文