How do I change the spacing between fields in a DataForm?
How do I change the spacing between fields in a DataForm in Silverlight?
I've tried editing the template but cannot find what I need.
I thought all I needed to do was change the MinHeight
and Margin
of the DataField
style, but that doesn't seem to do it.
<Style TargetTyp开发者_开发百科e="dataFormToolkit:DataField">
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Margin" Value="2"/>
<Setter Property="MinHeight" Value="5"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="dataFormToolkit:DataField">
<ContentControl x:Name="ContentControl" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="Stretch" IsTabStop="False" VerticalAlignment="Center"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I've found a number of articles about styling DataForm but many of them seem to be out of date. I don't see anything in the complete extracted template in Blend that corresponds to spacing.
Well changing the Margin on the style does change the spacing.
I'm gonna guess that you have the above style in a resource and are expecting it to apply implicitly to all DataField
instances. Silverlight 3 does not have support for implicit styles (the toolkit has some attached properties which can provide some semblence of implicit styles though).
You need to reference this style from the DataForm:-
<Grid.Resources>
<Style x:Key="DataFieldStyle" TargetType="dataFormToolkit:DataField">
<Setter Property="Margin" Value="2"/>
<Setter Property="MinHeight" Value="5"/>
</Style>
</Grid.Resources>
<DataForm DataFieldStyle="{StaticResource DataFieldStyle}" />
精彩评论