This is a migrated thread and some comments may be shown as answers.
DynamicClass1 BindingExpression with VirtualQueryableCollectionView
11 Answers 112 Views
This is a migrated thread and some comments may be shown as answers.
Jonx
Top achievements
Rank 2
Jonx asked on 10 Jan 2011, 01:04 PM
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.





11 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 13 Jan 2011, 04:18 PM
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>>
0
Jonx
Top achievements
Rank 2
answered on 16 Jan 2011, 01:03 PM
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. 
0
Milan
Telerik team
answered on 17 Jan 2011, 10:07 AM
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>>
0
Vlad
Telerik team
answered on 17 Jan 2011, 11:32 AM
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>>
0
Jonx
Top achievements
Rank 2
answered on 17 Jan 2011, 12:07 PM
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.
0
Vlad
Telerik team
answered on 17 Jan 2011, 12:59 PM
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>>
0
Jonx
Top achievements
Rank 2
answered on 03 Feb 2011, 07:02 PM
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?
0
Arkadiusz
Top achievements
Rank 1
answered on 24 Aug 2012, 08:36 AM
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.
0
Wenrong
Top achievements
Rank 1
answered on 12 Sep 2012, 11:13 PM
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.
0
Yezdi
Top achievements
Rank 1
answered on 21 Feb 2013, 06:35 PM
Can you please provide a solution to the above question posted by Wenrong.
 I am facing the same issue while using VirtualQueryableCollection
.
0
Vlad
Telerik team
answered on 22 Feb 2013, 06:56 AM
Hello,

 Please see my reply here.

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Asked by
Jonx
Top achievements
Rank 2
Answers by
Vlad
Telerik team
Jonx
Top achievements
Rank 2
Milan
Telerik team
Arkadiusz
Top achievements
Rank 1
Wenrong
Top achievements
Rank 1
Yezdi
Top achievements
Rank 1
Share this question
or