mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-09 23:43:28 +02:00
Restore WPF .NET Framework content from WPF .NET (#144)
* Copy .NET 5 WPF content back into .NET Framework * Add H1 heading difference for .NET * Fix validation errors
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Create a style for a control
|
||||
description: Learn how to create and reference a control style in Windows Presentation Foundation and .NET Core.
|
||||
description: Learn how to create and reference a control style in Windows Presentation Foundation and .NET.
|
||||
author: adegeo
|
||||
ms.author: adegeo
|
||||
ms.date: 09/12/2019
|
||||
@@ -11,7 +11,7 @@ dev_langs:
|
||||
#no-loc: [TextBlock, Setter]
|
||||
---
|
||||
|
||||
# Create a style for a control in WPF
|
||||
# Create a style for a control (WPF .NET)
|
||||
|
||||
With Windows Presentation Foundation (WPF), you can customize an existing control's appearance with your own reusable style. Styles can be applied globally to your app, windows and pages, or directly to controls.
|
||||
|
||||
@@ -37,7 +37,7 @@ A <xref:System.Windows.Style> is a convenient way to apply a set of property val
|
||||
|
||||
[!code-xaml[TextBlocks](./snippets/styles-templates-create-apply-style/csharp/Window1.xaml#SnippetTextBlocks)]
|
||||
|
||||

|
||||

|
||||
|
||||
You can change the default appearance by setting properties, such as <xref:System.Windows.Controls.Control.FontSize%2A> and <xref:System.Windows.Controls.Control.FontFamily%2A>, on each <xref:System.Windows.Controls.TextBlock> element directly. However, if you want your <xref:System.Windows.Controls.TextBlock> elements to share some properties, you can create a <xref:System.Windows.Style> in the `Resources` section of your XAML file, as shown here.
|
||||
|
||||
@@ -47,7 +47,7 @@ When you set the <xref:System.Windows.Style.TargetType%2A> of your style to the
|
||||
|
||||
Now the <xref:System.Windows.Controls.TextBlock> elements appear as follows.
|
||||
|
||||

|
||||

|
||||
|
||||
## Apply a style explicitly
|
||||
|
||||
@@ -63,7 +63,7 @@ To apply the style, set the <xref:System.Windows.FrameworkElement.Style%2A> prop
|
||||
|
||||
Notice that the first <xref:System.Windows.Controls.TextBlock> element has the style applied to it while the second TextBlock element remains unchanged. The implicit style from the previous section was changed to a style that declared the `x:Key` attribute, meaning, the only element affected by the style is the one that referenced the style directly.
|
||||
|
||||

|
||||

|
||||
|
||||
Once a style is applied, explicitly or implicitly, it becomes sealed and can't be changed. If you want to change a style that has been applied, create a new style to replace the existing one. For more information, see the <xref:System.Windows.Style.IsSealed%2A> property.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user