Click here to Skip to main content
15,794,593 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:[^]

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

<DataGrid Visibility="{Binding ElementName=btnListView, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"
          ItemsSource="{Binding TitleContainsSearchResults, Mode=OneWay}"  FocusVisualStyle="{x:Null}"
          ColumnHeaderStyle="{StaticResource ResultsDataGridHeader}">

Bound property:
public ObservableCollection<CatalogueResultItemViewModel> TitleContainsSearchResults
        return titleContainsSearchResults;
        titleContainsSearchResults = value;

When DataGrid is hidden then ok, when visible - then after bound collection cleared I get excepetion
Updated 17-Oct-11 11:33am
[no name] 17-Oct-11 16:21pm    
You will need to provide more details such as some code snippets.
Renat Khabibulin 17-Oct-11 16:28pm    
Just DataGrid...ok, I ll add some sources now

1 solution

In the same web reference, Alexis from WPF team, accepted as the bug and will be fixed in the future releases. With this info, you can reach out WPF team.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900