Monday, September 7, 2015

Apply Inner and Global Style's To Windows Phone Controls

Open Visual Studio 
File --> Project --> New Project
Select Windows Phone Apps



After Create Project, Open the Main.xaml
Create TextBlock Control


Write Inner Style in Page

 <Page.Resources>
        <Style x:Key="tbInnerStyle" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="Sege UI"></Setter>
            <Setter Property="FontSize" Value="28"></Setter>
        </Style>
    </Page.Resources>

We can apply Inner Style to TextBlock control
  <TextBlock Text="Hello Windows Phone" Style="{StaticResource tbInnerStyle}" >
            </TextBlock>



Press F5 and See Inner Style Output here.



Now we are going apply Global Style to Button Control
Open the App.xaml file and write global style

 <Application.Resources>
        <Style x:Key="tbGlobalStyle" TargetType="Button">
            <Setter Property="FontFamily" Value="Sege UI"></Setter>
            <Setter Property="Width" Value="250"></Setter>
            <Setter Property="Foreground" Value="Green"></Setter>
        </Style>
    </Application.Resources>


After that style key name: tbGlobalStyle apply to button 
 <Button Style="{StaticResource tbGlobalStyle}" Content="Global Style Button" >
 </Button>



Press F5 See Global Style Button Output.



No comments:

Post a Comment