mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-04 09:06:04 +02:00
@@ -15,7 +15,7 @@ ms.assetid: c19049bb-5ceb-492d-afd2-751dca0ed8e3
|
||||
# Control Styles and Templates
|
||||
Controls in Windows Presentation Foundation (WPF) have a <xref:System.Windows.Controls.ControlTemplate> that contains the visual tree of that control. You can change the structure and appearance of a control by modifying the <xref:System.Windows.Controls.ControlTemplate> of that control. There is no way to replace only part of the visual tree of a control; to change the visual tree of a control you must set the <xref:System.Windows.Controls.Control.Template%2A> property of the control to its new and complete <xref:System.Windows.Controls.ControlTemplate>.
|
||||
|
||||
The desktop themes determine which resource dictionary is used. To get the resource dictionaries for the desktop themes, see [Default WPF Themes](https://github.com/Microsoft/WPF-Samples/tree/master/Graphics/2DTransforms).
|
||||
The desktop themes determine which resource dictionary is used. The resource dictionaries for the desktop themes are included with your Visual Studio installation. The folder that contains the themes is generally located at _C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\\<visual studio edition>\\DesignTools\\SystemThemes\\wpf_, where _\<visual studio edition>_ represents the edition of Visual Studio.
|
||||
|
||||
The following table describes the resource dictionary file names and their corresponding desktop themes.
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ The <xref:System.Windows.Controls.RichTextBox> control enables you to display or
|
||||
|
||||
## TextBox or RichTextBox?
|
||||
|
||||
Both <xref:System.Windows.Controls.RichTextBox> and <xref:System.Windows.Controls.TextBox> allow users to edit text, however, the two controls are used in different scenarios. A <xref:System.Windows.Controls.RichTextBox> is a better choice when it is necessary for the user to edit formatted text, images, tables, or other rich content. For example, editing a document, article, or blog that requires formatting, images, etc is best accomplished using a <xref:System.Windows.Controls.RichTextBox>. A <xref:System.Windows.Controls.TextBox> requires less system resources then a <xref:System.Windows.Controls.RichTextBox> and it is ideal when only plain text needs to be edited (i.e. usage in forms). See [TextBox Overview](textbox-overview.md) for more information on <xref:System.Windows.Controls.TextBox>. The table below summarizes the main features of <xref:System.Windows.Controls.TextBox> and <xref:System.Windows.Controls.RichTextBox>.
|
||||
Both <xref:System.Windows.Controls.RichTextBox> and <xref:System.Windows.Controls.TextBox> allow users to edit text, however, the two controls are used in different scenarios. A <xref:System.Windows.Controls.RichTextBox> is a better choice when it is necessary for the user to edit formatted text, images, tables, or other rich content. For example, editing a document, article, or blog that requires formatting, images, etc is best accomplished using a <xref:System.Windows.Controls.RichTextBox>. A <xref:System.Windows.Controls.TextBox> requires less system resources than a <xref:System.Windows.Controls.RichTextBox> and it is ideal when only plain text needs to be edited (i.e. usage in forms). See [TextBox Overview](textbox-overview.md) for more information on <xref:System.Windows.Controls.TextBox>. The table below summarizes the main features of <xref:System.Windows.Controls.TextBox> and <xref:System.Windows.Controls.RichTextBox>.
|
||||
|
||||
|Control|Real-time Spellchecking|Context Menu|Formatting commands like <xref:System.Windows.Documents.EditingCommands.ToggleBold%2A> (Ctr+B)|<xref:System.Windows.Documents.FlowDocument> content like images, paragraphs, tables, etc.|
|
||||
|-------------|------------------------------|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
|
||||
@@ -9,6 +9,9 @@ ms.topic: how-to
|
||||
|
||||
This article describes how to migrate a Windows Forms desktop app from .NET Framework to .NET 5 or later. The .NET SDK includes support for Windows Forms applications. Windows Forms is still a Windows-only framework and only runs on Windows.
|
||||
|
||||
> [!TIP]
|
||||
> Try the [.NET Upgrade Assistant](/dotnet/core/porting/upgrade-assistant-winforms-framework) to help migrate your project.
|
||||
|
||||
Migrating your app from .NET Framework to .NET 5 generally requires a new project file. .NET 5 uses SDK-style project files while .NET Framework typically uses the older Visual Studio project file. If you've ever opened a Visual Studio project file in a text editor, you know how verbose it is. SDK-style projects are smaller and don't require as many entries as the older project file format does.
|
||||
|
||||
To learn more about .NET 5, see [Introduction to .NET](/dotnet/core/introduction).
|
||||
@@ -156,9 +159,15 @@ This XML gives you the basic structure of the project. However, it doesn't conta
|
||||
|
||||
One thing to note about the difference between .NET Framework projects and the SDK-style projects used by .NET 5 is that .NET Framework projects use an opt-in model for code files. Any code file you want to compile needs to be explicitly defined in your project file. SDK-style projects are reverse, they default to opt-out behavior: All code files starting from the project's directory and below are automatically included in your project. You don't need to migrate these entries if they are simple and without settings. This is the same for other common files such as _resx_.
|
||||
|
||||
Windows Forms projects also include Windows Form project specific files, such as _Properties/Settings.settings_ and _Properties/Resources.resx_. These files may need to be migrated they are declared in your original project.
|
||||
Windows Forms projects may also reference the following files:
|
||||
|
||||
Copy those entries from the old project file into an `<ItemGroup>` element in the new project. After you copy the entries, change all `<Compile Include="value">` elements to instead use the `Update` attribute instead of `Include`.
|
||||
- _Properties\\Settings.settings_
|
||||
- _Properties\\Resources.resx_
|
||||
- _Properties\\app.manifest_
|
||||
|
||||
The _app.manifest_ file is automatically referenced by your project and you don't need to do anything special to migrate it.
|
||||
|
||||
Any _*.resx_ and _*.settings_ files in the _Properties_ folder need to be migrated in the project. Copy those entries from the old project file into an `<ItemGroup>` element in the new project. After you copy the entries, change all `<Compile Include="value">` elements to instead use the `Update` attribute instead of `Include`.
|
||||
|
||||
- Import the configuration for the _Settings.settings_ file.
|
||||
|
||||
@@ -181,7 +190,7 @@ Copy those entries from the old project file into an `<ItemGroup>` element in th
|
||||
> [!IMPORTANT]
|
||||
> **Visual Basic** projects typically use the folder _My Project_ while C# projects typically use the folder _Properties_ for the default project settings file.
|
||||
|
||||
- Import the configuration for any _resx_ file, such as the _properties/Resources.resx_ file. Notice that the `Include` attribute was set to `Update` on the `<Compile>` and `<EmbeddedResource>` element, and `<SubType>` was removed from `<EmbeddedResource>`:
|
||||
- Import the configuration for any _resx_ file, such as the _properties\\Resources.resx_ file. Notice that the `Include` attribute was set to `Update` on the `<Compile>` and `<EmbeddedResource>` element, and `<SubType>` was removed from `<EmbeddedResource>`:
|
||||
|
||||
```xml
|
||||
<ItemGroup>
|
||||
@@ -204,7 +213,7 @@ Copy those entries from the old project file into an `<ItemGroup>` element in th
|
||||
|
||||
Visual Basic language projects require extra configuration.
|
||||
|
||||
01. Import the configuration file _My Project\Application.myapp_ setting. Notice that the `<Compile>` element uses the `Update` attribute instead of the `Include` attribute.
|
||||
01. Import the configuration file _My Project\\Application.myapp_ setting. Notice that the `<Compile>` element uses the `Update` attribute instead of the `Include` attribute.
|
||||
|
||||
```xml
|
||||
<ItemGroup>
|
||||
@@ -318,6 +327,7 @@ After you've finished migrating your app, test it!
|
||||
|
||||
## Next steps
|
||||
|
||||
- Try the [.NET Upgrade Assistant](/dotnet/core/porting/upgrade-assistant-winforms-framework) to migrate your app.
|
||||
- Learn about [breaking changes in Windows Forms](/dotnet/core/compatibility/winforms).
|
||||
- Read more about the [Windows Compatibility Pack][compat-pack].
|
||||
|
||||
|
||||
Reference in New Issue
Block a user