DynamicClass1 BindingExpression with VirtualQueryableCollectionView

12 posts, 0 answers
  1. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 10 Jan 2011 Link to this post

    Hello,
    I adapted your virtual data loading sample to my own silverlight WCF RIA Services project.

    I'm using version 2010.3.1110.1040.

    I'm geting binding expressions:
    Erreur System.Windows.Data : erreur de chemin d'accès BindingExpression : propriété 'Nom' introuvable sur '{}' 'DynamicClass1' (HashCode=0). BindingExpression : Path='Nom' DataItem='{}' (HashCode=0); l'élément cible est 'Telerik.Windows.Controls.GridView.GridViewCell' (Name=''); la propriété cible est 'Value' (type'System.Object')...

    Etc for all the properties of my object.

    My grid is:
    <telerik:RadGridView x:Name="grdCustomerList" ItemsSource="{Binding Customers}" AutoGenerateColumns="False" ShowGroupPanel="False" IsFilteringAllowed="False">
                                                    <telerik:RadGridView.Columns>
                                                        <telerik:GridViewDataColumn Header="ID" DataMemberBinding="{Binding CliID}" />
                                                        <telerik:GridViewDataColumn Header="Civ" DataMemberBinding="{Binding Civ}" />
                                                        <telerik:GridViewDataColumn Header="Structure" DataMemberBinding="{Binding Structure}" />
                                                        <telerik:GridViewDataColumn Header="Nom" DataMemberBinding="{Binding Nom}" />
                                                        <telerik:GridViewDataColumn Header="Prénom" DataMemberBinding="{Binding Prenom}" />
                                                    </telerik:RadGridView.Columns>
                                                </telerik:RadGridView>

    My viewmodel is:
    using System;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
     
    using Telerik.Windows.Data;
    using Telerik.Windows.Controls;
    using System.ServiceModel.DomainServices.Client;
    using Ogaca.Web;
     
    namespace Project
    {
        public class VirtualClientDatacontext : ViewModelBase
        {
            OgContext _Context;
            public OgContext Context
            {
                get
                {
                    if (_Context == null)
                    {
                        _Context = new OgContext();
     
                    }
     
                    return _Context;
                }
            }
     
            VirtualQueryableCollectionView _Customers;
            public VirtualQueryableCollectionView Customers
            {
                get
                {
                    if (_Customers == null)
                    {
                        _Customers = new VirtualQueryableCollectionView();
                        _Customers.VirtualItemCount = 100; // Force ItemsLoading to get the real total item count and data in a single request
                        _Customers.LoadSize = 10;
     
                        _Customers.ItemsLoading += Customers_ItemsLoading;
                    }
     
                    return _Customers;
                }
     
                private set
                {
                    if (this._Customers != value)
                    {
                        _Customers.ItemsLoading -= Customers_ItemsLoading;
     
                        this._Customers = value;
                        this.OnPropertyChanged("Customers");
                    }
                }
            }
     
            void Customers_ItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)
            {
                EntityQuery<Client> query = Context.GetClientsQuery();
                query.IncludeTotalCount = true;
                Context.Load<Client>(EntityQueryExtensions.Sort<Client>(query, Customers.SortDescriptors).Skip(e.StartIndex).Take(e.ItemCount),
                    LoadBehavior.RefreshCurrent, CustomersLoaded, e.StartIndex);
            }
     
            private void CustomersLoaded(LoadOperation lo)
            {
                if (lo.TotalEntityCount != Customers.VirtualItemCount)
                {
                    Customers.VirtualItemCount = lo.TotalEntityCount;
                }
     
                Customers.Load((int)lo.UserState, lo.Entities);
            }
     
            public void ClearLoadedCustomers()
            {
                this.Customers = null;
            }
        }
    }

    And the loading happens here:
    public MainPage()
    {
        InitializeComponent();
        MainPageObject = this;
        this.loginContainer.Child = new LoginStatus();
        App.Current.Host.Content.FullScreenChanged += new EventHandler(Content_FullScreenChanged);
     
        DataContext = new VirtualClientDatacontext();
    }

    It looks like there is a dynamic class generated as a proxy for me...

    I tought I'm doing exactly the same then in the sample, but obviously not...

    Thank you for your help...

    John.





  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 13 Jan 2011 Link to this post

    Hi John,

     Can you send us small example project (via support ticket) where we can reproduce this? We are about also to release our first service pack (before the end of this week). Can you test the same scenario with our latest binaries (when available)? 

    All the best,
    Vlad
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. DevCraft banner
  4. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 16 Jan 2011 Link to this post

    Hello Vlad, 
    I posted a support ticket two days ago but just to confirm like you asked that the "problem" is still present in the latest SP1.
    Kind regards,
    John. 
  5. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 17 Jan 2011 Link to this post

    Hi John,

    Thank you for sharing your code. We will be looking at this problem as soon as possible.


    All the best,
    Milan
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  6. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 17 Jan 2011 Link to this post

    Hello John,

    I've checked your code and I've found that even that you've assigned DataContext for the MainMage to be the VirtualClientDatacontext (with single property Customers) you are still trying to access various other properties like RadComboBox binding - ItemsSource="{Binding Clients}". 

    Kind regards,
    Vlad
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  7. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 17 Jan 2011 Link to this post

    Hello Vlad,
    Thank you very much for looking into this.
    It's true that I'm still a beginner in silverlight so please excuse my eventual dumb questions ;)

    This is to say that I do not understand your suggestion. In fact I  understand but I don't see what I can do with it to correct my code.
    I tried removing the combo you are talking about. I did also set the VirtualClientDatacontext to the datacontext of the grid only to make sure only the grid will try to bind to the VirtualClientDatacontext. Even with that I still have the binding errors.

    Would you be so kind and tell me the changes I should make to correct my problem. I understand that this may have nothing to do with your controls. But I permit myself to ask you as this seems obvious to you and not to me :)

    Thanks a lot in advance,
    John.
  8. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 17 Jan 2011 Link to this post

    Hello John,

     Please make sure that all bindings declared in XAML are correctly pointing to existing properties or your DataContext. 

    Greetings,
    Vlad
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  9. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 03 Feb 2011 Link to this post

    To me all the properties seems mapped correctly...
    Any exemple of a property not mapped correctly in my sample?

    Tell me something...
    May I have those errors because I'm not using the SP1 of WCF RIA Services ?
    Is the SP1 required?
  10. Arkadiusz
    Arkadiusz avatar
    2 posts
    Member since:
    Apr 2012

    Posted 24 Aug 2012 Link to this post

    Hi.

    I had same issue.
    Binding Exceptions are getting caught, so it wasn't problem with one column.
    But when I started using it for real with around 10 columns, it slowed down view initialization process to unacceptable levels.

    It is DataVirtualization issue in my opinion that could be solved, but is hard.

    Anyway... I figured out reason and easy fix for my scenario.

    Grid is expecting properties that do not exist in virtual items. But they do exist in loaded items.

    My first thought was that grid is using some sort of placeholders to imitate incoming data but it does'nt know ahead of time, format of data... SO it shouldn't use binding before real item comes in.

    Fix is to initialize view with VirtualItemCount = 0;
    And then just start filling the grid with first load, it will adjust VirtualItemsCount automatically.
  11. Wenrong
    Wenrong avatar
    36 posts
    Member since:
    May 2012

    Posted 12 Sep 2012 Link to this post

    I experience the same issue as well, it happens when using ItemsLoading event to populate the data.

    So I had to use the VirtualQueryableCollectionView(query) method.
  12. Yezdi
    Yezdi avatar
    14 posts
    Member since:
    Feb 2011

    Posted 21 Feb 2013 Link to this post

    Can you please provide a solution to the above question posted by Wenrong.
     I am facing the same issue while using VirtualQueryableCollection
    .
  13. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 22 Feb 2013 Link to this post

    Hello,

     Please see my reply here.

    Regards,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner