views:

45

answers:

2

I'm trying to make a data form in Silverlight 4. Perhaps I'm doing something wrong.

The class:

public class ExpenseInfoTest
{
    public int MyProperty { get; set; }
    public int Foo { get; set; }
    public int Bar { get; set; }
}

XAML:

    <local:ExpenseInfoTest x:Key="newExpense"/>

    <df:DataForm Height="218" 
                 HorizontalAlignment="Left" 
                 Margin="13,368,0,0" 
                 Name="expenseDataForm" 
                 VerticalAlignment="Top" 
                 Width="590" 
                 CurrentItem="{StaticResource newExpense}" />

What is displayed: Just the fields without the save and edit buttons

I'd like the "Save" button. How can I get it to appear? Is something wrong in my XAML or data class?

+1  A: 

This line of code is helpful:

expenseDataForm.CommandButtonsVisibility = DataFormCommandButtonsVisibility.All;
Rosarch
+2  A: 

In your xaml, add

CommandButtonsVisibility="All" 

in your DataForm declaration.

If you wanted to, you could bind the CommandButtonsVisibility to lets say a combo box

<ComboBox SelectedItem="{Binding CommandButtonsVisibility, ElementName=expenseDataForm, Mode=TwoWay}" SelectedIndex="0" >

and be able to control which command buttons are available based on the CB selection.

VoodooChild