Sunday, December 18, 2016

Style Examples - First

Case 1 : Consider a case where we have a Button in user control and we want following things

Backgrond  : Green
FontStyle  : Italic
Margin : 5
    <UserControl.Resources>
        <Style TargetType="Button">
            <Setter Property="Background" Value="Green"></Setter>
            <Setter Property="FontStyle" Value="Italic"></Setter>
            <Setter Property="Margin" Value="5"></Setter>           
        </Style>

    </UserControl.Resources>

        <StackPanel Orientation="Horizontal">
            <Button Content="It" Width="100" Height="30"></Button>
            <Button Content="is" Width="100" Height="30"></Button>
            <Button Content="my style" Width="100" Height="30"></Button>
        </StackPanel>

No comments:

Post a Comment