├── .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 | ![TwoPaneView](https://user-images.githubusercontent.com/1378165/74808461-c238c700-529f-11ea-93c5-33ca1063f8fd.gif) 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 | ![numberbox](https://user-images.githubusercontent.com/1378165/75103965-70ea4980-55b7-11ea-843d-57dcc021053f.gif) 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 | ![RelativePanel](https://cloud.githubusercontent.com/assets/1378165/10120048/b76250f0-645e-11e5-9b4d-2a0d7026a467.gif) 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 | ![image](https://cloud.githubusercontent.com/assets/1378165/10121609/94743df6-64a9-11e5-9908-29c0aeaf3c7f.png) 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 |