socal code camp_usc

16

Upload: nabeel-khan

Post on 30-Jun-2015

998 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Socal code camp_usc
Page 2: Socal code camp_usc

WPF Styling Architecture

Page 3: Socal code camp_usc

About me

• Sr. Consultant at Neudesic• 12 years experience of Microsoft

technologies• Currently working on WPF and WCF• Blog posts on mnabeelkhan.blogspot.com

Page 4: Socal code camp_usc

Agenda

• What is meant by styles• Why we need styles• Key Concepts• Steps in generating a style • Demo• Questions

Page 5: Socal code camp_usc

What is meant by Style

• Features that allow developers and designers to create visually compelling effects and to create a consistent appearance for the product (MSDN).

• A convenient way to apply a set of property values to more than one element (MSDN).

Page 6: Socal code camp_usc

Why we need styles

• Flexibility• Reduce the amount of core code• Accessibility• Separation of Layout from Content.

Page 7: Socal code camp_usc

Different Type of Styles

• Inline styles.• CSS• WPF Styles Architecture.

Page 8: Socal code camp_usc

Inline StylesExample

<ListBox ItemsSource="{Binding Source={StaticResource MyPhotos}}" Background="Silver" Width="600" Margin="10" SelectedIndex="0"/>

Page 9: Socal code camp_usc

Inline StylesDisadvantages

• Style information is provided for each control.• Lacking flexibility. • Cannot use as library between different

projects.• Maintainability – Very difficult to maintain as

changes had to be broad.• No separation between layout and Content.

Page 10: Socal code camp_usc

WPF Styling Architecture

Page 11: Socal code camp_usc

Style Flow

Page 12: Socal code camp_usc

Styles ArchitectureKey points

• Theme is at the top level.• Theme consists of different Control Styles

that are building block for a theme.• Each Control Style consists of General

style, Layout style and fonts.• General Style consists of brushes.• Brushes consists of primitive colors.

Page 13: Socal code camp_usc

Styles ArchitectureAdvantages

• Layout and content style is separated.• Several themes can be developed that have

similar structure.• Themes can be used cross applications as

Style libraries.• Flexibility• Easily maintainable.• Easy to make simple changes.

Page 14: Socal code camp_usc

WPF Styles Architecture

• Demo

Page 15: Socal code camp_usc

WPF Styles Architecture

• Questions