-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add control library templates #1005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a1708f8
adding custom control
jmarolf e581943
Add user control library
jmarolf 2287cd3
align names
jmarolf f7cadb4
open both code and xaml files
jmarolf f9dbbc7
rename folder from WpfControlLibrary-* to WpfUserControlLibrary-*
jmarolf 7672247
fix typo in template
jmarolf c23292e
remove extra line
jmarolf 92e10f3
remove namespace
jmarolf 444300b
use wpfusercontrollib as the short name
jmarolf 483ae98
adding code files
jmarolf 92e113f
adding default namespaces
jmarolf 82679d0
remove unnecessary namespaces
jmarolf f0d84fd
remove un-needed InitializeComponent
jmarolf 05112d2
rename files to include xaml
jmarolf 8239fe3
add InitializeComponent
jmarolf 0a5d445
delete duplicate file
jmarolf a64a546
prefix class with namespace
jmarolf 7c55031
do not fully qualify VB xaml class name
jmarolf 432f4ac
correctly name vb file
jmarolf bb1850e
do not condition use of root namespace
jmarolf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...jectTemplates/content/WpfCustomControlLibrary-CSharp/.template.config/dotnetcli.host.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/dotnetcli.host", | ||
"symbolInfo": { | ||
"TargetFrameworkOverride": { | ||
"isHidden": "true", | ||
"longName": "target-framework-override", | ||
"shortName": "" | ||
}, | ||
"Framework": { | ||
"longName": "framework" | ||
}, | ||
"skipRestore": { | ||
"longName": "no-restore", | ||
"shortName": "" | ||
}, | ||
"langVersion": { | ||
"longName": "langVersion", | ||
"shortName": "" | ||
} | ||
}, | ||
"usageExamples": [ | ||
"" | ||
] | ||
} |
86 changes: 86 additions & 0 deletions
86
...pf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/.template.config/template.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/template", | ||
"author": "Microsoft", | ||
"classifications": ["Common", "WPF"], | ||
"name": "WPF Custom Control Library", | ||
"generatorVersions": "[1.0.0.0-*)", | ||
"description": "A project for creating a custom control library for .NET Core WPF Applications", | ||
"groupIdentity": "Microsoft.Common.WPF.CustomControl", | ||
"precedence": "3000", | ||
"identity": "Microsoft.Common.WPF.CustomControl.CSharp.3.0", | ||
"shortName": "wpfcustomcontrollib", | ||
"tags": { | ||
"language": "C#", | ||
"type": "project" | ||
}, | ||
"sourceName": "Company.WpfCustomControlLibrary", | ||
"preferNameDirectory": true, | ||
"symbols": { | ||
"TargetFrameworkOverride": { | ||
"type": "parameter", | ||
"description": "Overrides the target framework", | ||
"replaces": "TargetFrameworkOverride", | ||
"datatype": "string", | ||
"defaultValue": "" | ||
}, | ||
"Framework": { | ||
"type": "parameter", | ||
"description": "The target framework for the project.", | ||
"datatype": "choice", | ||
"choices": [ | ||
{ | ||
"choice": "netcoreapp3.0", | ||
"description": "Target netcoreapp3.0" | ||
} | ||
], | ||
"replaces": "netcoreapp3.0", | ||
"defaultValue": "netcoreapp3.0" | ||
}, | ||
"langVersion": { | ||
"type": "parameter", | ||
"datatype": "text", | ||
"description": "Sets langVersion in the created project file", | ||
"defaultValue": "", | ||
"replaces": "$(ProjectLanguageVersion)" | ||
}, | ||
"HostIdentifier": { | ||
"type": "bind", | ||
"binding": "HostIdentifier" | ||
}, | ||
"skipRestore": { | ||
"type": "parameter", | ||
"datatype": "bool", | ||
"description": "If specified, skips the automatic restore of the project on create.", | ||
"defaultValue": "false" | ||
} | ||
}, | ||
"primaryOutputs": [ | ||
{ "path": "Company.WpfCustomControlLibrary.csproj" }, | ||
{ | ||
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", | ||
"path": "CustomControl1.cs" | ||
} | ||
], | ||
"defaultName": "WpfCustomControlLibrary1", | ||
"postActions": [ | ||
{ | ||
"condition": "(!skipRestore)", | ||
"description": "Restore NuGet packages required by this project.", | ||
"manualInstructions": [ | ||
{ "text": "Run 'dotnet restore'" } | ||
], | ||
"actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025", | ||
"continueOnError": true | ||
}, | ||
{ | ||
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", | ||
"description": "Opens CustomControl1.cs in the editor", | ||
"manualInstructions": [ ], | ||
"actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6", | ||
"args": { | ||
"files": "1" | ||
}, | ||
"continueOnError": true | ||
} | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
...rosoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/AssemblyInfo.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Windows; | ||
|
||
[assembly:ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] |
11 changes: 11 additions & 0 deletions
11
...ctTemplates/content/WpfCustomControlLibrary-CSharp/Company.WpfCustomControlLibrary.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework Condition="'$(TargetFrameworkOverride)' == ''">netcoreapp3.0</TargetFramework> | ||
<TargetFramework Condition="'$(TargetFrameworkOverride)' != ''">TargetFrameworkOverride</TargetFramework> | ||
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WpfCustomControlLibrary</RootNamespace> | ||
<LangVersion Condition="'$(langVersion)' != ''">$(ProjectLanguageVersion)</LangVersion> | ||
<UseWPF>true</UseWPF> | ||
</PropertyGroup> | ||
|
||
</Project> |
54 changes: 54 additions & 0 deletions
54
...soft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/CustomControl1.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
|
||
namespace Company.WpfCustomControlLibrary | ||
{ | ||
/// <summary> | ||
/// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file. | ||
/// | ||
/// Step 1a) Using this custom control in a XAML file that exists in the current project. | ||
/// Add this XmlNamespace attribute to the root element of the markup file where it is | ||
/// to be used: | ||
/// | ||
/// xmlns:MyNamespace="clr-namespace:Company.WpfCustomControlLibrary" | ||
/// | ||
/// | ||
/// Step 1b) Using this custom control in a XAML file that exists in a different project. | ||
/// Add this XmlNamespace attribute to the root element of the markup file where it is | ||
/// to be used: | ||
/// | ||
/// xmlns:MyNamespace="clr-namespace:Company.WpfCustomControlLibrary;assembly=Company.WpfCustomControlLibrary" | ||
/// | ||
/// You will also need to add a project reference from the project where the XAML file lives | ||
/// to this project and Rebuild to avoid compilation errors: | ||
/// | ||
/// Right click on the target project in the Solution Explorer and | ||
/// "Add Reference"->"Projects"->[Select this project] | ||
/// | ||
/// | ||
/// Step 2) | ||
/// Go ahead and use your control in the XAML file. | ||
/// | ||
/// <MyNamespace:CustomControl1/> | ||
/// | ||
/// </summary> | ||
public class CustomControl1 : Control | ||
{ | ||
static CustomControl1() | ||
{ | ||
DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl1), new FrameworkPropertyMetadata(typeof(CustomControl1))); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...ft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/Themes/Generic.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<ResourceDictionary | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:Company.WpfCustomControlLibrary"> | ||
<Style TargetType="{x:Type local:CustomControl1}"> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type local:CustomControl1}"> | ||
<Border Background="{TemplateBinding Background}" | ||
BorderBrush="{TemplateBinding BorderBrush}" | ||
BorderThickness="{TemplateBinding BorderThickness}"> | ||
</Border> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
</ResourceDictionary> |
24 changes: 24 additions & 0 deletions
24
...emplates/content/WpfCustomControlLibrary-VisualBasic/.template.config/dotnetcli.host.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/dotnetcli.host", | ||
"symbolInfo": { | ||
"TargetFrameworkOverride": { | ||
"isHidden": "true", | ||
"longName": "target-framework-override", | ||
"shortName": "" | ||
}, | ||
"Framework": { | ||
"longName": "framework" | ||
}, | ||
"skipRestore": { | ||
"longName": "no-restore", | ||
"shortName": "" | ||
}, | ||
"langVersion": { | ||
"longName": "langVersion", | ||
"shortName": "" | ||
} | ||
}, | ||
"usageExamples": [ | ||
"" | ||
] | ||
} |
86 changes: 86 additions & 0 deletions
86
...ojectTemplates/content/WpfCustomControlLibrary-VisualBasic/.template.config/template.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/template", | ||
"author": "Microsoft", | ||
"classifications": ["Common", "WPF"], | ||
"name": "WPF Custom Control Library", | ||
"generatorVersions": "[1.0.0.0-*)", | ||
"description": "A project for creating a custom control library for .NET Core WPF Applications", | ||
"groupIdentity": "Microsoft.Common.WPF.CustomControl", | ||
"precedence": "3000", | ||
"identity": "Microsoft.Common.WPF.CustomControl.VisualBasic.3.0", | ||
"shortName": "wpfcustomcontrollib", | ||
"tags": { | ||
"language": "VB", | ||
"type": "project" | ||
}, | ||
"sourceName": "Company.WpfCustomControlLibrary", | ||
"preferNameDirectory": true, | ||
"symbols": { | ||
"TargetFrameworkOverride": { | ||
"type": "parameter", | ||
"description": "Overrides the target framework", | ||
"replaces": "TargetFrameworkOverride", | ||
"datatype": "string", | ||
"defaultValue": "" | ||
}, | ||
"Framework": { | ||
"type": "parameter", | ||
"description": "The target framework for the project.", | ||
"datatype": "choice", | ||
"choices": [ | ||
{ | ||
"choice": "netcoreapp3.0", | ||
"description": "Target netcoreapp3.0" | ||
} | ||
], | ||
"replaces": "netcoreapp3.0", | ||
"defaultValue": "netcoreapp3.0" | ||
}, | ||
"langVersion": { | ||
"type": "parameter", | ||
"datatype": "text", | ||
"description": "Sets langVersion in the created project file", | ||
"defaultValue": "", | ||
"replaces": "$(ProjectLanguageVersion)" | ||
}, | ||
"HostIdentifier": { | ||
"type": "bind", | ||
"binding": "HostIdentifier" | ||
}, | ||
"skipRestore": { | ||
"type": "parameter", | ||
"datatype": "bool", | ||
"description": "If specified, skips the automatic restore of the project on create.", | ||
"defaultValue": "false" | ||
} | ||
}, | ||
"primaryOutputs": [ | ||
{ "path": "Company.WpfCustomControlLibrary.vbproj" }, | ||
{ | ||
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", | ||
"path": "CustomControl1.vb" | ||
} | ||
], | ||
"defaultName": "WpfCustomControlLibrary1", | ||
"postActions": [ | ||
{ | ||
"condition": "(!skipRestore)", | ||
"description": "Restore NuGet packages required by this project.", | ||
"manualInstructions": [ | ||
{ "text": "Run 'dotnet restore'" } | ||
], | ||
"actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025", | ||
"continueOnError": true | ||
}, | ||
{ | ||
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", | ||
"description": "Opens CustomControl1.vb in the editor", | ||
"manualInstructions": [ ], | ||
"actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6", | ||
"args": { | ||
"files": "1" | ||
}, | ||
"continueOnError": true | ||
} | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
...t.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-VisualBasic/AssemblyInfo.vb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Imports System.Windows | ||
|
||
'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found. | ||
'1st parameter: where theme specific resource dictionaries are located | ||
'(used if a resource is not found in the page, | ||
' or application resource dictionaries) | ||
|
||
'2nd parameter: where the generic resource dictionary is located | ||
'(used if a resource is not found in the page, | ||
'app, and any theme specific resource dictionaries) | ||
<Assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)> |
23 changes: 23 additions & 0 deletions
23
...plates/content/WpfCustomControlLibrary-VisualBasic/Company.WpfCustomControlLibrary.vbproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework Condition="'$(TargetFrameworkOverride)' == ''">netcoreapp3.0</TargetFramework> | ||
<TargetFramework Condition="'$(TargetFrameworkOverride)' != ''">TargetFrameworkOverride</TargetFramework> | ||
<RootNamespace>Company.WpfCustomControlLibrary</RootNamespace> | ||
<LangVersion Condition="'$(langVersion)' != ''">$(ProjectLanguageVersion)</LangVersion> | ||
<UseWPF>true</UseWPF> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Import Include="System.Windows" /> | ||
<Import Include="System.Windows.Controls" /> | ||
<Import Include="System.Windows.Data" /> | ||
<Import Include="System.Windows.Documents" /> | ||
<Import Include="System.Windows.Input" /> | ||
<Import Include="System.Windows.Media" /> | ||
<Import Include="System.Windows.Media.Imaging" /> | ||
<Import Include="System.Windows.Navigation" /> | ||
<Import Include="System.Windows.Shapes" /> | ||
</ItemGroup> | ||
|
||
</Project> |
18 changes: 18 additions & 0 deletions
18
...Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-VisualBasic/CustomControl1.vb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Public Class CustomControl1 | ||
Inherits Control | ||
|
||
''' To use this custom control in a XAML file in another project, complete the following steps: | ||
''' | ||
''' 1. Add a reference to this project | ||
''' 2. Add the following line to the root element of the XAML file where you wish to use this control: | ||
''' xmlns:MyNamespace="clr-namespace:Company.WpfCustomControlLibrary;assembly=Company.WpfCustomControlLibrary" | ||
''' 2. Use the control in the XAML file: | ||
''' <MyNamespace:CustomControl1/> | ||
|
||
Shared Sub New() | ||
'This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class. | ||
'This style is defined in Themes\Generic.xaml | ||
DefaultStyleKeyProperty.OverrideMetadata(GetType(CustomControl1), New FrameworkPropertyMetadata(GetType(CustomControl1))) | ||
End Sub | ||
|
||
End Class |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.