- Welcome, Guest. Please Login or Register
MindFusion  
  We have released initial version of MindFusion.Scheduling library for HTML5 & JavaScript.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Binding CustomReportItem to Data
Read 2163 times

seifedias   Offline
YaBB Newbies
*
Posts: 1
I Love MindFusion!


   
     
 
Binding CustomReportItem to Data
Jan 20th, 2012 at 8:12pm
 
Hi,

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

Code:
<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
 
 
 
IP Logged    
 
     

Meppy   Offline
YaBB Moderator
*****
Posts: 1783
Gender: male
MindFusion support


   
     
 
Re: Binding CustomReportItem to Data
Reply #1 - Jan 23rd, 2012 at 8:15am
 
Try the following custom item template:

Code:
<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
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print