【发布时间】:2011-05-23 14:19:58
【问题描述】:
假设我在 DataGridTemplateColumn 中有一个任意控件,我想知道如何获取该控件,因为我已检索到包含该控件的 DataGridCell。
我的包含 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);
扩展方法,包含在静态类中找到here
问题是,一旦获得 DataGridCell,如何检索“PercentageEditor”?有谁能够帮助我?任何帮助将不胜感激。谢谢!
【问题讨论】: