"Essential WPF - Chapter 8 Styles" 阅读笔记

    技术2025-01-28  23

    Chapter 8 Styles

     

    8.3 Using Styles for Good, Not Evil

     

    8.3.1 Build Themes, Not Styles

     

    Consequently, generally the best practice is to think of a theme as a “thing” rather than just a collection of styles at the root window in the application.

     

    The first piece of concrete advice I would give is to move the definition of the theme into a separate file and use the merged-dictionaries feature to bind the theme into the application. Even better, move the theme definition to a separate assembly and use a cross-assembly reference to load the style (/<assemblyName>;component/<resourceName>):

     

    8.3.2 Consistency Is King

     

    When building a custom look and feel for an application, it is important to make it consistent across all the controls that will be used.

     

    One of the goals of WPF was to make every control customizable so that we wouldn’t get the “Frankenstein” applications often seen with older forms packages (appearing as if the UI had been stitched together using parts of other applications).

     

    8.3.3 Have a Point

     

    Custom themes allow us to differentiate one application from others. Creating a custom theme is potentially expensive, in terms of both design and implementation.

     

    The key thing is that a custom theme should convey something to the user.

    最新回复(0)