R – SL3 Dataform Datafields in Border

silverlightsilverlight-3.0

Can you surround Datafields in a border? I have a large form that needs to be organized into sections, "Customer INformation" for instance.

Is there a way to surround these with a border?

Best Answer

I kinda get the feeling you are not specifying your own edit template for the control but a letting data form do it for you. I get this feeling because if you are already using an edit template you wouldn't be asking the question. Consider this:-

    <dataform:DataForm x:Name="dataForm">
        <dataform:DataForm.EditTemplate>
            <DataTemplate>
                <StackPanel>
                    <Border BorderBrush="Black" BorderThickness="2">
                        <StackPanel>
                            <dataform:DataField>
                                <TextBox Text="{Binding ID, Mode=TwoWay}" />
                            </dataform:DataField>
                            <dataform:DataField>
                                <TextBox Text="{Binding Name, Mode=TwoWay}" />
                            </dataform:DataField>
                        </StackPanel>
                    </Border>
                    <dataform:DataField>
                        <CheckBox IsChecked="{Binding Test, Mode=TwoWay}" />
                    </dataform:DataField>
                </StackPanel>
            </DataTemplate>
        </dataform:DataForm.EditTemplate>
    </dataform:DataForm>

Adding a border around the ID and Name fields is a simple case of placing them in their own StackPanel and putting that in a Border. Basically with a template you can do anything you want with the form appearance, in fact you don't even need the DataField if you feel you can do a better job with label placement etc in your own XAML.

Related Topic