假设我有一个任意控件在DataGridTemplateColumn中,我想知道如何获取该控件,假设我已经检索到包含该控件的DataGridCell。
包含DataGrid的XAML文件如下:
包含DataGrid的XAML文件如下:
<DataGrid Name="dgMovement">
...
<DataGridTemplateColumn Header="Target %">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<vi:PercentageEditor Value="{Binding TargetPercentage, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" Width="100px"
cal:Message.Attach="[Event PreviewLostKeyboardFocus] = [Action ChangeTargetPercentage];[Event PreviewGotKeyboardFocus] = [Action OnFocus]"
Name="aa" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>...
我使用以下扩展方法检索了DataGridCell:
DataGridCell cell = view.dgMovement2.GetCell(index, 6);
这个静态类中的扩展方法可以在这里找到。
问题是,一旦我得到了DataGridCell,如何检索“PercentageEditor”?有人可以帮我吗?任何帮助将不胜感激。谢谢!