Skip to content

Commit 868583d

Browse files
committed
Multitargeting updates
1 parent acf30b7 commit 868583d

27 files changed

+105
-89
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setup .NET Core
1717
uses: actions/setup-dotnet@v1
1818
with:
19-
dotnet-version: 5.0.100-preview.8.20417.9
19+
dotnet-version: 5.0.100-rc.1.20452.10
2020
- name: Install dependencies
2121
run: dotnet restore
2222
- name: Build

Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>0.9.2-debug.200915.0</Version>
3+
<Version>0.9.2-preview.200922.0</Version>
44
<Authors>Yimeng Wu</Authors>
55
<Product>ModernWPF UI Library</Product>
66
<PackageLicenseExpression>MIT</PackageLicenseExpression>

Directory.Build.targets

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<Project>
2+
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '4.6.1')) or
3+
'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
4+
<DefineConstants>$(DefineConstants);NET461_OR_NEWER</DefineConstants>
5+
</PropertyGroup>
6+
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '4.6.2')) or
7+
'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
8+
<DefineConstants>$(DefineConstants);NET462_OR_NEWER</DefineConstants>
9+
</PropertyGroup>
10+
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '4.7')) or
11+
'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
12+
<DefineConstants>$(DefineConstants);NET47_OR_NEWER</DefineConstants>
13+
</PropertyGroup>
14+
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '4.7.2')) or
15+
'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
16+
<DefineConstants>$(DefineConstants);NET472_OR_NEWER</DefineConstants>
17+
</PropertyGroup>
18+
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '4.8')) or
19+
'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
20+
<DefineConstants>$(DefineConstants);NET48_OR_NEWER</DefineConstants>
21+
</PropertyGroup>
22+
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '5.0'))">
23+
<DefineConstants>$(DefineConstants);NET5_0_OR_NEWER</DefineConstants>
24+
</PropertyGroup>
25+
26+
<PropertyGroup Condition="'$(SupportedOSPlatform)' != '' and $([MSBuild]::VersionGreaterThan($(SupportedOSPlatform), '7.0'))">
27+
<SupportedOSPlatform>7.0</SupportedOSPlatform>
28+
</PropertyGroup>
29+
30+
<Choose>
31+
<When Condition="'$(UseWinRT)' == 'true'">
32+
<Choose>
33+
<When Condition="$(DefineConstants.Contains('NET5_0_OR_NEWER'))" />
34+
<When Condition="$(DefineConstants.Contains('NET461_OR_NEWER'))">
35+
<ItemGroup>
36+
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.18362.2005" />
37+
</ItemGroup>
38+
</When>
39+
<Otherwise>
40+
<ItemGroup>
41+
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.6.0" />
42+
<Reference Include="Windows">
43+
<HintPath>$(MSBuildThisFileDirectory)WinMD\Windows.WinMD</HintPath>
44+
<IsWinMDFile>true</IsWinMDFile>
45+
<Private>false</Private>
46+
</Reference>
47+
<Reference Include="Windows.Foundation.FoundationContract">
48+
<HintPath>$(MSBuildThisFileDirectory)WinMD\Windows.Foundation.FoundationContract.winmd</HintPath>
49+
<IsWinMDFile>true</IsWinMDFile>
50+
<Private>false</Private>
51+
</Reference>
52+
<Reference Include="Windows.Foundation.UniversalApiContract">
53+
<HintPath>$(MSBuildThisFileDirectory)WinMD\Windows.Foundation.UniversalApiContract.winmd</HintPath>
54+
<IsWinMDFile>true</IsWinMDFile>
55+
<Private>false</Private>
56+
</Reference>
57+
</ItemGroup>
58+
</Otherwise>
59+
</Choose>
60+
</When>
61+
</Choose>
62+
</Project>

ModernWpf.Controls/CommandBarFlyout/CommandBarFlyoutToolBar.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ void UpdateFlowsFromAndFlowsTo()
336336
// Ensure the SizeOfSet and PositionInSet automation properties
337337
// for the primary commands and the MoreButton account for the
338338
// potential MoreButton.
339-
#if NETCOREAPP
339+
#if NET48_OR_NEWER
340340
EnsureAutomationSetCountAndPosition();
341341
#endif
342342

@@ -615,7 +615,7 @@ void UpdateTemplateSettings()
615615
}
616616
}
617617

618-
#if NETCOREAPP
618+
#if NET48_OR_NEWER
619619
void EnsureAutomationSetCountAndPosition()
620620
{
621621
var moreButton = m_moreButton;

ModernWpf.Controls/Flyout/Flyout.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private void PlayOpenAnimation()
110110

111111
if (animateFrom != AnimateFrom.None)
112112
{
113-
#if NETCOREAPP || NET462
113+
#if NET462_OR_NEWER
114114
var bitmapCache = new BitmapCache(VisualTreeHelper.GetDpi(presenter).PixelsPerDip);
115115
#else
116116
var bitmapCache = s_bitmapCacheMode;

ModernWpf.Controls/Flyout/FlyoutPresenter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected override void OnKeyDown(KeyEventArgs e)
6262
}
6363
}
6464

65-
#if NETCOREAPP || NET462
65+
#if NET462_OR_NEWER
6666
protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
6767
{
6868
base.OnDpiChanged(oldDpi, newDpi);

ModernWpf.Controls/ModernWpf.Controls.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net45;net462;netcoreapp3.0;net5.0</TargetFrameworks>
4+
<TargetFrameworks>net45;net462;netcoreapp3.0;net5.0-windows10.0.18362.0</TargetFrameworks>
55
<UseWPF>true</UseWPF>
66
<NeutralLanguage>en-US</NeutralLanguage>
77
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);GetDocumentationFile</TargetsForTfmSpecificBuildOutput>
@@ -22,7 +22,7 @@
2222
<None Include="Properties\DesignTimeResources.xaml" />
2323
</ItemGroup>
2424

25-
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
25+
<ItemGroup Condition="!$(DefineConstants.Contains('NET47_OR_NEWER'))">
2626
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
2727
</ItemGroup>
2828

ModernWpf.Controls/ModernWpfUI.nuspec

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,29 @@
1313
<tags>$tags$</tags>
1414
<dependencies>
1515
<group targetFramework="net45">
16-
<dependency id="System.Runtime.WindowsRuntime" version="4.7.0" exclude="Build,Analyzers" />
16+
<dependency id="System.Runtime.WindowsRuntime" version="4.6.0" exclude="Build,Analyzers" />
1717
<dependency id="System.ValueTuple" version="4.5.0" exclude="Build,Analyzers" />
1818
</group>
1919
<group targetFramework="net462">
20-
<dependency id="System.Runtime.WindowsRuntime" version="4.7.0" exclude="Build,Analyzers" />
2120
<dependency id="System.ValueTuple" version="4.5.0" exclude="Build,Analyzers" />
21+
<dependency id="Microsoft.Windows.SDK.Contracts" version="10.0.18362.2005" exclude="Build,Analyzers" />
2222
</group>
2323
<group targetFramework="netcoreapp3.0">
24-
<dependency id="System.Runtime.WindowsRuntime" version="4.7.0" exclude="Build,Analyzers" />
25-
</group>
26-
<group targetFramework="net5.0">
27-
<dependency id="Microsoft.Windows.CsWinRT" version="0.1.0-prerelease.200629.3" exclude="Build,Analyzers" />
28-
<dependency id="Microsoft.Windows.SDK.NET" version="10.0.18362.3-preview" exclude="Build,Analyzers" />
24+
<dependency id="Microsoft.Windows.SDK.Contracts" version="10.0.18362.2005" exclude="Build,Analyzers" />
2925
</group>
26+
<group targetFramework="net5.0-windows10.0.18362" />
3027
</dependencies>
3128
<frameworkReferences>
3229
<group targetFramework="netcoreapp3.0">
3330
<frameworkReference name="Microsoft.WindowsDesktop.App.WPF" />
3431
</group>
35-
<group targetFramework="net5.0">
32+
<group targetFramework="net5.0-windows10.0.18362">
3633
<frameworkReference name="Microsoft.WindowsDesktop.App.WPF" />
3734
</group>
3835
</frameworkReferences>
36+
<frameworkAssemblies>
37+
<frameworkAssembly assemblyName="netstandard" targetFramework="net472" />
38+
</frameworkAssemblies>
3939
</metadata>
4040
<files>
4141
<file src="bin\$configuration$\**\ModernWpf*.dll" target="lib" />

ModernWpf.Controls/NavigationView/NavigationView.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public NavigationView()
244244
m_navigationViewItemsFactory = new NavigationViewItemsFactory();
245245

246246
m_bitmapCache = new BitmapCache();
247-
#if NETCOREAPP || NET462
247+
#if NET462_OR_NEWER
248248
m_bitmapCache.RenderAtScale = VisualTreeHelper.GetDpi(this).PixelsPerDip;
249249
#endif
250250
}
@@ -5536,7 +5536,7 @@ DependencyObject IControlProtected.GetTemplateChild(string childName)
55365536
return GetTemplateChild(childName);
55375537
}
55385538

5539-
#if NETCOREAPP || NET462
5539+
#if NET462_OR_NEWER
55405540
protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
55415541
{
55425542
base.OnDpiChanged(oldDpi, newDpi);

ModernWpf.Controls/NavigationView/NavigationViewItemAutomationPeer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected override AutomationControlType GetAutomationControlTypeCore()
7777
}
7878
}
7979

80-
#if NETCOREAPP || NET48
80+
#if NET48_OR_NEWER
8181
protected override int GetPositionInSetCore()
8282
{
8383
int positionInSet = 0;

ModernWpf.Controls/RadioButtons/RadioButtons.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ void OnRepeaterElementPrepared(ItemsRepeater sender, ItemsRepeaterElementPrepare
428428
Select(args.Index);
429429
}
430430
}
431-
#if NETCOREAPP
431+
#if NET48_OR_NEWER
432432
var repeater = m_repeater;
433433
if (repeater != null)
434434
{
@@ -470,7 +470,7 @@ void OnRepeaterElementIndexChanged(ItemsRepeater sender, ItemsRepeaterElementInd
470470
var element = args.Element;
471471
if (element != null)
472472
{
473-
#if NETCOREAPP
473+
#if NET48_OR_NEWER
474474
element.SetValue(AutomationProperties.PositionInSetProperty, args.NewIndex + 1);
475475
#endif
476476
// When the selected item's index changes, update selection to match
@@ -486,7 +486,7 @@ void OnRepeaterElementIndexChanged(ItemsRepeater sender, ItemsRepeaterElementInd
486486

487487
void OnRepeaterCollectionChanged(object sender, object args)
488488
{
489-
#if NETCOREAPP
489+
#if NET48_OR_NEWER
490490
var repeater = m_repeater;
491491
if (repeater != null)
492492
{

ModernWpf.Controls/ToggleSwitch/ToggleSwitch.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public override void OnApplyTemplate()
305305

306306
if (_bitmapCache == null)
307307
{
308-
#if NETCOREAPP || NET462
308+
#if NET462_OR_NEWER
309309
_bitmapCache = new BitmapCache(VisualTreeHelper.GetDpi(this).PixelsPerDip);
310310
#else
311311
_bitmapCache = new BitmapCache(2);
@@ -344,7 +344,7 @@ protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
344344
}
345345
}
346346

347-
#if NETCOREAPP || NET462
347+
#if NET462_OR_NEWER
348348
protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
349349
{
350350
base.OnDpiChanged(oldDpi, newDpi);

ModernWpf.MahApps/ModernWpf.MahApps.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net452;net46;net462;net47;netcoreapp3.0;netcoreapp3.1;net5.0</TargetFrameworks>
4+
<TargetFrameworks>net452;net46;net462;net47;netcoreapp3.0;netcoreapp3.1;net5.0-windows10.0.18362.0</TargetFrameworks>
55
<UseWPF>true</UseWPF>
66
<NeutralLanguage>en-US</NeutralLanguage>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>

ModernWpf.SampleApp/ModernWpf.SampleApp.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
5-
<TargetFrameworks>net45;net462;netcoreapp3.1;net5.0</TargetFrameworks>
5+
<TargetFrameworks>net45;net48;netcoreapp3.1;net5.0-windows10.0.18362.0</TargetFrameworks>
66
<UseWPF>true</UseWPF>
77
<ApplicationIcon>Assets\AppIcon.ico</ApplicationIcon>
88
<LangVersion>8.0</LangVersion>

ModernWpf.sln

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ EndProject
1212
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1387DCAB-42A4-4F47-9E85-16998E2D9C71}"
1313
ProjectSection(SolutionItems) = preProject
1414
Directory.Build.props = Directory.Build.props
15+
Directory.Build.targets = Directory.Build.targets
1516
Settings.XamlStyler = Settings.XamlStyler
1617
EndProjectSection
1718
EndProject
@@ -41,7 +42,7 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "NavigationView_TestUI", "te
4142
EndProject
4243
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestAppUtils", "test\TestAppUtils\TestAppUtils.csproj", "{48F790D9-2231-477E-839B-C4F5C6A20595}"
4344
EndProject
44-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiThreadingSample", "samples\MultiThreadingSample\MultiThreadingSample.csproj", "{4067F104-92D9-4609-AC0A-D02AC5BD444B}"
45+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MultiThreadingSample", "samples\MultiThreadingSample\MultiThreadingSample.csproj", "{4067F104-92D9-4609-AC0A-D02AC5BD444B}"
4546
EndProject
4647
Global
4748
GlobalSection(SharedMSBuildProjectFiles) = preSolution

ModernWpf/Controls/Primitives/MaximizedWindowFixer.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private void SetWindow(Window window)
7070
_hwnd = new WindowInteropHelper(window).Handle;
7171

7272
_window.StateChanged += WindowStateChanged;
73-
#if NETCOREAPP || NET462
73+
#if NET462_OR_NEWER
7474
_window.DpiChanged += WindowDpiChanged;
7575
#endif
7676
_window.Closed += WindowClosed;
@@ -96,7 +96,7 @@ private void UnsubscribeWindowEvents()
9696
{
9797
_window.SourceInitialized -= WindowSourceInitialized;
9898
_window.StateChanged -= WindowStateChanged;
99-
#if NETCOREAPP || NET462
99+
#if NET462_OR_NEWER
100100
_window.DpiChanged -= WindowDpiChanged;
101101
#endif
102102
_window.Closed -= WindowClosed;
@@ -129,7 +129,7 @@ private void WindowStateChanged(object sender, EventArgs e)
129129
UpdateWindowPadding();
130130
}
131131

132-
#if NETCOREAPP || NET462
132+
#if NET462_OR_NEWER
133133
private void WindowDpiChanged(object sender, DpiChangedEventArgs e)
134134
{
135135
InvalidateMaximizedWindowBorder();
@@ -217,7 +217,7 @@ private Thickness GetMaximizedWindowBorder()
217217
}
218218

219219
double dpiScaleX, dpiScaleY;
220-
#if NETCOREAPP || NET462
220+
#if NET462_OR_NEWER
221221
DpiScale dpi = VisualTreeHelper.GetDpi(_window);
222222
dpiScaleX = dpi.DpiScaleX;
223223
dpiScaleY = dpi.DpiScaleY;

ModernWpf/Controls/Primitives/ThemeShadowChrome.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static ThemeShadowChrome()
2626

2727
public ThemeShadowChrome()
2828
{
29-
#if NETCOREAPP || NET462
29+
#if NET462_OR_NEWER
3030
_bitmapCache = new BitmapCache(VisualTreeHelper.GetDpi(this).PixelsPerDip);
3131
#else
3232
_bitmapCache = new BitmapCache();
@@ -281,7 +281,7 @@ protected override Size ArrangeOverride(Size arrangeSize)
281281
return base.ArrangeOverride(arrangeSize);
282282
}
283283

284-
#if NETCOREAPP || NET462
284+
#if NET462_OR_NEWER
285285
protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
286286
{
287287
base.OnDpiChanged(oldDpi, newDpi);

ModernWpf/Media/Animation/NavigationAnimation.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private void OnCompleted(object sender, EventArgs e)
5858

5959
private BitmapCache GetBitmapCache()
6060
{
61-
#if NETCOREAPP || NET462
61+
#if NET462_OR_NEWER
6262
return new BitmapCache(VisualTreeHelper.GetDpi(_element).PixelsPerDip);
6363
#else
6464
return _defaultBitmapCache;

ModernWpf/ModernWpf.csproj

+3-26
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,18 @@
11
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net45;net462;netcoreapp3.0;net5.0</TargetFrameworks>
4+
<TargetFrameworks>net45;net462;netcoreapp3.0;net5.0-windows10.0.18362.0</TargetFrameworks>
55
<UseWPF>true</UseWPF>
66
<NeutralLanguage>en-US</NeutralLanguage>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<LangVersion>8.0</LangVersion>
9+
<UseWinRT>true</UseWinRT>
910
</PropertyGroup>
1011

11-
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
12+
<ItemGroup Condition="!$(DefineConstants.Contains('NET47_OR_NEWER'))">
1213
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
1314
</ItemGroup>
1415

15-
<ItemGroup Condition="'$(TargetFramework)' != 'net5.0'">
16-
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.7.0" />
17-
<Reference Include="Windows">
18-
<HintPath>WinMD\Windows.WinMD</HintPath>
19-
<IsWinMDFile>true</IsWinMDFile>
20-
<Private>false</Private>
21-
</Reference>
22-
<Reference Include="Windows.Foundation.FoundationContract">
23-
<HintPath>WinMD\Windows.Foundation.FoundationContract.winmd</HintPath>
24-
<IsWinMDFile>true</IsWinMDFile>
25-
<Private>false</Private>
26-
</Reference>
27-
<Reference Include="Windows.Foundation.UniversalApiContract">
28-
<HintPath>WinMD\Windows.Foundation.UniversalApiContract.winmd</HintPath>
29-
<IsWinMDFile>true</IsWinMDFile>
30-
<Private>false</Private>
31-
</Reference>
32-
</ItemGroup>
33-
34-
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
35-
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="0.1.0-prerelease.200629.3" />
36-
<PackageReference Include="Microsoft.Windows.SDK.NET" Version="10.0.18362.3-preview" />
37-
</ItemGroup>
38-
3916
<ItemGroup>
4017
<Page Remove="Properties\DesignTimeResources.xaml" />
4118
</ItemGroup>

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Modern styles and controls for your WPF applications.
1010

1111
* [Additional controls](https://github.com/Kinnara/ModernWpf/wiki/Controls#additional-controls) to help you build modern applications. Some are ported from the [Windows UI Library](https://github.com/microsoft/microsoft-ui-xaml).
1212

13-
* Targets .NET Framework 4.5 and .NET Core 3. Runs on Windows Vista SP2 and above.
13+
* Targets .NET Framework 4.5+, .NET Core 3+, and .NET 5. Runs on Windows Vista SP2 and above.
1414

1515
![Overview of controls (light theme)](docs/images/Controls.Light.png "Overview of controls (light theme)")
1616

File renamed without changes.

0 commit comments

Comments
 (0)