Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Binding CustomReportItem to Data (Read 4056 times)
seifedias
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 1
Joined: Jan 20th, 2012
Binding CustomReportItem to Data
Jan 20th, 2012 at 8:12pm
Print Post  
Hi,

I just downloaded the ReportingTrial to take a closer look. I added a CustomReportItem to arrange some Data:

Code
Select All
<r:CustomReportItem Name="Kopf" Location="20,10" Width="300" Height="100">
           <r:CustomReportItem.Template>
               <DataTemplate>
                   <Grid>
                       <Grid.ColumnDefinitions>
                           <ColumnDefinition></ColumnDefinition>
                           <ColumnDefinition></ColumnDefinition>
                           <ColumnDefinition></ColumnDefinition>
                       </Grid.ColumnDefinitions>
                       <TextBlock Text="[Name]" />
                       <TextBlock Grid.Column="1" Text="[Vorname]" />
                       <TextBlock Grid.Column="2" Text="[Alter]" />
                   </Grid>
               </DataTemplate>
           </r:CustomReportItem.Template>
       </r:CustomReportItem>
 


Now I'm trying to bind the textblocks to a datasource by setting the Datacontext-property of the CustomReportItem to display actual data instead of static text. Unfortunatly it just won't work.

Can anybody tell me how to achieve this? The datasource is a class which exposes the properties "Name", "Vorname" and "Alter".

Thanks for any answers
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Binding CustomReportItem to Data
Reply #1 - Jan 23rd, 2012 at 8:15am
Print Post  
Try the following custom item template:

Code
Select All
<r:CustomReportItem Name="Kopf" Location="20,10" Size="300,100" Value="{Binding}">
      <r:CustomReportItem.Template>
            <DataTemplate>
                  <Grid>
                        <Grid.ColumnDefinitions>
                              <ColumnDefinition></ColumnDefinition>
                              <ColumnDefinition></ColumnDefinition>
                              <ColumnDefinition></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="{Binding Name}" />
                        <TextBlock Grid.Column="1" Text="{Binding Vorname}" />
                        <TextBlock Grid.Column="2" Text="{Binding Alter}" />
                  </Grid>
            </DataTemplate>
      </r:CustomReportItem.Template>
</r:CustomReportItem> 



The following changes were made:

1. The size of the report items needs to be specified through ReportItem.Size, rather than setting it through the FrameworkElement properties directly.

2. The item's Value is bound to the current DataContext so that the bindings inside the item can be resolved properly.

3. The MindFusion reporting expressions (those surrounded in square brackets) can be used directly only for the MindFusion.Reporting.Wpf.Label.Text and MindFusion.Reporting.Wpf.CustomReportItem.Value properties. You can still use them for any other property through the Expression extension, but it is easier to simply use regular WPF bindings instead. In the above case the TextBlock.Text property values have been changed to regular bindings.

I hope this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint