Okay, I figured out how to get this working I had to tweak the code that is posted in that MSDN article in the original question ....DataGridRow row = (DataGridRow)(KeywordsGrid.ItemContainerGenerator.ContainerFromItem(KeywordsGrid.SelectedItem));// Getting the ContentPresenter of the row detailsDataGridDetailsPresenter presenter = FindVisualChild<DataGridDetailsPresenter>(row);// Finding Remove button from the DataTemplate that is set on that ContentPresenterDataTemplate template = presenter.ContentTemplate;Button button = (Button)template.FindName("RemoveItemButton", presenter);"KeywordsGrid"是绑定到我的数据网格的变量.请注意,在我对FindVisualChild的调用中,我使用的是"DataGridDetailsPresenter"类,而不是"ContentPresenter"(这是关键……它迫使FindVisualChild方法一直遍历所有contentpresenters,直到我到达一个有关行的详细信息)."KeywordsGrid" is the variable tied to my datagrid. Notice in my call to FindVisualChild, i'm using a "DataGridDetailsPresenter" class instead of a "ContentPresenter" (This was the key ... it forced the FindVisualChild method to iterate all the way through all the contentpresenters until I got to the one for the row details). 这篇关于如何以编程方式访问数据网格行详细信息控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-23 17:56