DataGrid绑定问题 [英] Issue with DataGrid binding

查看:132
本文介绍了DataGrid绑定问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我遇到了以下问题.
我使用DataGrid和MVVM模式.当绑定集合为空时,出现异常:

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



同样的问题在这里: http://wpf.codeplex.com/workitem/9699 [



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");
    }
}



如果隐藏了DataGrid,则可以,如果可见,则可以-清除绑定集合后,我得到了排除.



When DataGrid is hidden then ok, when visible - then after bound collection cleared I get excepetion

推荐答案

在同一Web参考中,来自WPF团队的Alexis被接受为错误并将在以后的版本中修复.有了这些信息,您可以联系WPF团队.
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.


这篇关于DataGrid绑定问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆