This is a migrated thread and some comments may be shown as answers.

[Solved] I am trying to simply bind to a class in the codebehind and am getting a BindingExpression Error

8 Answers 76 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ed
Top achievements
Rank 1
Ed asked on 04 Mar 2013, 02:57 PM

I am trying to simply bind to a class in the codebehind and am getting a BindingExpression Error

It works fine if I try add the itemsource from code behind as so

            ReportGrid.ItemsSource = SampleDataPeople;

But when I add via Binding I get this and no

Error: BindingExpression path error: 'SampleDataPeople' property not found on
'GridApp.Data.SampleDataItem, GridApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
BindingExpression: Path='SampleDataPeople' DataItem='GridApp.Data.SampleDataItem, GridApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'; target element is 'Telerik.UI.Xaml.Controls.Grid.RadDataGrid' (Name='ReportGrid'); target property is 'ItemsSource' (type 'Object')
'GridApp.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\system32\WinMetadata\Windows.Devices.winmd'

<telerikGrid:RadDataGrid x:Name="ReportGrid"
           ItemsSource="{Binding SampleDataPeople }"
           AutoGenerateColumns="False" >
 
           <telerikGrid:RadDataGrid.Columns >
           <telerikGrid:DataGridTextColumn PropertyName="FirstName" Header="FirstName"/>
           <telerikGrid:DataGridTextColumn PropertyName="LastName" Header="LastName"/>
       </telerikGrid:RadDataGrid.Columns>
            
   </telerikGrid:RadDataGrid>

 

public ObservableCollection<SampleDataPerson> sampleDataPeople;
      public ObservableCollection<SampleDataPerson> SampleDataPeople
      {
          get { return sampleDataPeople; }
          set
          {
              sampleDataPeople = value;
              RaisePropertyChanged("SampleDataPeople");
          }
      }

 

 

 

8 Answers, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 04 Mar 2013, 04:54 PM
Hi Ed,

Thank you for contacting us.

I have prepared a working project using the given code snippets. Please, find the attached file.
Can you please clarify if this is working on your side too and if yes - can you modify it in order to reproduce the described issue?

I am looking forward to your reply.

 

Kind regards,
Ivaylo Gergov
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Ed
Top achievements
Rank 1
answered on 04 Mar 2013, 06:40 PM
Thanks, based on that I think I see the issue, I assumed that I did not need a separate class as the viewmodel and the binding would find the People class in the code behind.  Ill make a separate VM like you did and it will probably be fine.

Ed,
0
Ed
Top achievements
Rank 1
answered on 05 Mar 2013, 02:06 PM
Ivaylo, first thanks for helping.
I want to say that once I put my code all back in it once again stoped working.

it looks like I am using an await method so wondering if that is the reason?

namespace GridApp.Controls
{
    public partial class CtlReport : UserControl
    {
        CtrlReportViewModel vm;
      
        public  CtlReport()
        {
            this.InitializeComponent();
 
            vm = new CtrlReportViewModel();
            this.ReportGrid.DataContext = vm;
 
// this loads grid
            vm.LoadDataNoAsync();
// this does not
//            vm.LoadData();
        }
    }
}



using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace GridApp.Controls
{
    class CtrlReportViewModel : INotifyPropertyChanged
    {
        public void LoadDataNoAsync()
        {
            ServiceReference.RemoteHostServiceClient client = new ServiceReference.RemoteHostServiceClient();
            var favorites = client.UserFavoriteGetAsync(Globals.Id, "widget");
            ReportData = new ObservableCollection<ReportsDataItem>();
            foreach (var f in favorites.Result)
            {
                var userWidget = client.UserWidgetByIdGetAsync(f.ObjectID);
                ReportData.Add(new ReportsDataItem()
                {
                    Description = userWidget.Result.Description,
                    Id = userWidget.Result.Id,
                });
                RaisePropertyChanged("ReportData");
 
                System.Diagnostics.Debug.WriteLine("Owner {0}, Description {1}", userWidget.Result.Id, userWidget.Result.Description);
            }
        }
 
 
        public async void LoadData()
        {
            ServiceReference.RemoteHostServiceClient client = new ServiceReference.RemoteHostServiceClient();
            var favorites = (await client.UserFavoriteGetAsync(Globals.Id, "widget")).ToList();
            ReportData = new ObservableCollection<ReportsDataItem>();
            foreach (var f in favorites)
            {
                var userWidget = (await client.UserWidgetByIdGetAsync(f.ObjectID));
                ReportData.Add(new ReportsDataItem()
                {
                    Description = userWidget.Description,
                    Id = userWidget.Id,
                });
                RaisePropertyChanged("ReportData");
 
                System.Diagnostics.Debug.WriteLine("Owner {0}, Description {1}", userWidget.Id, userWidget.Description);
            }
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
        private ObservableCollection<ReportsDataItem> reportData;
 
        public ObservableCollection<ReportsDataItem> ReportData
        {
            get
            {
                return reportData;
            }
            set
            {
                reportData = value;
                RaisePropertyChanged("ReportData");
            }
 
        }
 
        private void RaisePropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(name));
            }
        }
    
}

<UserControl

x:Class="GridApp.Controls.CtlReport"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:local="using:GridApp.Controls"

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

xmlns:telerikGrid="using:Telerik.UI.Xaml.Controls.Grid"

mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"

x:Name="reportctl">

<StackPanel>

<telerikGrid:RadDataGrid x:Name="ReportGrid"

ItemsSource="{Binding ReportData}"

AutoGenerateColumns="False">

<telerikGrid:RadDataGrid.Columns >

<telerikGrid:DataGridTextColumn PropertyName="Description" Header="Description"/>

<telerikGrid:DataGridTextColumn PropertyName="Id" Header="Owner"/>

</telerikGrid:RadDataGrid.Columns>

</telerikGrid:RadDataGrid>

</StackPanel>

</UserControl>

0
Ivaylo Gergov
Telerik team
answered on 07 Mar 2013, 11:49 AM
Hello Ed,

Thank you for getting back to us.

I tried to reproduce this issue but with no result. It seems that our RadDataGrid works fine with async methods. Today we uploaded a new internal build that fixes several issues in RadDataGrid. Could you please give the latest bits a try and in case you still experience issues I will need a runnable demo project that reproduces the problem so that I can debug it locally and isolate its cause.

I am looking forward to your reply.

 

All the best,
Ivaylo Gergov
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Ed
Top achievements
Rank 1
answered on 07 Mar 2013, 02:30 PM
> Today we uploaded a new internal build that fixes several issues in RadDataGrid.
Is there a link to the new build?

The download link still has
RadControlsForWindows8Setup_2013_1_219
0
Ivaylo Gergov
Telerik team
answered on 07 Mar 2013, 03:47 PM
Hello Ed,

In order to have access to internal builds you first have to purchase or download a trial version of our latest official release. Then you can see the internal builds from your account - Manage Products -> Latest Internal Builds.

I hope this information helps.

Regards,
Ivaylo Gergov
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Ed
Top achievements
Rank 1
answered on 13 Mar 2013, 06:40 PM
I have logged into my account
Download the Windows 8 RAD Controls (2013_1_219)
Went to Managed Products > Latest internal builds

I see do not see any new builds only
!No internal builds for your products have been uploaded recently.
Has there been any updates past 2013_1_219?


0
Apo
Telerik team
answered on 18 Mar 2013, 03:35 PM
Hi Ed,

Thank you for contacting us.

Could you please provide the e-mail address with which you log into our system as I do not see active licenses or trials under the account of www@gencode.com.

Looking forward to hearing from you.

Greetings,
Apo
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
General Discussions
Asked by
Ed
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Ed
Top achievements
Rank 1
Apo
Telerik team
Share this question
or