DataFrom works fine with AutoGenerateFields and no styles, but when I add a textbox style to the DataFormTextField's EditingElementStyle like this
Style x:Key="FieldTextBoxStyle" TargetType="TextBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<Grid x:Name="RootElement">
<Grid.Resources>
<Storyboard x:Key="Normal State"/>
<Storyboard x:Key="Focused State"/>
</Grid.Resources>
<ScrollViewer x:Name="ContentElement" Background="Transparent" Padding="{TemplateBinding Padding}" Margin="1,1,1,1">
</ScrollViewer>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
and this
DataForm dForm = new DataForm() { AutoGenerateFields = false, AutoEdit = true, AutoCommit = true, CommandButtonsVisibility = DataFormCommandButtonsVisibility.None, Foreground = new SolidColorBrush(Colors.Black), Header = "Basic Infomation" };
dForm.Fields.Add(new DataFormTextField() { FieldLabelContent = "Company Name", Binding = new Binding("Name"), EditingElementStyle = Resources["FieldTextBoxStyle"] as Style });
I want the form to start in Edit mode without having to click a button. But since Name is required
[Required]
public string Name;
The Binding triggers an error because Name is empty by default... Is my styling wrong?