Home Forums WPF controls Xceed DataGrid for WPF V1.1 – DataGridCollectionViewSource

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #23055 |

    I’ve just changed my CollectionViewSource to DataGridCollectionViewSource and am now getting the following:-

    ‘XamlParseException: ‘System.Windows.Data.BindingExpression’ value cannot be assigned to property ‘ItemsSource’ of object ‘Xceed.Wpf.DataGrid.DataGridControl’. A source must be specified. Error at object ‘System.Windows.Data.Binding’ in markup file’

    The XAML is:-

    <xcdg:DataGridCollectionViewSource x:Key=”notesDataView” Source=”{Binding Path=NotesDataModel.NotesData}” />

    <xcdg:DataGridControl x:Name=”notesDataGrid”
    BorderBrush=”Transparent”
    AutoCreateColumns=”False”
    ItemsSource=”{Binding Source={StaticResource notesDataView}}”
    CellEditorDisplayConditions=”CellIsCurrent”
    EditTriggers=”BeginEditCommand,CellIsCurrent,ActivationGesture”
    ValidationMode=”CellEndingEdit”>

    … again, was fine in V1.0.

    Thanks
    Michael

    Imported from legacy forums. Posted by Michael (had 8026 views)

    Xceed Support
    Member
    Post count: 5658

    Have you tried just using a static resource markup instead of a binding?

    ItemsSource=”{StaticResource notesDataView}”

    Imported from legacy forums. Posted by Marcus [Xceed] (had 700 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Marcus,

    That produces the following:-

    ‘XamlParseException: Cannot convert the value in attribute ‘ItemsSource’ to object of type ‘System.Collections.IEnumerable’. ‘Xceed.Wpf.DataGrid.DataGridCollectionViewSource’ is not a valid value for property ‘ItemsSource’. Error at object ‘notesDataGrid’ in markup file’

    Michael

    Imported from legacy forums. Posted by Michael (had 422 views)

    User (Old forums)
    Member
    Post count: 23064

    Will this be fixed in the service release or is there a workaround?

    Michael

    Imported from legacy forums. Posted by Michael (had 560 views)

    User (Old forums)
    Member
    Post count: 23064

    Michael,

    Could you provide a little more code/context?

    The exception you are getting is thrown by the DataGridCollectionViewSource because its Source property evaluates to null.

    Your DataGridCollectionViewSource.Source is set to a binding with no source specified (Source=”{Binding Path=NotesDataModel.NotesData}”), which probably makes the Binding return null.

    How were you declaring the “regular” CollectionViewSource with v1.0 of the DataGrid?

    Thanks,

    Imported from legacy forums. Posted by Pascal (had 916 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Pascal,

    You shouldn’t need to explicitly declare a Source.

    See:- http://msdn2.microsoft.com/en-us/library/system.windows.data.binding.source.aspx

    ‘By default, bindings inherit the data context specified by the DataContext property, if one has been set. However, the Source property is one of the ways you can explicitly set the source of a Binding and override the inherited data context. If you do not need the functionality of establishing a scope in which several properties inherit the same data context, you can use the Source property instead of the DataContext property.’

    I currently just use the following:-

    <ResourceDictionary>
    <CollectionViewSource x:Key=”notesDataView” Source=”{Binding Path=NotesDataModel.NotesData}” />
    </ResourceDictionary>

    <xcdg:DataGridControl x:Name=”notesDataGrid”
    ItemsSource=”{Binding Source={StaticResource notesDataView}}”>

    I set the DataContext further up the visual tree to my ViewModel. The DataGridControl inherits this and the binding will use it as it’s source. The path(NotesDataModel) is a property on the ViewModel.

    In other areas of the app I use quite a few of the techniques referred to in the remarks here:-
    http://msdn2.microsoft.com/en-us/library/system.windows.data.binding.path.aspx
    so it would be a big blow if the DataGridControl was non-standard.

    Let me know if you need any more info.

    Michael

    Imported from legacy forums. Posted by Michael (had 489 views)

    User (Old forums)
    Member
    Post count: 23064

    I understand…

    The problem is due to the current behavior of the DataGridCollectionViewSource, which expects its Source property to be non-null at init time.

    When the DGCVSource is first initialized, the Binding resolves to null because there is no DataContext yet, and the DGCVSource doesn’t like that.

    We are working on refactoring that part of the DGCVSource so it doesn’t assume that Source will always be non-null at init time.

    The fix might not be part of next week’s service release as we don’t want to delay that service release too much, but it should find its way in the next service release after that.

    Imported from legacy forums. Posted by Pascal (had 623 views)

    User (Old forums)
    Member
    Post count: 23064

    This issue affects me as well. What is the approximate release date for this bugfix?

    Also, does anyone have a workaround that works in markup? Thank you.

    Imported from legacy forums. Posted by Joao (had 474 views)

    User (Old forums)
    Member
    Post count: 23064

    The fix for this will be part of a service release which will be available in the week of June 25.

    Imported from legacy forums. Posted by Pascal (had 1357 views)

    User (Old forums)
    Member
    Post count: 23064

    Did the fix make it into the service release?

    Imported from legacy forums. Posted by valure (had 431 views)

    User (Old forums)
    Member
    Post count: 23064

    I dont know if anyone still reads this, but I am having this problem with a new download. Has this fix been released?

    Imported from legacy forums. Posted by Adam (had 709 views)

    User (Old forums)
    Member
    Post count: 23064

    Sorry for not following-up earlier… The fix did not make it into the last 1.1 service release for various reasons. It is part of version 1.2, though, which will be released in august.

    Imported from legacy forums. Posted by Pascal (had 897 views)

    User (Old forums)
    Member
    Post count: 23064

    I’m having the same problem. Could you notify us when you release new version?

    Imported from legacy forums. Posted by Lena (had 8608 views)

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.