- XAML Tutorial
- XAML - Home
- XAML - Overview
- XAML - Environment Setup
- Writing XAML Aplication On MAC OS
- XAML Vs C# Code
- XAML Vs.VB.NET
- XAML - Building Blocks
- XAML - Controls
- XAML - Layouts
- XAML - Event Handling
- XAML - Data Binding
- XAML - Markup Extensions
- XAML - Dependency Properties
- XAML - Resources
- XAML - Templates
- XAML - Styles
- XAML - Triggers
- XAML - Debugging
- XAML - Custom Controls
- XAML Useful Resources
- XAML - Quick Guide
- XAML - Useful Resources
- XAML - Discussion
XAML - Layout Level
Defining a style on any layout level can only be accessible by that layout and by its child elements only. Given below is the example of a layout level where all the three buttons have a common style.
<Window x:Class = "XAMLLayoutLevelStyle.MainWindow" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x = "http://schemas.microsoft.com/winfx/2006/xaml" Title = "MainWindow" Height = "350" Width = "604"> <StackPanel Margin = "10"> <StackPanel.Resources> <Style TargetType = "Button"> <Setter Property = "Foreground" Value = "Blue" /> <Setter Property = "FontStyle" Value = "Italic" /> <Setter Property = "Width" Value = "100" /> <Setter Property = "Height" Value = "40" /> <Setter Property = "Margin" Value = "10" /> </Style> </StackPanel.Resources> <Button>Button 1</Button> <Button>Button 2</Button> <Button Foreground = "Blue">Button 3</Button> </StackPanel> </Window>
When the above code is compiled and executed, it will produce the following output −
xaml_styles.htm
Advertisements