不能收集屬性綁定到數據網格行模板的Datagrid在DataGrid行模板
<DataTemplate x:Key="RowDetailsTemplate" DataType="{x:Type summons:IndividualDefendantSearchViewModel}">
<controls:ExtendedDataGrid
x:Name="RowDetails"
CanUserSortColumns="True"
ContentWidth="910"
DataContext="{Binding ElementName=Parent, Path=DataContext.GroupedSearchResults}"
Focusable="False"
HeadersVisibility="None"
IsSynchronizedWithCurrentItem="False"
ItemsSource="{Binding Path=SelectableIndividualDefendantSearchResults}"
ShowRowSelection="False">
<controls:ExtendedDataGrid.Columns>
<DataGridTextColumn
Width="*"
Binding="{Binding Name}"
Header="{localization:LanguageBinding ResourceKey=Name}" />
</controls:ExtendedDataGrid.Columns>
</controls:ExtendedDataGrid>
</DataTemplate>
我的數據模板
public class SelectableIndividualDefendantSearchResult : CheckedListItem<SearchResult>
{
public string Name
=> $"{Item.FirstName} {(string.IsNullOrEmpty(Item.Insertion) ? "" : Item.Insertion + " ")}{Item.LastName}";
}
public class GroupedSelectableIndividualDefendantSearchResult: EnhancedBindableBase
{
public DateTime? SearchDate { get; set; }
public ObservableCollection<SelectableIndividualDefendantSearchResult>
_selectableIndividualDefendantSearchResults;
public ObservableCollection<SelectableIndividualDefendantSearchResult>
SelectableIndividualDefendantSearchResults {
get { return _selectableIndividualDefendantSearchResults; }
set { SetProperty(ref _selectableIndividualDefendantSearchResults, value); }
}
}
我的財產:
public ObservableCollection<GroupedSelectableIndividualDefendantSearchResult> GroupedSearchResults
{
get { return _groupedSearchResults; }
set { SetProperty(ref _groupedSearchResults, value); }
}
主要的DataGrid的ItemSource是
ItemsSource="{Binding GroupedSearchResults}"
我可以看到SearchDate綁定到主行,但RowDataTemplate是空字符串...我做錯了什麼?
在您的IndividualDefendantSearchViewModel中是否有一個名爲'SelectableIndividualDefendantSearchResults'的屬性? –
不,SelectableIndividualDefendantSearchResults是GroupedSearchResults的一個屬性 –