/
Resources and Styles Resources and Styles

Resources and Styles - PowerPoint Presentation

phoebe-click
phoebe-click . @phoebe-click
Follow
343 views
Uploaded On 2019-11-20

Resources and Styles - PPT Presentation

Resources and Styles Rujchai Ungarunyawee Department of Computer Engineering Khon Kaen University WPF Resources Assembly resources Object resources aka Logical or Declarative resources Object Resources ID: 765742

style resources styles property resources style property styles triggers trigger object code resource application event xaml change collection set

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Resources and Styles" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Resources and Styles Rujchai Ung-arunyawee Department of Computer Engineering Khon Kaen University

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

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.

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

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

Accessing Resources in Code

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

System Resources SystemColors , SystemFonts , and SystemParameters

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.

Properties of The Style Class

Create a Style at object level

Setting Complex Properties

Creating a button-only style

Attaching Event Handlers

Many Layers of Styles

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

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

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

Multiple Triggers

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