![]() ![]() In this example, the first TextBlock is rendered using the fast path, while the second is not. protected override void OnLaunched(LaunchActivatedEventArgs e) You typically set debug settings in the OnLaunched method override in the code-behind page for App.xaml, like this. Tip This feature is explained in depth in this session from Build 2015- XAML Performance: Techniques for Maximizing Universal Windows App Experiences Built with XAML. When this property is set to true, the text that is on the fast path displays in a bright green color. You can set the DebugSettings.IsTextPerformanceVisualizationEnabled property to true during debugging to determine whether text is using fast path rendering. Setting this property to true disables the fast path. IsTextSelectionEnabled: Only false is fast path.LineStackingStrategy: If LineHeight is not 0, the BaselineToBaseline and MaxHeight values disable the fast path.Typography: Only the default values for the various Typography properties are fast path.For more info about versions, see Version adaptive code. If your app is run on an earlier version of Windows, these conditions will also cause your text to render on the slow path. Note Prior to Windows 10, version 1607, additional properties also affect the fast path. TextTrimming: Only the None, CharacterEllipsis, and WordEllipsis values are fast path.CharacterSpacing: Only the default value of 0 is fast path.Setting the text via TextBlock's Inlines collection (such as Inline text) will disable the fast path, due to the potential complexity of multiple formats. Text: The most important condition is that the fast path is used only when you set text by explicitly setting the Text property, either in XAML or in code (as shown in the previous examples).To keep text rendering on the fast path, be sure to follow these guidelines when setting the properties listed here. This fast path applies only to TextBlock, so it should be preferred when possible over RichTextBlock.Ĭertain conditions require TextBlock to fall back to a more feature-rich and CPU intensive code path for text rendering. This fast path both decreases overall memory use and greatly reduces the CPU time to do text measuring and arranging. Whenever possible, XAML uses a more efficient code path to layout text. However, using Inlines also disables fast path text rendering, which is discussed in the next section. The inline Hyperlink element lets you add a hyperlink to your text. For more info, see the Formatting text section. ![]() Text can be bold, underlined,Įlements derived from the Inline class, such as Bold, Italic, Run, Span, and LineBreak, enable different formatting for different parts of the text. You can also add content by placing inline flow content elements in the TextBox.Inlines property, like this. The most common way to display text is to set the Text property to a string value, as shown in the previous example. There are two properties you can use to add content to a TextBlock: Text and Inlines. Here's how to define a simple TextBlock control and set its Text property to a string. Get the app from the Microsoft Store or get the source code on GitHub The WinUI 3 Gallery app includes interactive examples of most WinUI 3 controls, features, and functionality. Open the WinUI 3 Gallery app and see the TextBlock in action. Use a RichTextBlock when you need support for multiple paragraphs, multi-column text or other complex text layouts, or inline UI elements like images.įor more info about choosing the right text control, see the Text controls article. It also provides many of the same formatting options for customizing how your text is rendered.Īlthough you can put line breaks in the text, text block is designed to display a single paragraph and doesn't support text indentation. You can easily access and use text from a text block in your app by getting the value of the Text property. Is this the right control?Ī text block is typically easier to use and provides better text rendering performance than a rich text block, so it's preferred for most app UI text. You can use it to display single-line or multi-line text, inline hyperlinks, and text with formatting like bold, italic, or underlined. Text block is the primary control for displaying read-only text in apps. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |