Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
HTML
<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:
C#
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
Posted
Updated 17-Oct-11 10:33am
v2
Comments
[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