Presentation is loading. Please wait.

Presentation is loading. Please wait.

Rujchai Ung-arunyawee Department of Computer Engineering Khon Kaen University.

Similar presentations


Presentation on theme: "Rujchai Ung-arunyawee Department of Computer Engineering Khon Kaen University."— Presentation transcript:

1 Rujchai Ung-arunyawee Department of Computer Engineering Khon Kaen University

2 WPF Resources Assembly resources Object resources. (aka. Logical or Declarative resources)

3 Object Resources Efficiency. Resources let you define an object once and use it in several places in your markup. This streamlines your code and makes it marginally more efficient. Maintainability. Resources let you take low-level formatting details (such as font sizes) and move them to a central place where they’re easy to change. It’s the XAML equivalent of creating constants in your code. Adaptability. Once certain information is separated from the rest of your application and placed in a resource section, it becomes possible to modify it dynamically. For example, you may want to change resource details based on user preferences or the current language.

4 The Resources Collection Every element includes a Resources property, which stores a dictionary collection of resources. The most common way to define resources is at the window-level

5 Use a resource in your XAML By a markup extension StaticResource: set once, when the window is first created. DynamicResource: reapplied if the resource is changed

6

7 Accessing Resources in Code

8 Application Resources WPF continues to check the set of resources you’ve defined for your application the App.xaml file

9 System Resources SystemColors, SystemFonts, and SystemParameters

10 Styles A style is a collection of property values that can be applied to an element. Similar to the cascading style sheet (CSS) standard in HTML The Style class is used to create styles.

11 Properties of The Style Class

12

13 Create a Style at object level

14 Setting Complex Properties

15 Creating a button-only style

16 Attaching Event Handlers

17 Many Layers of Styles

18 Automatically Applying Styles Simply need to set the TargetType property to indicate the appropriate type and leave out the key name altogether.

19 Sets the Style property to a null value is to remove the style.

20 The Style.Triggers: Trigger Using triggers, you can automate simple style changes without resorting to code

21 Multiple Triggers

22 The Style.Triggers: EventTrigger Simple Trigger waits for a property change to occur Event Trigger waits for a specific event to be fired Event trigger requires that you supply a series of actions that modify the control These actions are used to apply an animation.

23

24


Download ppt "Rujchai Ung-arunyawee Department of Computer Engineering Khon Kaen University."

Similar presentations


Ads by Google