Skip to content

Instantly share code, notes, and snippets.

@sonnemaf
Last active April 5, 2018 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sonnemaf/392915fabfae8be149fc989cd2cdf11f to your computer and use it in GitHub Desktop.
Save sonnemaf/392915fabfae8be149fc989cd2cdf11f to your computer and use it in GitHub Desktop.
RequiredHeaderTemplate and BoldHeaderTemplate for XAML #UWP
<Page x:Class="App18.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App18"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<FontWeight x:Key="HeaderFontWeight">Medium</FontWeight>
<DataTemplate x:Key="RequiredHeaderTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding}"
FontWeight="{StaticResource HeaderFontWeight}" />
<TextBlock Text="(required)"
FontSize="12"
Margin="4,0,0,1"
VerticalAlignment="Bottom" />
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="BoldHeaderTemplate">
<TextBlock Text="{Binding}"
FontWeight="{StaticResource HeaderFontWeight}" />
</DataTemplate>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Orientation="Vertical"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="250">
<TextBox HeaderTemplate="{StaticResource RequiredHeaderTemplate}"
Header="Firstname"
Margin="0,0,0,8"
InputScope="PersonalFullName" />
<TextBox HeaderTemplate="{StaticResource RequiredHeaderTemplate}"
Header="Lastname"
Margin="0,0,0,8"
InputScope="PersonalFullName" />
<TextBox HeaderTemplate="{StaticResource BoldHeaderTemplate}"
Header="Email"
Margin="0,0,0,8"
InputScope="EmailNameOrAddress" />
<ComboBox HeaderTemplate="{StaticResource RequiredHeaderTemplate}"
Header="Department"
HorizontalAlignment="Stretch">
<ComboBoxItem Content="Sales" />
<ComboBoxItem Content="Production" />
<ComboBoxItem Content="Marketing" />
</ComboBox>
</StackPanel>
</Grid>
</Page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment