Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2549
Binding DataPresenter to List<DateTime>
posted

Hi all,

I have a problem binding a List<DateTime> to a DataPresenter.

When binding it with AutogenerateFields = true everything works fine, but I want to define the fields in XAML like that (this is created by the tip of Josh Smith [http://blogs.infragistics.com/blogs/josh_smith/archive/2008/10/03/how-to-avoid-typing-fieldlayout-xaml.aspx]:

 

<igDP:XamDataPresenter.FieldLayouts>

 

 

 

 

 

 

<igDP:FieldLayout>

 

 

 

 

<igDP:FieldLayout.Fields>

 

 

 

 

<igDP:Field Name="Value" />

 

 </igDP:FieldLayout.Fields>

 

 

 

 

 

 

</igDP:FieldLayout>

 

 

 

 

 

 

 

 

</igDP:XamDataPresenter.FieldLayouts>

 

 

 The Grid is always empty, until I switch back to AutoGenerateFields = true
Binding is done in code while ThePlan.TheDates is a List<DateTime>:

this

 

 

.dpThePlan.DataSource = ThePlan.TheDates;

 

Any ideas on this one?
Have a great day and best regards
Andy

Parents
  • 69686
    Verified Answer
    posted

    Hello Andy,

    This is because the Fields use the name of the public properties to bind to the underlying data. As DataTime (and int, string, bool, etc.) are atomic types they do not have names and that is why "Value" is used. If you are binding to List<DateTime> then you would always have only one FieldLayout and only on Field, so you could leave the XamDataGrid create this and set the Field's properties through the FieldSettings/ FieldLayoutSettings objects. If that is not an option, you can try with UnboundField and setting its BindingPath property, which should be able to bind to "Value".

Reply Children
No Data