--- title: "Optimizing Performance: Other Recommendations" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "Terminal Services rendering [WPF]" - "opacity [WPF]" - "hit-test objects [WPF]" - "ScrollBarVisibility enumeration [WPF]" - "brushes [WPF], performance" ms.assetid: d028cc65-7e97-4a4f-9859-929734eaf40d --- # Optimizing Performance: Other Recommendations This topic provides performance recommendations in addition to the ones covered by the topics in the [Optimizing WPF Application Performance](optimizing-wpf-application-performance.md) section. This topic contains the following sections: - [Opacity on Brushes Versus Opacity on Elements](#Opacity) - [Navigation to Object](#Navigation_Objects) - [Hit Testing on Large 3D Surfaces](#Hit_Testing) - [CompositionTarget.Rendering Event](#CompositionTarget_Rendering_Event) - [Avoid Using ScrollBarVisibility=Auto](#Avoid_Using_ScrollBarVisibility) - [Configure Font Cache Service to Reduce Start-up Time](#FontCache) ## Opacity on Brushes Versus Opacity on Elements When you use a to set the or of an element, it is better to set the value rather than the setting the element's property. Modifying an element's property can cause [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] to create a temporary surface. ## Navigation to Object The object derives from and extends it with content navigation support, primarily by aggregating and the journal. You can update the client area of by specifying either a uniform resource identifier (URI) or an object. The following sample shows both methods: [!code-csharp[Performance#PerformanceSnippet14](~/samples/snippets/csharp/VS_Snippets_Wpf/Performance/CSharp/TestNavigation.xaml.cs#performancesnippet14)] [!code-vb[Performance#PerformanceSnippet14](~/samples/snippets/visualbasic/VS_Snippets_Wpf/Performance/visualbasic/testnavigation.xaml.vb#performancesnippet14)] Each object has a journal that records the user's navigation history in that window. One of the purposes of the journal is to allow users to retrace their steps. When you navigate using a uniform resource identifier (URI), the journal stores only the uniform resource identifier (URI) reference. This means that each time you revisit the page, it is dynamically reconstructed, which may be time consuming depending on the complexity of the page. In this case, the journal storage cost is low, but the time to reconstitute the page is potentially high. When you navigate using an object, the journal stores the entire visual tree of the object. This means that each time you revisit the page, it renders immediately without having to be reconstructed. In this case, the journal storage cost is high, but the time to reconstitute the page is low. When you use the object, you will need to keep in mind how the journaling support impacts your application's performance. For more information, see [Navigation Overview](../app-development/navigation-overview.md). ## Hit Testing on Large 3D Surfaces Hit testing on large 3D surfaces is a very performance intensive operation in terms of CPU consumption. This is especially true when the 3D surface is animating. If you do not require hit testing on these surfaces, then disable hit testing. Objects that are derived from can disable hit testing by setting the property to `false`. ## CompositionTarget.Rendering Event The event causes [!INCLUDE[TLA2#tla_winclient](../../../includes/tla2sharptla-winclient-md.md)] to continuously animate. If you use this event, detach it at every opportunity. ## Avoid Using ScrollBarVisibility=Auto Whenever possible, avoid using the value for the `HorizontalScrollBarVisibility` and `VerticalScrollBarVisibility` properties. These properties are defined for , , and objects, and as an attached property for the object. Instead, set to , , or . The value is intended for cases when space is limited and scrollbars should only be displayed when necessary. For example, it may be useful to use this value with a of 30 items as opposed to a with hundreds of lines of text. ## Configure Font Cache Service to Reduce Start-up Time The WPF Font Cache service shares font data between WPF applications. The first WPF application you run starts this service if the service is not already running. If you are using Windows Vista, you can set the "Windows Presentation Foundation (WPF) Font Cache 3.0.0.0" service from "Manual" (the default) to "Automatic (Delayed Start)" to reduce the initial start-up time of WPF applications. ## See also - [Planning for Application Performance](planning-for-application-performance.md) - [Taking Advantage of Hardware](optimizing-performance-taking-advantage-of-hardware.md) - [Layout and Design](optimizing-performance-layout-and-design.md) - [2D Graphics and Imaging](optimizing-performance-2d-graphics-and-imaging.md) - [Object Behavior](optimizing-performance-object-behavior.md) - [Application Resources](optimizing-performance-application-resources.md) - [Text](optimizing-performance-text.md) - [Data Binding](optimizing-performance-data-binding.md) - [Animation Tips and Tricks](../graphics-multimedia/animation-tips-and-tricks.md)