I am using SL4 Business application with WCF RIA service. In my app, there is a loginForm. in the designer of loginform I can found username textbox and password textbox.But in .Xaml page its like the code given below.
<local:BusyIndicator x:Name="busyIndicator" BusyContent="{Binding Path=Strings.BusyIndicatorLoggingIn, Source={StaticResource ApplicationResources}}"
IsBusy="{Binding IsLoggingIn}">
<StackPanel Orientation="Vertical">
<toolkit:DataForm x:Name="loginForm"
Padding="10,0,10,0"
CurrentItem="{Binding}"
IsEnabled="{Binding IsLoggingIn, Converter={StaticResource NotOperatorValueConverter}}"
AutoEdit="True" CommandButtonsVisibility="None" HeaderVisibility="Collapsed"
AutoGeneratingField="LoginForm_AutoGeneratingField"
Style="{StaticResource LoginDataFormStyle}" />
</StackPanel>
</local:BusyIndicator>
My question is I need to style the username textbox as well as password textbox in the dataform. How can I do this? From where can i access these controls?
Those controls are generated by the DataForm control. You basically need to put a default style for TextBox and PasswordBox under the root Grid's Resources. I gave them a massive font size of 50. You just need to replace them with your own styles.
<!-- LoginDataForm Style -->
<Style x:Key="LoginDataFormStyle" TargetType="dataControls:DataForm">
<Setter Property="Width" Value="370"/>
<Setter Property="AutoCommit" Value="True"/>
<Setter Property="AutoGenerateFields" Value="True"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="DescriptionViewerPosition" Value="Auto"/>
<Setter Property="LabelPosition" Value="Auto"/>
<Setter Property="HeaderVisibility" Value="Collapsed"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="0,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="dataControls:DataForm">
<Grid dataControls:DataField.IsFieldGroup="True">
<Grid.Resources>
<Style TargetType="TextBox">
<Setter Property="FontSize" Value="50"/>
</Style>
<Style TargetType="PasswordBox">
<Setter Property="FontSize" Value="50"/>
</Style>
<Style x:Key="ButtonGeneric" TargetType="Button">
Hope this helps. :)