我有数据网格单元格,在它下面我有一个文本框控件。如何使用路由事件调用该文本框控件的文本更改事件?我尝试了 EventSetter 但它不起作用。
这是代码:
<Style TargetType="{x:Type DataGridCell}" x:Key="DatagridCellWithTextbox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<TextBox x:Name="txtCell" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content.Text}" VerticalContentAlignment="Top" TextChanged="">
</TextBox>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
谢谢迪