Presentation is loading. Please wait.

Presentation is loading. Please wait.

Adam Calderon – C# MVP Application Development Practice Lead Interknowlogy.

Similar presentations


Presentation on theme: "Adam Calderon – C# MVP Application Development Practice Lead Interknowlogy."— Presentation transcript:

1 Adam Calderon – C# MVP Application Development Practice Lead Interknowlogy

2  More info on InterKnowlogy: www.InterKnowlogy.com www.InterKnowlogy.com  Contact Information E-mail: adamc@InterKnowlogy.comadamc@InterKnowlogy.com Phone: 760-930-0075 x274 Blog: http://blogs.InterKnowlogy.com/AdamCalderonhttp://blogs.InterKnowlogy.com/AdamCalderon  About Adam Calderon  Microsoft MVP – C#  Microsoft UI Server Frameworks Advisory Council  Developer / Author / Speaker / Teacher

3  What Styles are and how to use them  How Triggers can be used to replace common UI behavior  How Templates can be used to enhance the look of a control

4  Styles  Triggers  Templates

5  What are styles?  Problems they address in WinForms 2.0  Styling controls one at a time  Unnecessary Custom Control Creation  Similarities to Cascading Style Sheets  Inline declaration  Page level declaration  Separate file declaration

6  Contained in System.Windows.Style  Main Properties  Key  TargetType  Setters ▪ Property – Can set element properties ▪ Event – Can set names to common event handlers

7 Some Text

8  Static Resources  Loaded when Window or Page Loads  Leads to slower page loading  Changes to underlining values are not propagated  Dynamic Resources  More overhead to allow for constant updates  Can only be used to set dependency properties  Can potentially improve Page and Window load time

9  Contains hash table of resources  Great way to organize resources  Resource.MergedDictionaries combines many different file based resources

10

11  Application Level  Application.Resources  Page/Window Level  Window.Resources  Page.Resources  Element Level  Grid.Resources

12  Order of Precedence  Application Level ▪ Page/Window Level (Overrides Application) ▪ Element Level (Final Override)  BasedOn Property  Style-based  Element-based

13  Organize styles into scope areas  Application  Page  Element  Use Resource Dictionaries  Use inheritance (BasedOn) in cases where you want to override a style for a particular application area  Try to limit element use of element based styles

14 Styles in Action

15  Styles  Triggers  Templates

16  Setters that are set based on one or more conditions  Three Types of Triggers  Property – Invoked when the value of a dependency property changes  Data – Invoked when the value of a plain.NET property changes  Event – Invoked when a routed event changes

17  Based on System.Windows.Trigger  Set when a specified property has a specified value  Reset when the property no longer has this value

18  Set when a specified property (.NET based or dependency) has a specified value  Reset when the property no longer has this value <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=Text}" Value="Color">

19  Triggers can be logically Or’d together to solve unique problems  If both conditions are true the last one wins Last one Wins when both are true

20  Triggers can be logically AND’d together to solve unique problems  Implemented using MultiTrigger

21 Triggers in Action

22  Styles  Triggers  Templates

23  Pick up where properties leave off  Provide ability to completely replace a controls visual tree  Not about replacing functionality  Reinforces separation of functionality and view  Out-of-box controls get their visual appearance from Templates  Brings together layout, styles and triggers

24  Three types of templates:  ControlTemplate  ItemsPanelTemplate  DataTemplate

25 <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> <Button Height="20" Width="40" Background=“Blue” Template="{StaticResource ButtonTemplate}">Ok

26  Based on System.Windows.Controls.ControlTemplate  Resources  TargetType  Trigggers  TemplateBinding links template and control properties  ContentPresenter can be used to display controls content

27  Markup extension similar to binding  More lightweight than binding and designed for templates  Data source is always the target control.........

28  Provides ability to show all types of content  Preferred way to provide ability for your template to show content  Remember that your are replacing the visual representation of a control and correctly showing contained content is important

29 Templates in Action

30  Styles are powerful and flexible  Triggers eliminate user interaction-based UI coding  Controls are more about behavior  Control Templates modify visual aspects of controls

31  MSDN ® Links Microsoft Windows ® Vista ™ development center: http://msdn2.microsoft.com/en- us/windowsvista/default.aspx http://msdn2.microsoft.com/en- us/windowsvista/default.aspx Microsoft.NET Framework 3.0 for developers: http://msdn.microsoft.com/winfx/ http://msdn.microsoft.com/winfx/  Other Links Microsoft.NET Framework: http://www.netfx3.com/http://www.netfx3.com/

32

33  More info on InterKnowlogy: www.InterKnowlogy.com www.InterKnowlogy.com  Contact Information E-mail: adamc@InterKnowlogy.comadamc@InterKnowlogy.com Phone: 760-930-0075 x274 Blog: http://blogs.InterKnowlogy.com/AdamCalderonhttp://blogs.InterKnowlogy.com/AdamCalderon  About Adam Calderon  Microsoft MVP – C#  Microsoft UI Server Frameworks Advisory Council  Developer / Author / Speaker / Teacher


Download ppt "Adam Calderon – C# MVP Application Development Practice Lead Interknowlogy."

Similar presentations


Ads by Google