【发布时间】:2011-09-09 23:34:22
【问题描述】:
我为 ListView 中的项目编写了一个自定义 DataTemplate,如下所示:
<DataTemplate x:Key="CustomerStateTemplate">
<Grid Margin="5, 5, 5, 5">
<Grid.ColumnDefinitions>
...
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
...
</Grid.RowDefinitions>
<Image Grid.Row="0" Grid.RowSpan="2" Width="24" Height="20" ... />
<TextBox Style="{StaticResource CustomerStyle}" Grid.Column="0"
Grid.Row="0" Grid.ColumnSpan="2"
Name="nameField">
<TextBox.Text>
<Binding Path="Name" />
</TextBox.Text>
</TextBox>
...
我已经获得了我的漂亮风格。 现在,如果我想选择该项目,我必须单击模板控件之间的空白。如果我单击 ListViewItem 中的文本框,它不会像项目一样选择。那么,有没有办法通过点击模板中的控件来选择 ListViewItem?
万分感谢!
【问题讨论】:
-
你在尝试将
textbox用作lable吗? -
可以,但我希望直接更新内容。我对组合框也有同样的问题
标签: c# .net wpf wpf-controls datatemplate