├── .github
├── FUNDING.yml
└── workflows
│ ├── cibuild.yml
│ └── publish_to_nuget.yml
├── .gitignore
├── LICENSE
├── README.md
└── src
├── Directory.Build.Props
├── Directory.Build.Targets
├── TestApp
├── App.config
├── App.xaml
├── App.xaml.cs
├── KeyValuePanel.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Samples
│ ├── EnumValuesConverter.cs
│ ├── Numberboxes
│ │ ├── NumberBoxSample1.xaml
│ │ └── NumberBoxSample1.xaml.cs
│ ├── RelativePanels
│ │ ├── Sample1.xaml
│ │ ├── Sample1.xaml.cs
│ │ ├── Sample2.xaml
│ │ ├── Sample2.xaml.cs
│ │ ├── Sample3.xaml
│ │ ├── Sample3.xaml.cs
│ │ ├── Sample4.xaml
│ │ ├── Sample4.xaml.cs
│ │ ├── Sample5.xaml
│ │ └── Sample5.xaml.cs
│ ├── SplitViews
│ │ ├── SV_Sample1.xaml
│ │ └── SV_Sample1.xaml.cs
│ ├── StateTriggers
│ │ ├── AdaptiveTriggerSample.xaml
│ │ ├── AdaptiveTriggerSample.xaml.cs
│ │ ├── SimpleStateSample.xaml
│ │ └── SimpleStateSample.xaml.cs
│ └── TwoPaneViews
│ │ ├── TPSample1.xaml
│ │ └── TPSample1.xaml.cs
└── TestApp.csproj
├── TestAppNetCore
└── TestAppNetCore.csproj
├── UnitTests
├── Framework
│ ├── ApplicationInitializer.cs
│ ├── ImageAnalysis.cs
│ ├── UIHelpers.WPF.cs
│ └── UIHelpers.cs
├── RelativePanelTests.cs
├── TestPages
│ ├── RelativePanel1.xaml
│ └── RelativePanel1.xaml.cs
└── UnitTests.csproj
├── UniversalWPF.SplitView
├── GridLengthAnimation.cs
├── Properties
│ └── AssemblyInfo.cs
├── SplitView.Properties.cs
├── SplitView.cs
├── SplitViewDisplayMode.cs
├── SplitViewPaneClosingEventArgs.cs
├── SplitViewPanePlacement.cs
├── SplitViewTemplateSettings.cs
├── Themes
│ └── Generic.xaml
└── UniversalWPF.SplitView.csproj
├── UniversalWPF.StateTriggers
├── AdaptiveTrigger.cs
├── Properties
│ └── AssemblyInfo.cs
├── SetterBaseCollection.cs
├── StateTrigger.cs
├── StateTriggerBase.cs
├── UniversalWPF.StateTriggers.csproj
├── VisualStateManagerHook.cs
└── VisualStateUwp.cs
├── UniversalWPF.sln
├── UniversalWPF
├── NumberBox
│ ├── NumberBox.cs
│ ├── NumberBox.xaml
│ ├── NumberBoxParser.cs
│ └── NumberFormatters.cs
├── Properties
│ └── AssemblyInfo.cs
├── RelativePanel
│ ├── RPGraph.cs
│ ├── RPNode.cs
│ ├── RelativePanel.AttachedProperties.cs
│ └── RelativePanel.cs
├── Themes
│ └── Generic.xaml
├── TwoPaneView
│ ├── DisplayRegionHelper.cs
│ ├── DisplayRegionHelperInfo.cs
│ ├── TwoPaneView.cs
│ ├── TwoPaneView.xaml
│ ├── TwoPaneViewMode.cs
│ ├── TwoPaneViewPriority.cs
│ ├── TwoPaneViewTallModeConfiguration.cs
│ ├── TwoPaneViewWideModeConfiguration.cs
│ └── ViewMode.cs
├── UniversalWPF.csproj
└── VisualStudioToolsManifest.xml
└── UwpTestApp
├── App.xaml
├── App.xaml.cs
├── Assets
├── LockScreenLogo.scale-200.png
├── SplashScreen.scale-200.png
├── Square150x150Logo.scale-200.png
├── Square44x44Logo.scale-200.png
├── Square44x44Logo.targetsize-24_altform-unplated.png
├── StoreLogo.png
└── Wide310x150Logo.scale-200.png
├── MainPage.xaml
├── MainPage.xaml.cs
├── Package.appxmanifest
├── Properties
├── AssemblyInfo.cs
└── Default.rd.xml
├── Samples
└── StateTriggers
│ ├── AdaptiveTriggerSample.xaml
│ └── AdaptiveTriggerSample.xaml.cs
├── UwpTestApp.csproj
└── UwpTestApp_TemporaryKey.pfx
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: dotMorten
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 |
--------------------------------------------------------------------------------
/.github/workflows/cibuild.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | - release/*
8 | paths-ignore:
9 | - 'docs/**'
10 | pull_request:
11 | branches:
12 | - main
13 | paths-ignore:
14 | - 'docs/**'
15 |
16 | jobs:
17 | build:
18 |
19 | runs-on: windows-latest
20 |
21 | steps:
22 | - name: Clone NmeaParser
23 | uses: actions/checkout@v1
24 |
25 | - name: Setup Visual Studio Command Prompt
26 | uses: microsoft/setup-msbuild@v1.0.2
27 |
28 | - name: Build
29 | run: |
30 | msbuild /restore /t:Build src/UniversalWPF.sln /p:Configuration=Release
31 |
32 | - name: Tests
33 | run: |
34 | dotnet test src/UnitTests/bin/Release/net6.0-windows10.0.19041.0/UnitTests.dll -v normal
35 |
36 | - name: Upload artifacts
37 | uses: actions/upload-artifact@v1
38 | with:
39 | name: NuGet Packages
40 | path: artifacts/NuGet/Release
41 |
--------------------------------------------------------------------------------
/.github/workflows/publish_to_nuget.yml:
--------------------------------------------------------------------------------
1 | name: Publish UniversalWpf NuGet
2 |
3 | on:
4 | workflow_dispatch:
5 |
6 | jobs:
7 | build:
8 |
9 | runs-on: windows-2022
10 |
11 | steps:
12 | - name: Clone Repo
13 | uses: actions/checkout@v1
14 |
15 | - name: Setup Visual Studio Command Prompt
16 | uses: microsoft/setup-msbuild@v1.1
17 |
18 | - name: Get certificate
19 | id: cert_file
20 | uses: timheuer/base64-to-file@v1.2
21 | with:
22 | fileName: 'certfile.pfx'
23 | encodedString: ${{ secrets.BASE64_ENCODED_PFX }}
24 |
25 | - name: Build
26 | run: |
27 | msbuild /restore /t:Build,Pack src/UniversalWPF/UniversalWPF.csproj /p:Configuration=Release /p:CertificatePath=${{ steps.cert_file.outputs.filePath }} /p:CertificatePassword=${{ secrets.PFX_PASSWORD }}
28 |
29 | - name: Sign NuGet Package
30 | run: |
31 | nuget sign artifacts\NuGet\Release\*.nupkg -CertificatePath ${{ steps.cert_file.outputs.filePath }} -CertificatePassword ${{ secrets.PFX_PASSWORD }} -Timestamper http://timestamp.digicert.com -NonInteractive
32 | nuget sign artifacts\NuGet\Release\*.snupkg -CertificatePath ${{ steps.cert_file.outputs.filePath }} -CertificatePassword ${{ secrets.PFX_PASSWORD }} -Timestamper http://timestamp.digicert.com -NonInteractive
33 |
34 | - name: Upload artifacts
35 | uses: actions/upload-artifact@v1
36 | with:
37 | name: NuGet Packages
38 | path: artifacts/NuGet/Release
39 |
40 | - name: Push to NuGet
41 | run: |
42 | dotnet nuget push artifacts\NuGet\Release\*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://nuget.org
43 | dotnet nuget push artifacts\NuGet\Release\*.snupkg -k ${{ secrets.NUGET_API_KEY }} -s https://nuget.org
44 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studo 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | *_i.c
42 | *_p.c
43 | *_i.h
44 | *.ilk
45 | *.meta
46 | *.obj
47 | *.pch
48 | *.pdb
49 | *.pgc
50 | *.pgd
51 | *.rsp
52 | *.sbr
53 | *.tlb
54 | *.tli
55 | *.tlh
56 | *.tmp
57 | *.tmp_proj
58 | *.log
59 | *.vspscc
60 | *.vssscc
61 | .builds
62 | *.pidb
63 | *.svclog
64 | *.scc
65 |
66 | # Chutzpah Test files
67 | _Chutzpah*
68 |
69 | # Visual C++ cache files
70 | ipch/
71 | *.aps
72 | *.ncb
73 | *.opensdf
74 | *.sdf
75 | *.cachefile
76 |
77 | # Visual Studio profiler
78 | *.psess
79 | *.vsp
80 | *.vspx
81 |
82 | # TFS 2012 Local Workspace
83 | $tf/
84 |
85 | # Guidance Automation Toolkit
86 | *.gpState
87 |
88 | # ReSharper is a .NET coding add-in
89 | _ReSharper*/
90 | *.[Rr]e[Ss]harper
91 | *.DotSettings.user
92 |
93 | # JustCode is a .NET coding addin-in
94 | .JustCode
95 |
96 | # TeamCity is a build add-in
97 | _TeamCity*
98 |
99 | # DotCover is a Code Coverage Tool
100 | *.dotCover
101 |
102 | # NCrunch
103 | _NCrunch_*
104 | .*crunch*.local.xml
105 |
106 | # MightyMoose
107 | *.mm.*
108 | AutoTest.Net/
109 |
110 | # Web workbench (sass)
111 | .sass-cache/
112 |
113 | # Installshield output folder
114 | [Ee]xpress/
115 |
116 | # DocProject is a documentation generator add-in
117 | DocProject/buildhelp/
118 | DocProject/Help/*.HxT
119 | DocProject/Help/*.HxC
120 | DocProject/Help/*.hhc
121 | DocProject/Help/*.hhk
122 | DocProject/Help/*.hhp
123 | DocProject/Help/Html2
124 | DocProject/Help/html
125 |
126 | # Click-Once directory
127 | publish/
128 |
129 | # Publish Web Output
130 | *.[Pp]ublish.xml
131 | *.azurePubxml
132 | # TODO: Comment the next line if you want to checkin your web deploy settings
133 | # but database connection strings (with potential passwords) will be unencrypted
134 | *.pubxml
135 | *.publishproj
136 |
137 | # NuGet Packages
138 | *.nupkg
139 | # The packages folder can be ignored because of Package Restore
140 | **/packages/*
141 | # except build/, which is used as an MSBuild target.
142 | !**/packages/build/
143 | # Uncomment if necessary however generally it will be regenerated when needed
144 | #!**/packages/repositories.config
145 |
146 | # Windows Azure Build Output
147 | csx/
148 | *.build.csdef
149 |
150 | # Windows Store app package directory
151 | AppPackages/
152 |
153 | # Others
154 | *.[Cc]ache
155 | ClientBin/
156 | [Ss]tyle[Cc]op.*
157 | ~$*
158 | *~
159 | *.dbmdl
160 | *.dbproj.schemaview
161 | *.pfx
162 | *.publishsettings
163 | node_modules/
164 | bower_components/
165 |
166 | # RIA/Silverlight projects
167 | Generated_Code/
168 |
169 | # Backup & report files from converting an old project file
170 | # to a newer Visual Studio version. Backup files are not needed,
171 | # because we have git ;-)
172 | _UpgradeReport_Files/
173 | Backup*/
174 | UpgradeLog*.XML
175 | UpgradeLog*.htm
176 |
177 | # SQL Server files
178 | *.mdf
179 | *.ldf
180 |
181 | # Business Intelligence projects
182 | *.rdl.data
183 | *.bim.layout
184 | *.bim_*.settings
185 |
186 | # Microsoft Fakes
187 | FakesAssemblies/
188 |
189 | # Node.js Tools for Visual Studio
190 | .ntvs_analysis.dat
191 |
192 | # Visual Studio 6 build log
193 | *.plg
194 |
195 | # Visual Studio 6 workspace options file
196 | *.opt
197 | project.lock.json
198 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # UniversalWPF
2 | A set of WPF Controls ported from Windows Universal apps / WinUI
3 |
4 | NOTE: This is mostly a work in progress. TwoPaneView is fully working, but might have issues on Windows X, as the necessary APIs there to do screen spanning are not yet exposed.
5 | State Triggers are not working yet. RelativePanel _should_ work but needs lots of testing (please help!), SplitView is partially working, but needs some work still.
6 |
7 | # NuGet / Usage
8 |
9 | Install this from NuGet:
10 |
11 | > `Install-Package UniversalWPF`
12 |
13 | No xmlns registration needed in your xaml files! You can just use the controls prefix-less like the built-in controls. Example:
14 |
15 | ```xml
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | ```
24 |
25 | ## Sponsoring
26 |
27 | If you like this library and use it a lot, consider sponsoring me. Anything helps and encourages me to keep going.
28 |
29 | See here for details: https://github.com/sponsors/dotMorten
30 |
31 | ### Controls
32 | - [TwoPaneView](https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/two-pane-view) - A full port of UWP's TwoPaneView control, including support the Windows X Dual-screen devices.
33 |
34 | 
35 |
36 | - [NumberBox](https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/number-box) - A full port of UWP's NumberBox control.
37 |
38 | 
39 |
40 | - [RelativePanel](https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Controls.RelativePanel) - Identical behavior to UWP/WinUI. Want to see this built-in in WPF? [Vote here](https://github.com/dotnet/wpf/issues/112)
41 |
42 | 
43 |
44 | ### In Progress
45 |
46 | - SplitView (Very much work in progress - doesn't animate in/out and closed compact mode isn't rendering)
47 |
48 | - StateTrigger / AdaptiveTrigger (API complete, functionality not so much)
49 |
50 | 
51 |
52 |
53 |
--------------------------------------------------------------------------------
/src/Directory.Build.Props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | UniversalWPF
5 | true
6 | $(MSBuildThisFileDirectory)..\artifacts\NuGet\$(Configuration)\
7 | Morten Nielsen
8 | Morten Nielsen - https://xaml.dev
9 | git
10 | https://github.com/dotMorten/UniversalWPF
11 | MIT
12 | https://github.com/dotMorten/UniversalWPF
13 | Universal WPF - A set of WPF controls and APIs built to match UWP counterparts.
14 | Copyright © 2021-$([System.DateTime]::Now.ToString('yyyy')) - Morten Nielsen
15 | WPF
16 | true
17 | true
18 | snupkg
19 | $(MSBuildThisFileDirectory)..\artifacts\nuget\$(Configuration)
20 | 1.0.0
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/Directory.Build.Targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(OutputPath)\$(AssemblyName).xml
5 |
6 |
7 |
8 |
9 | $(ProgramFiles)\Windows Kits\10\bin\x64\signtool.exe
10 | $(ProgramFiles)\Windows Kits\10\bin\10.0.22000.0\x64\signtool.exe
11 | $(ProgramFiles)\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe
12 | $(ProgramFiles)\Windows Kits\10\bin\10.0.18362.0\x64\signtool.exe
13 | $(ProgramFiles)\Windows Kits\10\bin\10.0.17134.0\x64\signtool.exe
14 | $(WindowsSDK80Path)bin\x64\signtool.exe
15 | signtool.exe
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
25 |
27 |
28 |
--------------------------------------------------------------------------------
/src/TestApp/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/TestApp/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/TestApp/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace TestApp
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/TestApp/KeyValuePanel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 |
9 | namespace TestApp.Samples
10 | {
11 | public class KeyValuePanel : Panel
12 | {
13 | protected override Size MeasureOverride(Size availableSize)
14 | {
15 | int pairCount = (int)Math.Ceiling(Children.Count / 2d);
16 | if (pairCount == 0)
17 | return new Size(0, 0);
18 | double cellWidth = 0;
19 | double cellHeight = 0;
20 | double maxWidth = Orientation == Orientation.Horizontal ? availableSize.Width / pairCount : availableSize.Width / 2;
21 | double maxHeight = Orientation == Orientation.Horizontal ? availableSize.Height / 2 : availableSize.Height / pairCount;
22 | foreach (var child in Children.OfType())
23 | {
24 | child.Measure(new Size(maxWidth, maxHeight));
25 | cellWidth = Math.Max(cellWidth, child.DesiredSize.Width);
26 | cellHeight = Math.Max(cellHeight, child.DesiredSize.Height);
27 | }
28 | if (Orientation == Orientation.Horizontal)
29 | return new Size(cellWidth * pairCount, cellHeight * 2);
30 | else
31 | return new Size(cellWidth * 2, pairCount * cellHeight);
32 | }
33 | protected override Size ArrangeOverride(Size finalSize)
34 | {
35 | int pairCount = (int)Math.Ceiling(Children.Count / 2d);
36 | if (pairCount == 0)
37 | return new Size(0, 0);
38 | double cellWidth = 0;
39 | double cellHeight = 0;
40 | double maxWidth = Orientation == Orientation.Horizontal ? finalSize.Width / pairCount : finalSize.Width / 2;
41 | double maxHeight = Orientation == Orientation.Horizontal ? finalSize.Height / 2 : finalSize.Height / pairCount;
42 | foreach (var child in Children.OfType())
43 | {
44 | cellWidth = Math.Max(cellWidth, child.DesiredSize.Width);
45 | cellHeight = Math.Max(cellHeight, child.DesiredSize.Height);
46 | }
47 | double x = 0;
48 | double y = 0;
49 | int count = 0;
50 | foreach (var child in Children.OfType())
51 | {
52 | child.Arrange(new Rect(x, y, cellWidth, cellHeight));
53 | if(Orientation == Orientation.Horizontal)
54 | {
55 | if (count % 2 == 1)
56 | {
57 | x += cellWidth;
58 | y = 0;
59 | }
60 | else
61 | {
62 | y += cellHeight;
63 | }
64 | }
65 | else
66 | {
67 | if (count % 2 == 1)
68 | {
69 | y += cellHeight;
70 | x = 0;
71 | }
72 | else
73 | {
74 | x += cellWidth;
75 | }
76 | }
77 | count++;
78 | }
79 | if (Orientation == Orientation.Horizontal)
80 | return new Size(x + cellWidth, cellHeight * 2);
81 | else
82 | return new Size(cellWidth * 2, y + cellHeight);
83 | }
84 |
85 |
86 |
87 | public Orientation Orientation
88 | {
89 | get { return (Orientation)GetValue(OrientationProperty); }
90 | set { SetValue(OrientationProperty, value); }
91 | }
92 |
93 | // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
94 | public static readonly DependencyProperty OrientationProperty =
95 | DependencyProperty.Register(nameof(Orientation), typeof(Orientation), typeof(KeyValuePanel), new PropertyMetadata(Orientation.Horizontal));
96 |
97 |
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/src/TestApp/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/TestApp/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using System.Reflection;
16 |
17 | namespace TestApp
18 | {
19 | ///
20 | /// Interaction logic for MainWindow.xaml
21 | ///
22 | public partial class MainWindow : Window
23 | {
24 | public MainWindow()
25 | {
26 | InitializeComponent();
27 | LoadSamples();
28 | }
29 |
30 | private void LoadSamples()
31 | {
32 | var samples = typeof(TestApp.MainWindow).GetTypeInfo().Assembly.GetTypes().Where(t => t.BaseType == typeof(UserControl) && t.FullName.Contains(".Samples."));
33 |
34 | sampleList.ItemsSource = samples;
35 | }
36 |
37 | private void sampleList_SelectionChanged(object sender, SelectionChangedEventArgs e)
38 | {
39 | if (e.AddedItems != null && e.AddedItems.Count > 0)
40 | {
41 | var t = e.AddedItems[0] as Type;
42 | var c = t.GetConstructor(new Type[] { });
43 | var sampleinstance = c.Invoke(new object[] { }) as UserControl;
44 | sampleView.Children.Clear();
45 | try
46 | {
47 | var ctrl = new ControlExceptionHandler() { Content = sampleinstance };
48 | sampleView.Children.Add(ctrl);
49 | }
50 | catch (System.Exception ex)
51 | {
52 | }
53 | }
54 | }
55 |
56 | private class ControlExceptionHandler : ContentControl
57 | {
58 | protected override Size ArrangeOverride(Size arrangeBounds)
59 | {
60 | try
61 | {
62 | return base.ArrangeOverride(arrangeBounds);
63 | }
64 | catch (System.Exception ex)
65 | {
66 | Content = new TextBlock()
67 | {
68 | Text = "Arrange failed:\n" + ex.Message,
69 | FontSize = 20,
70 | HorizontalAlignment = HorizontalAlignment.Center,
71 | VerticalAlignment = VerticalAlignment.Center,
72 | TextWrapping = TextWrapping.Wrap
73 | };
74 | return base.ArrangeOverride(arrangeBounds);
75 | }
76 | }
77 |
78 | protected override Size MeasureOverride(Size constraint)
79 | {
80 | try
81 | {
82 | return base.MeasureOverride(constraint);
83 | }
84 | catch (System.Exception ex)
85 | {
86 | Content = new TextBlock()
87 | {
88 | Text = "Measure failed:\n" + ex.Message,
89 | FontSize = 20,
90 | HorizontalAlignment = HorizontalAlignment.Center,
91 | VerticalAlignment = VerticalAlignment.Center,
92 | TextWrapping = TextWrapping.Wrap
93 | };
94 | return base.MeasureOverride(constraint);
95 | }
96 | }
97 | }
98 |
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/src/TestApp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("TestApp")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("TestApp")]
15 | [assembly: AssemblyCopyright("Copyright © 2015")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/src/TestApp/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace TestApp.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TestApp.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/TestApp/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/src/TestApp/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace TestApp.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/TestApp/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/EnumValuesConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Data;
8 |
9 | namespace TestApp.Samples
10 | {
11 | public class EnumValuesConverter : IValueConverter
12 | {
13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
14 | {
15 | Type enumType = null;
16 | if(parameter is string typename)
17 | {
18 | enumType = Type.GetType(typename);
19 | }
20 | else if(parameter is Type t)
21 | {
22 | enumType = t;
23 | }
24 | if(enumType.IsEnum)
25 | {
26 | return Enum.GetValues(enumType);
27 | }
28 | return value;
29 | }
30 |
31 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
32 | {
33 | throw new NotImplementedException();
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/Numberboxes/NumberBoxSample1.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
20 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
34 |
35 |
36 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
64 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/Numberboxes/NumberBoxSample1.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 |
17 | namespace TestApp.Samples.Numberboxes
18 | {
19 | ///
20 | /// Interaction logic for NumberBoxSample1.xaml
21 | ///
22 | public partial class NumberBoxSample1 : UserControl
23 | {
24 | public NumberBoxSample1()
25 | {
26 | DataContext = this;
27 | InitializeComponent();
28 | }
29 | public DataModelWithINPC DataModelWithINPC { get; } = new DataModelWithINPC();
30 |
31 | private void SetTwoWayBoundNaNButton_Click(object sender, RoutedEventArgs e)
32 | {
33 | DataModelWithINPC.Value = double.NaN;
34 | TwoWayBoundNumberBoxValue.Text = TwoWayBoundNumberBox.Value.ToString();
35 | }
36 | }
37 |
38 | public class DataModelWithINPC : INotifyPropertyChanged
39 | {
40 | private double _value;
41 |
42 | public event PropertyChangedEventHandler PropertyChanged;
43 |
44 | protected virtual void OnPropertyChanged(string propertyName)
45 | {
46 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
47 | }
48 |
49 | public double Value
50 | {
51 | get => _value;
52 | set
53 | {
54 | if (value != _value)
55 | {
56 | _value = value;
57 | OnPropertyChanged(nameof(this.Value));
58 | }
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/RelativePanels/Sample1.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
22 |
23 |
25 |
31 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/RelativePanels/Sample1.xaml.cs:
--------------------------------------------------------------------------------
1 | #if NETFX_CORE
2 | using Windows.UI.Xaml.Controls;
3 | #else
4 | using System.Windows.Controls;
5 | #endif
6 |
7 | namespace TestApp.Samples.RelativePanels
8 | {
9 | public sealed partial class Sample1 : UserControl
10 | {
11 | public Sample1()
12 | {
13 | this.InitializeComponent();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/RelativePanels/Sample2.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
16 |
20 |
25 |
26 |
30 |
31 |
34 |
35 |
39 |
40 |
45 |
50 |
58 |
59 |
64 |
68 |
69 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/RelativePanels/Sample2.xaml.cs:
--------------------------------------------------------------------------------
1 | #if NETFX_CORE
2 | using Windows.UI.Xaml.Controls;
3 | #else
4 | using System.Windows.Controls;
5 | #endif
6 |
7 | namespace TestApp.Samples.RelativePanels
8 | {
9 | public sealed partial class Sample2 : UserControl
10 | {
11 | public Sample2()
12 | {
13 | this.InitializeComponent();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/RelativePanels/Sample3.xaml:
--------------------------------------------------------------------------------
1 |
10 |
15 |
16 |
18 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/RelativePanels/Sample3.xaml.cs:
--------------------------------------------------------------------------------
1 | #if NETFX_CORE
2 | using Windows.UI.Xaml.Controls;
3 | #else
4 | using System.Windows.Controls;
5 | #endif
6 |
7 | namespace TestApp.Samples.RelativePanels
8 | {
9 | public sealed partial class Sample3 : UserControl
10 | {
11 | public Sample3()
12 | {
13 | this.InitializeComponent();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/RelativePanels/Sample4.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/RelativePanels/Sample4.xaml.cs:
--------------------------------------------------------------------------------
1 | #if NETFX_CORE
2 | using Windows.UI.Xaml.Controls;
3 | #else
4 | using System.Windows.Controls;
5 | #endif
6 |
7 | namespace TestApp.Samples.RelativePanels
8 | {
9 | public sealed partial class Sample4 : UserControl
10 | {
11 | public Sample4()
12 | {
13 | this.InitializeComponent();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/RelativePanels/Sample5.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/RelativePanels/Sample5.xaml.cs:
--------------------------------------------------------------------------------
1 | #if NETFX_CORE
2 | using Windows.UI.Xaml.Controls;
3 | #else
4 | using System.Windows.Controls;
5 | #endif
6 |
7 | namespace TestApp.Samples.RelativePanels
8 | {
9 | public sealed partial class Sample5 : UserControl
10 | {
11 | public Sample5()
12 | {
13 | this.InitializeComponent();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/SplitViews/SV_Sample1.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Inline
23 | Overlay
24 | CompactInline
25 | CompactOverlay
26 |
27 |
28 |
29 | Left
30 | Right
31 |
32 |
33 |
34 |
35 |
36 |
37 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/SplitViews/SV_Sample1.xaml.cs:
--------------------------------------------------------------------------------
1 | #if NETFX_CORE
2 | using Windows.UI.Xaml.Controls;
3 | #else
4 | using System.Windows.Controls;
5 | using UniversalWPF;
6 | #endif
7 |
8 | namespace TestApp.Samples.SplitViews
9 | {
10 | public sealed partial class Sample1 : UserControl
11 | {
12 | public Sample1()
13 | {
14 | this.InitializeComponent();
15 | }
16 |
17 | private void splitview_PaneClosing(object sender, SplitViewPaneClosingEventArgs e)
18 | {
19 | e.Cancel = cancelClose.IsChecked.Value;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/StateTriggers/AdaptiveTriggerSample.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/StateTriggers/AdaptiveTriggerSample.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace TestApp.Samples.StateTriggers
17 | {
18 | ///
19 | /// Interaction logic for SimpleStateSample.xaml
20 | ///
21 | public partial class AdaptiveTriggerSample : UserControl
22 | {
23 | public AdaptiveTriggerSample()
24 | {
25 | InitializeComponent();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/StateTriggers/SimpleStateSample.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
19 |
20 |
21 |
22 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/StateTriggers/SimpleStateSample.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace TestApp.Samples.StateTriggers
17 | {
18 | ///
19 | /// Interaction logic for SimpleStateSample.xaml
20 | ///
21 | public partial class SimpleStateSample : UserControl
22 | {
23 | public SimpleStateSample()
24 | {
25 | InitializeComponent();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/TwoPaneViews/TPSample1.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
39 |
40 |
41 |
42 |
45 |
48 |
49 |
50 |
53 |
54 |
57 |
58 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/src/TestApp/Samples/TwoPaneViews/TPSample1.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using System.Windows.Controls;
7 |
8 | namespace TestApp.Samples.TwoPaneViews
9 | {
10 | ///
11 | /// An empty page that can be used on its own or navigated to within a Frame.
12 | ///
13 | public sealed partial class TPSample1 : UserControl
14 | {
15 | public TPSample1()
16 | {
17 | this.InitializeComponent();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/TestApp/TestApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {08FA4AD4-AB63-4F81-AB39-900F5D6A4462}
8 | WinExe
9 | Properties
10 | TestApp
11 | TestApp
12 | v4.5.2
13 | 512
14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | 4
16 | true
17 |
18 |
19 | AnyCPU
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 |
28 |
29 | AnyCPU
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | 4.0
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | MSBuild:Compile
56 | Designer
57 |
58 |
59 |
60 |
61 | NumberBoxSample1.xaml
62 |
63 |
64 | Sample1.xaml
65 |
66 |
67 | Sample2.xaml
68 |
69 |
70 | Sample3.xaml
71 |
72 |
73 | Sample5.xaml
74 |
75 |
76 | Sample4.xaml
77 |
78 |
79 | SV_Sample1.xaml
80 |
81 |
82 | AdaptiveTriggerSample.xaml
83 |
84 |
85 | SimpleStateSample.xaml
86 |
87 |
88 | TPSample1.xaml
89 |
90 |
91 | MSBuild:Compile
92 | Designer
93 |
94 |
95 | App.xaml
96 | Code
97 |
98 |
99 | MainWindow.xaml
100 | Code
101 |
102 |
103 | Designer
104 | MSBuild:Compile
105 |
106 |
107 | MSBuild:Compile
108 | Designer
109 |
110 |
111 | MSBuild:Compile
112 | Designer
113 |
114 |
115 | MSBuild:Compile
116 | Designer
117 |
118 |
119 | MSBuild:Compile
120 | Designer
121 |
122 |
123 | MSBuild:Compile
124 | Designer
125 |
126 |
127 | MSBuild:Compile
128 | Designer
129 |
130 |
131 | MSBuild:Compile
132 | Designer
133 |
134 |
135 | Designer
136 | MSBuild:Compile
137 |
138 |
139 | Designer
140 | MSBuild:Compile
141 |
142 |
143 |
144 |
145 | Code
146 |
147 |
148 | True
149 | True
150 | Resources.resx
151 |
152 |
153 | True
154 | Settings.settings
155 | True
156 |
157 |
158 | ResXFileCodeGenerator
159 | Resources.Designer.cs
160 |
161 |
162 | SettingsSingleFileGenerator
163 | Settings.Designer.cs
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 | {f3bad196-2f0c-4302-ab89-8c7f1362568d}
173 | UniversalWPF.SplitView
174 |
175 |
176 | {601a0fba-133a-4e0e-9955-1eb01fc8eb11}
177 | UniversalWPF.StateTriggers
178 |
179 |
180 | {08527b7c-04bc-4d92-8546-bee72d8a53d2}
181 | UniversalWPF
182 |
183 |
184 |
185 |
192 |
--------------------------------------------------------------------------------
/src/TestAppNetCore/TestAppNetCore.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net6.0-windows10.0.19041.0
6 | true
7 | TestApp
8 | TestApp
9 |
10 |
11 |
12 |
13 |
14 | XamlIntelliSenseFileGenerator
15 | Never
16 |
17 |
18 | XamlIntelliSenseFileGenerator
19 | Never
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/UnitTests/Framework/ApplicationInitializer.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Reflection;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Media;
10 |
11 | namespace UnitTests
12 | {
13 | [TestClass]
14 | public class ApplicationInitializer
15 | {
16 | internal static System.Threading.Thread UIThread;
17 | internal static System.Windows.Window window;
18 |
19 | [AssemblyInitialize]
20 | public static void AssemblyInitialize(TestContext context)
21 | {
22 | var waitForApplicationRun = new TaskCompletionSource();
23 | System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(() =>
24 | //Task.Run(() =>
25 | {
26 | var application = new System.Windows.Application();
27 |
28 | application.Startup += (s, e) => {
29 | application.Dispatcher.Invoke(() =>
30 | {
31 | application.MainWindow = window = new System.Windows.Window();
32 | application.MainWindow.Background = new SolidColorBrush(Colors.Black);
33 | window.Content = new System.Windows.Controls.ContentControl();
34 | window.Show();
35 | waitForApplicationRun.SetResult(true);
36 | });
37 | };
38 | application.Run();
39 | return;
40 | }));
41 | t.SetApartmentState(System.Threading.ApartmentState.STA);
42 | t.Start();
43 | UIThread = t;
44 | waitForApplicationRun.Task.Wait();
45 | }
46 |
47 |
48 | [AssemblyCleanup]
49 | public static void AssemblyCleanup()
50 | {
51 | window?.Dispatcher?.Invoke(() => { window?.Close(); });
52 |
53 | // UIThread.Abort();
54 | var app = System.Windows.Application.Current;
55 | if( app != null)
56 | {
57 | var d = app.Dispatcher;
58 | if (d != null && !(d.HasShutdownStarted || d.HasShutdownFinished))
59 | {
60 | try
61 | {
62 | d.Invoke(() =>
63 | {
64 | if (!(d.HasShutdownStarted || d.HasShutdownFinished))
65 | app.Shutdown();
66 | });
67 | }
68 | catch (TaskCanceledException) { }
69 | }
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/UnitTests/Framework/UIHelpers.WPF.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Media;
9 | using System.Windows.Media.Imaging;
10 |
11 | namespace UnitTests
12 | {
13 | public partial class UIHelpers
14 | {
15 | public static void ApplySizeToView(System.Windows.FrameworkElement view, double width, double height, double scaleFactor)
16 | {
17 | view.Width = width;
18 | view.Height = height;
19 | }
20 |
21 | public static async Task RenderAsync(FrameworkElement visual, double scaleFactor)
22 | {
23 | TaskCompletionSource