Binding RowDetails in WPF DataGrid


I cant seem to find how to do this.

I dont see why the datacontext for a rowdetailstemplate becomes the datacontext of the datagrid parent. When it cleary should choose the rowitem from the datagrid itemssource.

<DataGrid Grid.Row="1" x:Name="DataGrid" ItemsSource="{Binding Collection}" <DataGrid.RowDetailsTemplate> <DataTemplate> <TextBox Text="{Binding WhyDoesThisBindingUseDataContextOfDatGridParentAndNotTheRowDataObject}"/> </DataTemplate> </DataGrid.RowDetailsTemplate></DataGrid>

How can i get the rowdataobject as the datacontext for my template?


Look at the visual tree.

<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/PRRfW.jpg" data-original="https://i.stack.imgur.com/PRRfW.jpg" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Object which you binds to ItemsSource doesn't apply to RowDetailsTemplate. It takes DataContext of DataGrid Parent.


  • Only select only one radio button from listview
  • Cannot customize Navigation Drawer
  • Persist selected rows the correct way
  • Persist selected rows the correct way
  • DataBound ListBox and Button inside a ScrollViewer/StackPanel construct, with Button appearing below
  • Wiring up CollectionChanged and PropertyChanged (Or : Why do some WPF Bindings not refresh?)
  • Bind customObject to DataGrid
  • WPF: binding several views to a TabControl's items
  • Is DataGrid an alternative for UWP?
  • Using ListPicker and DataBinding
  • Flyout.showAt() ArgumentException based on Content
  • DataGrid: Help accessing a control defined in a CellEditingTemplate
  • Why is wpf UpdateSourceTrigger not binding explicitly?
  • How to get instance of the GridControl in LookupEdit (Devexpress)
  • Return list instead of an item Webservice Phone 8.1 UAP
  • Visualizing 2D Data in a Table
  • Programmatically setting the record pointer in a C# DataGridView
  • How to use a MultiBinding on DataGridTextColumn?
  • Add items to ComboBox at runtime?
  • Binding ContextMenu Tag to Owner
  • How to prompt user that edits have been made upon changing pages or sorting in Kendo Grid
  • Binding from within a ResourceDictionary in a Catel WPF UserControl
  • Different Datacontext for Command and CommandParameter
  • How to start server for Selenium grid Java Maven setup
  • Allocating a 2D contiguous array within a function
  • Dynamically load css stylesheet and wait for it to load
  • Drawing a Path in XAML (with binding) vs. C#. One works, one doesn't
  • Consuming a WCF service in a Java Client using wsHttpBinding
  • Force show.bind execution
  • Get one-time binding to work for ng-if
  • QuartzCore.framework for Mono Develop
  • Unanticipated behavior
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • Can't mass-assign protected attributes when import data from csv file
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app
  • java string with new operator and a literal
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize