Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Associated data editing with DataForm RSS

7 replies

Last post Jul 28, 2009 01:59 PM by arsher

(0)
  • arsher

    arsher

    0 Points

    6 Posts

    Associated data editing with DataForm

    Jul 12, 2009 11:26 AM | LINK

    I have an entity with a foreign key relationship and I'm trying to edit it on a DataForm. There is no problem as long as I edit simple data members but when I do the same on the associated data members the editing has no effect on the commit button, it remains disabled and if I try to cancel the changes it does not do that either. In the May CTP this worked correctly. Am I missing some changes/options etc. or is there any workaround for this one?

    Thank You.

  • Jonathan Shen – MSFT

    Jonathan She...

    All-Star

    50156 Points

    4951 Posts

    Microsoft

    Re: Associated data editing with DataForm

    Jul 17, 2009 05:47 AM | LINK

    Hi Arsher,

    3.9 DataForm Changes

    The DataForm control has been removed from the SDK. It is now in the Silverlight Toolkit, which is available at http://www.codeplex.com/Silverlight.

    The largest change related to DataForm impacts anyone using the Fields collection in the DataForm, and is as follows:

     

    DataFormFields have all been removed and DataForm.Fields collection has been removed. They have been replaced with the new DataField control, which is a control that wraps content with a label and DescriptionViewer. Also, note that you must now explicitly specify Mode=TwoWay on bindings in the DataField, whereas before you could just specify the path and the DataFormField would inject TwoWay into the binding. For example, if you have the following in the Fields collection:

     

    <dataControls:DataFormTextField Binding="{Binding FirstName}" />
    

     

     

    you would want to instead place this in the EditTemplate:

     

    <dataControls:DataField>
        <TextBox Text="{Binding FirstName, Mode=TwoWay}" />
    </dataControls:DataField>
    

     

    Note that since these are now controls, DataFormFieldGroups can be replaced just with regular panels.

     

    Also note that since these are now controls unto themselves, the DataForm no longer handles all of the alignment of the labels in these fields. The DataForm will group these fields together at the top level, but if you want more fine-tuned grouping (for example, two columns of fields), you can use the attached property DataField.IsFieldGroup on a Panel to specify that the DataFields within the Panel should have their labels grouped together in width. The following shows an example:

     

    <StackPanel Orientation="Horizontal">
        <StackPanel dataControls:DataField.IsFieldGroup="True">
            <dataControls:DataField>
                <TextBox Text="{Binding FirstName, Mode=TwoWay}" />
            </dataControls:DataField>
            <dataControls:DataField>
                <TextBox Text="{Binding LastName, Mode=TwoWay}" />
            </dataControls:DataField>
        </StackPanel>
        <StackPanel dataControls:DataField.IsFieldGroup="True">
            <dataControls:DataField>
                <TextBox Text="{Binding StreetAddress, Mode=TwoWay}" />
            </dataControls:DataField>
            <dataControls:DataField>
                <TextBox Text="{Binding State, Mode=TwoWay}" />
            </dataControls:DataField>
        </StackPanel>
    </StackPanel>
    

     

    This would cause the FirstName/LastName DataFields to have their labels the same width, and similarly for StreetAddress/State DataFields.

     

    That represents the bulk of this breaking change. In addition, there are other breaking changes on the DataForm which are as follows:

     

    • FieldEditEnding and FieldEditEnded have been removed.

    • GetFieldElement() has been removed.

    • ItemEditEnding, ItemEditEnded, CommitItemEdit() have been changed to EditEnding, EditEnded, and CommitEdit() respectively.

    • CanMoveToXXXXItem have been removed, as they can be derived from the collection given to the DataForm.

    • CanUserAdd/DeleteItems have been removed, as they are implied through CommandButtonsVisibility.

    • IsEditing and IsAddingItem have been removed, as they are implied through Mode.

    • FieldLabelPosition and FieldLabelStyle have become LabelPosition and LabelStyle.

    • WrapAfter and Orientation have been removed.

    • The type names DataFormFieldLabelPosition and DataFormDescriptionViewerPosition have been changed to DataFieldLabelPosition and DataFieldDescriptionViewerPosition.

     These are the changes, take a look.  If it doesn't work, please share a repro with us.  Thanks

    Best regards,

    Jonathan 

    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
  • arsher

    arsher

    0 Points

    6 Posts

    Re: Re: Associated data editing with DataForm

    Jul 20, 2009 07:08 AM | LINK

    I made some experimenting and i was led to the following conclusion:
    The entity classes generated by RIA framework are implementing the INotifyPropertyChanged interface but if I edit an entityreference in an entity the dataform is not getting any notification and this way it is not aware of any changes. In the previous RIA release this worked fine I don't know why it does not now [:(].
    If someone has any workaround please let me know.

    Thank you.

  • Leonid Andruhin

    Leonid Andruhin

    Participant

    888 Points

    192 Posts

    Re: Re: Re: Associated data editing with DataForm

    Jul 21, 2009 05:43 AM | LINK

    I've got the same problem. Posted in "Report Silverlight Bug" - no answer still.

  • silver_surfing

    silver_surfing

    Member

    20 Points

    5 Posts

    Re: Re: Re: Associated data editing with DataForm

    Jul 28, 2009 01:29 AM | LINK

    I'm having the same issue.  This was definitely working before the release.  Very frustrating.

    Microsoft folks...any help?!?!

     

    Entity Framework Association INotifyPropertyChanged

  • Leonid Andruhin

    Leonid Andruhin

    Participant

    888 Points

    192 Posts

    Re: Re: Re: Re: Associated data editing with DataForm

    Jul 28, 2009 06:40 AM | LINK

    May be, you can find answer here?

    http://silverlight.net/forums/t/112449.aspx

  • lee_sl

    lee_sl

    Contributor

    4222 Points

    864 Posts

    Re: Re: Re: Re: Re: Associated data editing with DataForm

    Jul 28, 2009 08:32 AM | LINK

    I have sample at http://leeontech.wordpress.com/2009/07/27/working-with-dataform/. it doesnt use Edit features of the dataform, but has buttons in the template for edit and cancel.

     I just changed the CommandButtonsVisibility property to all and when I edit a reference property, the buttons seem to be enabled

    ----------------------------------------------
    Available for consulting in Dallas, TX
    http://leeontech.wordpress.com/
  • arsher

    arsher

    0 Points

    6 Posts

    Re: Re: Re: Re: Re: Associated data editing with DataForm

    Jul 28, 2009 01:59 PM | LINK

    Hiding the Save and Cancel command buttons and making your own was definately a great idea, it works fine [:)].

    Thank you very much!!