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

ReportViewer-Exception: A 'Binding' can only be set on a DependencyProperty of a DependencyObject.

2 Answers 273 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
wal1
Top achievements
Rank 1
wal1 asked on 09 Oct 2012, 03:30 PM
Hello!

I upgrade a project to "Telerik Reporting Q2 2012 SP2 (6.1.12.820)" from "(4.0.10.423)". The following code dont work, after the upgrade.
<UserControl x:Class="Sta1.UI.Modules.Reports.ReportDetailView"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:telerik="clr-namespace:Telerik.ReportViewer.Wpf;assembly=Telerik.ReportViewer.Wpf" mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300" x:Name="thisWindow">
  <Grid>
    <telerik:ReportViewer Report="{Binding DataContext.Report, ElementName=thisWindow}" />
  </Grid>
</UserControl>

The exception is:
A 'Binding' cannot be set on the 'Report' property of type 'ReportViewer'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.

In the ViewModel is this code:
...
    private Report _report;
    public Report Report
    {
      get { return _report; }
      private set
      {
        _report = value;
        NotifyOfPropertyChange(() => Report);
      }
    }
 
    public void SetReport(Report reportToShow)
    {
      Report = null;
      Report = reportToShow;
    }
...

Thanks in advance
wal1

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 09 Oct 2012, 03:37 PM
Hi wal1,

You now have to bind to the newly introduced ReportSource Property instead. In your ViewModel you can pass the respective report source (InstanceReportSource, UriReportSource, XmlReportSource or TypeReportSource). It has to be something like this:
Copy Code
<telerik:ReportViewer x:Name="ReportViewer1" ReportSource="{Binding MyReportSource}" />

In your ViewModel then you pass the appropriate report source to that property.

All the best,
Steve
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
wal1
Top achievements
Rank 1
answered on 10 Oct 2012, 04:46 AM
It works :o)

Thanks for your answer Steve
Tags
General Discussions
Asked by
wal1
Top achievements
Rank 1
Answers by
Steve
Telerik team
wal1
Top achievements
Rank 1
Share this question
or