Hi
I have met following problem.
I use DataGrid and MVVM pattern. When bound collection become empty I get exception:
The specified Visual is not an ancestor of this Visual
Same problem is here:
http://wpf.codeplex.com/workitem/9699[
^]
But nobody wrote about solution there...And also, I dont use grouping.
I cant find any solution in the Internet...S.O.S! :)
Thanks in advance
UPDATE:
<DataGrid Visibility="{Binding ElementName=btnListView, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"
ItemsSource="{Binding TitleContainsSearchResults, Mode=OneWay}" FocusVisualStyle="{x:Null}"
ColumnHeaderStyle="{StaticResource ResultsDataGridHeader}">
<datagrid.columns>.......</datagrid.columns>
Bound property:
public ObservableCollection<CatalogueResultItemViewModel> TitleContainsSearchResults
{
get
{
return titleContainsSearchResults;
}
set
{
titleContainsSearchResults = value;
OnPropertyChanged("TitleContainsSearchResults");
}
}
When DataGrid is hidden then ok, when visible - then after bound collection cleared I get excepetion