Trying to update a "Details" DataGrid
RowDetailsTemplate
in a "People" DataGrid
(Doing some crazy Inception stuff!).
The collection is being updated correctly with NotifyOfPropertyChange()
, but it doesn't seem to update the row in the DataGrid
.
The Header
"Adress Info" is there in the RowDetailsTemplate
, but no rows are showing up in that DataGrid
.
Models:
public class PersonModel
{
public string FirstName{ get; set; }
public string LastName{ get; set; }
}
public class DetailsModel
{
public string Address{ get; set; }
}
ViewModel:
private ObservableCollection<PersonModel> _people;
private ObservableCollection<PersonModel> People
{
get { return _people; }
set
{
_people = value;
NotifyOfPropertyChange(() => People);
}
}
private ObservableCollection<DetailsModel> _details;
private ObservableCollection<DetailsModel> Details
{
get { return _details; }
set
{
_details = value;
NotifyOfPropertyChange(() => Details);
}
}
public void SetRowDetail(PeopleModel selectedPerson)
{
PeopleModel person = selectedPerson;
DetailsModel detailInfo = new DetailsModel();
detailInfo.address = GetAddr(person.AddressIndex);
Details = new ObservableCollection<DetailsModel>() {detailInfo};
}
View:
<DataGrid x:Name="People"
Grid.Row="1"
cm:Message.Attach="[Event MouseUp]=[Action SetRowDetail($this)]">
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<StackPanel>
<TextBox Text="Person Details" />
<DataGrid x:Name="Details"
ItemsSource="{Binding TakeoutCoefficients}">
<DataGrid.Columns>
<DataGridTextColumn Header="Address Info"
Binding="{Binding Address, UpdateSourceTrigger=PropertyChanged}" />
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
I would like to achieve this without having to take out the RowDetailsTemplate
.
Tried BindableCollection and ItemsSource doesn't seem to help either.
Any help or suggestions would be greatly appreciated.