双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

关于wpf的datagrid,自定义模板列,无法编辑的问题。

tj_libo tj_libo 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
目前做一个列表,datagrid用了模板列,列下分为3个textbox以横线隔开,相当于合并单元格。

<DataGridTextColumn Header="列名" Binding="{Binding ZQDGL13, Mode=TwoWay}" Width="50" ElementStyle="{StaticResource contentCenterStyle}"/>
<DataGridTemplateColumn Header="合并单元格的" Width="50" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50*"/>
<RowDefinition />
<RowDefinition Height="50*"/>
<RowDefinition />
<RowDefinition Height="50*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" x:Name="Baifenbi1" Text="{Binding Path=ZQDGL14.Baifenbi1, Mode=TwoWay}" VerticalAlignment="Center" Margin="3,3,3,3"/>
<Line Grid.Row="1" Stroke="Black" Stretch="Fill" X2="1" VerticalAlignment="Center"/>
<TextBlock Grid.Row="2" x:Name="Baifenbi2" Text="{Binding Path=ZQDGL14.Baifenbi2, Mode=TwoWay}" VerticalAlignment="Center" Margin="3,3,3,3"/>
<Line Grid.Row="3" Stroke="Black" Stretch="Fill" X2="1" VerticalAlignment="Center"/>
<TextBlock Grid.Row="4" x:Name="Baifenbi3" Text="{Binding Path=ZQDGL14.Baifenbi3, Mode=TwoWay}" VerticalAlignment="Center" Margin="3,3,3,3"/>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>


运行后 其他单元格都可以双击编辑,唯独这个合并模板,选中时选的是整个单元格,无法选中其中的某个textbox,也无法编辑textbox内容

请教如何实现编辑和单独选中啊。
...全文
评论 5
收藏 已收藏
分享
返回顶部
tj_libo
C# 111,129 成员 642,540 内容