Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF DataGrid Binding
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! Smile | :)
 
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
Posted 17-Oct-11 11:09am
Edited 17-Oct-11 11:33am
v2
Comments
Collin Jasnoch at 17-Oct-11 16:21pm
   
You will need to provide more details such as some code snippets.
Renat Khabibulin at 17-Oct-11 16:28pm
   
Just DataGrid...ok, I ll add some sources now

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
0 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 17 Oct 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100