views:

373

answers:

2

I am using Dataform to show a object in my Silverlight application. It is a simple Input page which where you can input value and the SAVE button at the bottom submits the information to the database.

My object contains 7 data fields, out of which I need to show only 5 of them. The other two data fields are added in the database directly.

My silverlight application communicates to the database via WCF services.

So, the question is can I filter data fields on the dataform?

+2  A: 

If you are Auto-generating the DataForm, you can use

[Display(AutoGenerateField=false)]
public string SomeProperty {get;set;}

This attribute was previously called Bindable in the SL3 beta, and has since changed in the RTM release. More info here

Neil
Neil,Do you mean I add the above attribute to the object in the reference.cs? As, I told you that I am adding my WCF service as a service reference in my Silverlight project.I was a bit hestitant to modify the reference.cs file which is automatically generated when I add a service reference. Is this the only way out ?
SVI
no no, okay im assuming ure following the MVVM architecture, maybe using prism, therefore in your viewmodel add these as attributes above your property, if ure not following the MVVM pattern, then do u bind ur dataform directly to the WCF service (aka the reference.cs)
Neil
i think you should take a look at this link http://www.silverlightshow.net/items/Creating-Rich-Data-Forms-in-Silverlight-3-Customization.aspx
Neil
A: 

Following is the snippet from xaml file

dataFormToolkit:DataForm x:Name="dataForm" CommitButtonContent="Save" CancelButtonContent="Cancel" AutoEdit="True" AutoGenerateFields="False"

Following is the snippet from xaml.cs file

    public CreateProduct()
    {
        InitializeComponent();
        this.Loaded += new RoutedEventHandler(CreateProduct_Loaded);


    }

    private void CreateProduct_Loaded(object sender, RoutedEventArgs e)
    {

        ServiceReference.Product model = new ServiceReference.Product();
        dataForm.CurrentItem = model;
    }
SVI
if autogenerate is false then where is the DisplayTemplate?
Neil