├── src ├── UwpTestApp │ ├── Assets │ │ ├── StoreLogo.png │ │ ├── LockScreenLogo.scale-200.png │ │ ├── SplashScreen.scale-200.png │ │ ├── Square44x44Logo.scale-200.png │ │ ├── Wide310x150Logo.scale-200.png │ │ ├── Square150x150Logo.scale-200.png │ │ └── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── UwpTestApp_TemporaryKey.pfx │ ├── App.xaml │ ├── Samples │ │ └── StateTriggers │ │ │ ├── AdaptiveTriggerSample.xaml.cs │ │ │ └── AdaptiveTriggerSample.xaml │ ├── MainPage.xaml │ ├── MainPage.xaml.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── Default.rd.xml │ ├── Package.appxmanifest │ ├── App.xaml.cs │ └── UwpTestApp.csproj ├── TestApp │ ├── App.config │ ├── Properties │ │ ├── Settings.settings │ │ ├── Settings.Designer.cs │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── App.xaml.cs │ ├── App.xaml │ ├── Samples │ │ ├── RelativePanels │ │ │ ├── Sample1.xaml.cs │ │ │ ├── Sample2.xaml.cs │ │ │ ├── Sample3.xaml.cs │ │ │ ├── Sample4.xaml.cs │ │ │ ├── Sample5.xaml.cs │ │ │ ├── Sample3.xaml │ │ │ ├── Sample4.xaml │ │ │ ├── Sample5.xaml │ │ │ ├── Sample1.xaml │ │ │ └── Sample2.xaml │ │ ├── SplitViews │ │ │ ├── SV_Sample1.xaml.cs │ │ │ └── SV_Sample1.xaml │ │ ├── TwoPaneViews │ │ │ ├── TPSample1.xaml.cs │ │ │ └── TPSample1.xaml │ │ ├── StateTriggers │ │ │ ├── SimpleStateSample.xaml.cs │ │ │ ├── AdaptiveTriggerSample.xaml.cs │ │ │ ├── SimpleStateSample.xaml │ │ │ └── AdaptiveTriggerSample.xaml │ │ ├── EnumValuesConverter.cs │ │ └── Numberboxes │ │ │ ├── NumberBoxSample1.xaml.cs │ │ │ └── NumberBoxSample1.xaml │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── KeyValuePanel.cs │ └── TestApp.csproj ├── UniversalWPF │ ├── VisualStudioToolsManifest.xml │ ├── Themes │ │ └── Generic.xaml │ ├── UniversalWPF.csproj │ ├── TwoPaneView │ │ ├── ViewMode.cs │ │ ├── DisplayRegionHelperInfo.cs │ │ ├── TwoPaneViewPriority.cs │ │ ├── TwoPaneViewMode.cs │ │ ├── TwoPaneViewTallModeConfiguration.cs │ │ ├── TwoPaneViewWideModeConfiguration.cs │ │ ├── DisplayRegionHelper.cs │ │ └── TwoPaneView.xaml │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── RelativePanel │ │ └── RelativePanel.cs │ └── NumberBox │ │ └── NumberFormatters.cs ├── UnitTests │ ├── TestPages │ │ ├── RelativePanel1.xaml.cs │ │ └── RelativePanel1.xaml │ ├── Framework │ │ ├── UIHelpers.cs │ │ ├── ApplicationInitializer.cs │ │ └── UIHelpers.WPF.cs │ ├── UnitTests.csproj │ └── RelativePanelTests.cs ├── UniversalWPF.SplitView │ ├── SplitViewPanePlacement.cs │ ├── UniversalWPF.SplitView.csproj │ ├── SplitViewPaneClosingEventArgs.cs │ ├── SplitViewDisplayMode.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── GridLengthAnimation.cs │ ├── SplitViewTemplateSettings.cs │ ├── SplitView.cs │ └── SplitView.Properties.cs ├── UniversalWPF.StateTriggers │ ├── UniversalWPF.StateTriggers.csproj │ ├── StateTriggerBase.cs │ ├── StateTrigger.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── VisualStateManagerHook.cs │ ├── SetterBaseCollection.cs │ ├── AdaptiveTrigger.cs │ └── VisualStateUwp.cs ├── TestAppNetCore │ └── TestAppNetCore.csproj ├── Directory.Build.Props └── Directory.Build.Targets ├── .github ├── FUNDING.yml └── workflows │ ├── cibuild.yml │ └── publish_to_nuget.yml ├── README.md └── .gitignore /src/UwpTestApp/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/UniversalWPF/HEAD/src/UwpTestApp/Assets/StoreLogo.png -------------------------------------------------------------------------------- /src/UwpTestApp/UwpTestApp_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/UniversalWPF/HEAD/src/UwpTestApp/UwpTestApp_TemporaryKey.pfx -------------------------------------------------------------------------------- /src/UwpTestApp/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/UniversalWPF/HEAD/src/UwpTestApp/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /src/UwpTestApp/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/UniversalWPF/HEAD/src/UwpTestApp/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /src/UwpTestApp/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/UniversalWPF/HEAD/src/UwpTestApp/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /src/UwpTestApp/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/UniversalWPF/HEAD/src/UwpTestApp/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /src/UwpTestApp/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/UniversalWPF/HEAD/src/UwpTestApp/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /src/UwpTestApp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotMorten/UniversalWPF/HEAD/src/UwpTestApp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /src/TestApp/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/TestApp/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/UwpTestApp/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/UniversalWPF/VisualStudioToolsManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /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/UnitTests/TestPages/RelativePanel1.xaml.cs: -------------------------------------------------------------------------------- 1 | #if NETFX_CORE 2 | using Windows.UI.Xaml.Controls; 3 | #else 4 | using System.Windows.Controls; 5 | #endif 6 | 7 | namespace UnitTests.TestPages 8 | { 9 | public sealed partial class RelativePanel1 : UserControl 10 | { 11 | public RelativePanel1() 12 | { 13 | this.InitializeComponent(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/TestApp/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /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.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.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.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.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/UniversalWPF/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /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/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/UwpTestApp/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 Windows.UI.Xaml.Controls; 8 | 9 | namespace TestApp.Samples.StateTriggers 10 | { 11 | /// 12 | /// Interaction logic for SimpleStateSample.xaml 13 | /// 14 | public partial class AdaptiveTriggerSample : UserControl 15 | { 16 | public AdaptiveTriggerSample() 17 | { 18 | InitializeComponent(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/UniversalWPF.SplitView/SplitViewPanePlacement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace UniversalWPF 8 | { 9 | /// 10 | /// Defines constants that specify whether the pane is to the left or right of the 11 | /// content in a SplitView. 12 | /// 13 | public enum SplitViewPanePlacement 14 | { 15 | /// 16 | /// The pane is shown to the left of the SplitView content. 17 | /// 18 | Left = 0, 19 | /// 20 | /// The pane is shown to the right of the SplitView content. 21 | /// 22 | Right = 1 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /src/UniversalWPF.SplitView/UniversalWPF.SplitView.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0-windows10.0.19041.0;net452 5 | Library 6 | $(PackageTags) SplitView 7 | true 8 | 9 | 10 | 11 | 12 | 4.0 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/UniversalWPF.SplitView/SplitViewPaneClosingEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace UniversalWPF 8 | { 9 | /// 10 | /// Provides event data for the SplitView.PaneClosing event. 11 | /// 12 | public sealed class SplitViewPaneClosingEventArgs : EventArgs 13 | { 14 | internal SplitViewPaneClosingEventArgs() { } 15 | /// 16 | /// Gets or sets a value that indicates whether the pane closing action should be 17 | /// canceled. 18 | /// 19 | /// true to cancel the pane closing action; otherwise, false. 20 | public bool Cancel { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/UnitTests/Framework/UIHelpers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace UnitTests 5 | { 6 | public class DisplayInfo 7 | { 8 | public double ScaleFactor { get; internal set; } = 1; 9 | public double Width { get; internal set; } 10 | public double Height { get; internal set; } 11 | } 12 | 13 | public partial class UIHelpers 14 | { 15 | public static Task RunUITest(Func action, [System.Runtime.CompilerServices.CallerFilePath] string testFilePath = null, [System.Runtime.CompilerServices.CallerMemberName] string testName = null) 16 | { 17 | return RunUITest_Impl(action, testFilePath, testName); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /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/UnitTests/UnitTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net6.0-windows10.0.19041.0;net462 4 | false 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /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/UniversalWPF.StateTriggers/UniversalWPF.StateTriggers.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0-windows10.0.19041.0;net452 5 | Library 6 | $(PackageTags) AdaptiveTriggers StateTriggers 7 | true 8 | 9 | 10 | 11 | 12 | 4.0 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/UwpTestApp/MainPage.xaml: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/UwpTestApp/MainPage.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 Windows.Foundation; 7 | using Windows.Foundation.Collections; 8 | using Windows.UI.Xaml; 9 | using Windows.UI.Xaml.Controls; 10 | using Windows.UI.Xaml.Controls.Primitives; 11 | using Windows.UI.Xaml.Data; 12 | using Windows.UI.Xaml.Input; 13 | using Windows.UI.Xaml.Media; 14 | using Windows.UI.Xaml.Navigation; 15 | 16 | // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 17 | 18 | namespace UwpTestApp 19 | { 20 | /// 21 | /// An empty page that can be used on its own or navigated to within a Frame. 22 | /// 23 | public sealed partial class MainPage : Page 24 | { 25 | public MainPage() 26 | { 27 | this.InitializeComponent(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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/Samples/RelativePanels/Sample3.xaml: -------------------------------------------------------------------------------- 1 | 10 | 15 | 16 | 18 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /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/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/UwpTestApp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("UwpTestApp")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("UwpTestApp")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /src/UniversalWPF/UniversalWPF.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0-windows10.0.19041.0;net452 5 | Library 6 | $(PackageTags), RelativePanel, NumberBox, TwoPaneView 7 | true 8 | 1.0.0 9 | $(Description). Contains the RelativePanel, NumberBox and TwoPaneView controls 10 | 10 11 | $(NoWarn);CS8600;CS8602;CS8604 12 | 13 | 14 | 15 | 16 | 4.0 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/UniversalWPF.StateTriggers/StateTriggerBase.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 | 8 | namespace UniversalWPF 9 | { 10 | /// 11 | /// Represents the base class for state triggers. 12 | /// 13 | public abstract class StateTriggerBase : DependencyObject 14 | { 15 | /// 16 | /// Initializes a new instance of the StateTriggerBase class. 17 | /// 18 | protected StateTriggerBase() { } 19 | 20 | /// 21 | /// Sets the value that indicates whether the state trigger is active. 22 | /// 23 | /// true if the system should apply the trigger; otherwise, false. 24 | protected void SetActive(bool IsActive) 25 | { 26 | //if (IsTriggerActive != IsActive) 27 | { 28 | IsTriggerActive = IsActive; 29 | Owner?.SetActive(IsTriggerActive); 30 | } 31 | } 32 | 33 | internal bool IsTriggerActive { get; private set; } 34 | 35 | internal VisualStateUwp Owner { get; set; } 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/TestApp/Samples/RelativePanels/Sample4.xaml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/UwpTestApp/Properties/Default.rd.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/TestApp/Samples/RelativePanels/Sample5.xaml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /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/TestApp/Samples/RelativePanels/Sample1.xaml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 22 | 23 | 25 | 31 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/UniversalWPF.StateTriggers/StateTrigger.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 | 8 | namespace UniversalWPF 9 | { 10 | /// 11 | /// Represents a trigger that applies visual states conditionally. 12 | /// 13 | public class StateTrigger : StateTriggerBase 14 | { 15 | /// 16 | /// Initializes a new instance of the StateTrigger class. 17 | /// 18 | public StateTrigger() { } 19 | 20 | /// 21 | /// Gets or sets a value that indicates whether the trigger should be applied 22 | /// 23 | /// true if the system should apply the trigger; otherwise, false. 24 | public bool IsActive 25 | { 26 | get { return (bool)GetValue(IsActiveProperty); } 27 | set { SetValue(IsActiveProperty, value); } 28 | } 29 | 30 | /// Identifies the IsActive dependency property. 31 | /// The identifier for the IsActive dependency property. 32 | public static readonly DependencyProperty IsActiveProperty = 33 | DependencyProperty.Register("IsActive", typeof(bool), typeof(StateTrigger), new PropertyMetadata(false, OnIsActivePropertyChanged)); 34 | 35 | private static void OnIsActivePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 36 | { 37 | ((StateTrigger)d).SetActive((bool)e.NewValue); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /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/UniversalWPF/TwoPaneView/ViewMode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Based on a port of TwoPaneView control in the WinUI Library: https://github.com/microsoft/microsoft-ui-xaml/ 3 | MIT License 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE 24 | */ 25 | 26 | namespace UniversalWPF 27 | { 28 | internal enum ViewMode 29 | { 30 | Pane1Only, 31 | Pane2Only, 32 | LeftRight, 33 | RightLeft, 34 | TopBottom, 35 | BottomTop, 36 | None 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /src/UniversalWPF.SplitView/SplitViewDisplayMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace UniversalWPF 8 | { 9 | /// 10 | /// Defines constants that specify how the pane is shown in a SplitView. 11 | /// 12 | public enum SplitViewDisplayMode 13 | { 14 | /// 15 | /// The pane covers the content when it's open and does not take up space in the 16 | /// control layout. The pane closes when the user taps outside of it. 17 | /// 18 | Overlay = 0, 19 | /// 20 | /// The pane is shown side-by-side with the content and takes up space in the control 21 | /// layout. The pane does not close when the user taps outside of it. 22 | /// 23 | Inline = 1, 24 | /// 25 | /// The amount of the pane defined by the CompactPaneLength property is shown side-by-side 26 | /// with the content and takes up space in the control layout. The remaining part 27 | /// of the pane covers the content when it's open and does not take up space in the 28 | /// control layout. The pane closes when the user taps outside of it. 29 | /// 30 | CompactOverlay = 2, 31 | /// 32 | /// The amount of the pane defined by the CompactPaneLength property is shown side-by-side 33 | /// with the content and takes up space in the control layout. The remaining part 34 | /// of the pane pushes the content to the side when it's open and takes up space 35 | /// in the control layout. The pane does not close when the user taps outside of 36 | /// it. 37 | /// 38 | CompactInline = 3 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/UniversalWPF/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using System.Windows; 3 | 4 | // Setting ComVisible to false makes the types in this assembly not visible 5 | // to COM components. If you need to access a type in this assembly from 6 | // COM, set the ComVisible attribute to true on that type. 7 | [assembly: ComVisible(false)] 8 | 9 | //In order to begin building localizable applications, set 10 | //CultureYouAreCodingWith in your .csproj file 11 | //inside a . For example, if you are using US english 12 | //in your source files, set the to en-US. Then uncomment 13 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 14 | //the line below to match the UICulture setting in the project file. 15 | 16 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 17 | 18 | 19 | [assembly:ThemeInfo( 20 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 21 | //(used if a resource is not found in the page, 22 | // or application resource dictionaries) 23 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 24 | //(used if a resource is not found in the page, 25 | // app, or any theme specific resource dictionaries) 26 | )] 27 | 28 | 29 | [assembly: System.Windows.Markup.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "UniversalWPF")] 30 | [assembly: System.Windows.Markup.XmlnsPrefix("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "")] 31 | 32 | -------------------------------------------------------------------------------- /src/UniversalWPF.SplitView/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using System.Windows; 3 | 4 | // Setting ComVisible to false makes the types in this assembly not visible 5 | // to COM components. If you need to access a type in this assembly from 6 | // COM, set the ComVisible attribute to true on that type. 7 | [assembly: ComVisible(false)] 8 | 9 | //In order to begin building localizable applications, set 10 | //CultureYouAreCodingWith in your .csproj file 11 | //inside a . For example, if you are using US english 12 | //in your source files, set the to en-US. Then uncomment 13 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 14 | //the line below to match the UICulture setting in the project file. 15 | 16 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 17 | 18 | 19 | [assembly:ThemeInfo( 20 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 21 | //(used if a resource is not found in the page, 22 | // or application resource dictionaries) 23 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 24 | //(used if a resource is not found in the page, 25 | // app, or any theme specific resource dictionaries) 26 | )] 27 | 28 | 29 | [assembly: System.Windows.Markup.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "UniversalWPF")] 30 | [assembly: System.Windows.Markup.XmlnsPrefix("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "")] 31 | 32 | -------------------------------------------------------------------------------- /src/UniversalWPF.StateTriggers/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using System.Windows; 3 | 4 | // Setting ComVisible to false makes the types in this assembly not visible 5 | // to COM components. If you need to access a type in this assembly from 6 | // COM, set the ComVisible attribute to true on that type. 7 | [assembly: ComVisible(false)] 8 | 9 | //In order to begin building localizable applications, set 10 | //CultureYouAreCodingWith in your .csproj file 11 | //inside a . For example, if you are using US english 12 | //in your source files, set the to en-US. Then uncomment 13 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 14 | //the line below to match the UICulture setting in the project file. 15 | 16 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 17 | 18 | 19 | [assembly:ThemeInfo( 20 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 21 | //(used if a resource is not found in the page, 22 | // or application resource dictionaries) 23 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 24 | //(used if a resource is not found in the page, 25 | // app, or any theme specific resource dictionaries) 26 | )] 27 | 28 | 29 | [assembly: System.Windows.Markup.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "UniversalWPF")] 30 | [assembly: System.Windows.Markup.XmlnsPrefix("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "")] 31 | 32 | -------------------------------------------------------------------------------- /src/UwpTestApp/Package.appxmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | UwpTestApp 18 | mort5161 19 | Assets\StoreLogo.png 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /src/UniversalWPF/TwoPaneView/DisplayRegionHelperInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Based on a port of TwoPaneView control in the WinUI Library: https://github.com/microsoft/microsoft-ui-xaml/ 3 | MIT License 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE 24 | */ 25 | 26 | using System.Windows; 27 | 28 | namespace UniversalWPF 29 | { 30 | internal struct DisplayRegionHelperInfo 31 | { 32 | private const int c_maxRegions = 2; 33 | 34 | public DisplayRegionHelperInfo(TwoPaneViewMode mode = TwoPaneViewMode.SinglePane) 35 | { 36 | Regions = new Rect[c_maxRegions]; 37 | Mode = mode; 38 | } 39 | 40 | public TwoPaneViewMode Mode { get; set; } 41 | public Rect[] Regions { get; set; } 42 | } 43 | } -------------------------------------------------------------------------------- /src/UniversalWPF/TwoPaneView/TwoPaneViewPriority.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Based on a port of TwoPaneView control in the WinUI Library: https://github.com/microsoft/microsoft-ui-xaml/ 3 | MIT License 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE 24 | */ 25 | 26 | namespace UniversalWPF 27 | { 28 | /// 29 | /// Defines constants that specify which pane has priority in a TwoPaneView. 30 | /// 31 | /// 32 | /// 33 | public enum TwoPaneViewPriority 34 | { 35 | /// 36 | /// Pane 1 has priority. 37 | /// 38 | Pane1 = 0, 39 | /// 40 | /// Pane 2 has priority. 41 | /// 42 | Pane2 = 1, 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /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/UniversalWPF/TwoPaneView/TwoPaneViewMode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Based on a port of TwoPaneView control in the WinUI Library: https://github.com/microsoft/microsoft-ui-xaml/ 3 | MIT License 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE 24 | */ 25 | 26 | namespace UniversalWPF 27 | { 28 | /// 29 | /// Defines constants that specify how panes are shown in a . 30 | /// 31 | /// 32 | /// 33 | public enum TwoPaneViewMode 34 | { 35 | /// 36 | /// Only one pane is shown. 37 | /// 38 | SinglePane = 0, 39 | 40 | /// 41 | /// Panes are shown side-by-side. 42 | /// 43 | Wide = 1, 44 | 45 | /// 46 | /// Panes are shown top-bottom. 47 | /// 48 | Tall = 2, 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/UniversalWPF.SplitView/GridLengthAnimation.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.Media.Animation; 8 | 9 | namespace UniversalWPF 10 | { 11 | public class GridLengthAnimation : AnimationTimeline 12 | { 13 | public override object GetCurrentValue(object defaultOriginValue, 14 | object defaultDestinationValue, AnimationClock animationClock) 15 | { 16 | var from = ((GridLength)GetValue(GridLengthAnimation.FromProperty)); 17 | var to = ((GridLength)GetValue(GridLengthAnimation.ToProperty)); 18 | if (from.GridUnitType != to.GridUnitType) //We can't animate different types, so just skip straight to it 19 | return to; 20 | double fromVal = from.Value; 21 | double toVal = to.Value; 22 | 23 | if (fromVal > toVal) 24 | { 25 | return new GridLength((1 - animationClock.CurrentProgress.Value) * 26 | (fromVal - toVal) + toVal, GridUnitType.Star); 27 | } 28 | else 29 | { 30 | return new GridLength(animationClock.CurrentProgress.Value * 31 | (toVal - fromVal) + fromVal, GridUnitType.Star); 32 | } 33 | } 34 | 35 | public override Type TargetPropertyType 36 | { 37 | get 38 | { 39 | return typeof(GridLength); 40 | } 41 | } 42 | 43 | protected override System.Windows.Freezable CreateInstanceCore() 44 | { 45 | return new GridLengthAnimation(); 46 | } 47 | 48 | public static readonly DependencyProperty FromProperty = DependencyProperty.Register("From", typeof(GridLength), typeof(GridLengthAnimation)); 49 | public GridLength From 50 | { 51 | get 52 | { 53 | return (GridLength)GetValue(GridLengthAnimation.FromProperty); 54 | } 55 | set 56 | { 57 | SetValue(GridLengthAnimation.FromProperty, value); 58 | } 59 | } 60 | public static readonly DependencyProperty ToProperty = DependencyProperty.Register("To", typeof(GridLength), typeof(GridLengthAnimation)); 61 | public GridLength To 62 | { 63 | get 64 | { 65 | return (GridLength)GetValue(GridLengthAnimation.ToProperty); 66 | } 67 | set 68 | { 69 | SetValue(GridLengthAnimation.ToProperty, value); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/UniversalWPF/TwoPaneView/TwoPaneViewTallModeConfiguration.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Based on a port of TwoPaneView control in the WinUI Library: https://github.com/microsoft/microsoft-ui-xaml/ 3 | MIT License 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE 24 | */ 25 | 26 | namespace UniversalWPF 27 | { 28 | /// 29 | /// Defines constants that specify how panes are shown in a in tall mode. 30 | /// 31 | /// 32 | /// 33 | public enum TwoPaneViewTallModeConfiguration 34 | { 35 | /// 36 | /// Only the pane that has priority is shown, the other pane is hidden. 37 | /// 38 | SinglePane = 0, 39 | 40 | /// 41 | /// The pane that has priority is shown on top, the other pane is shown on the bottom. 42 | /// 43 | TopBottom = 1, 44 | 45 | /// 46 | /// The pane that has priority is shown on the bottom, the other pane is shown on top. 47 | /// 48 | BottomTop = 2, 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /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/UniversalWPF/TwoPaneView/TwoPaneViewWideModeConfiguration.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Based on a port of TwoPaneView control in the WinUI Library: https://github.com/microsoft/microsoft-ui-xaml/ 3 | MIT License 4 | 5 | Copyright (c) Microsoft Corporation. All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE 24 | */ 25 | 26 | namespace UniversalWPF 27 | { 28 | /// 29 | /// Defines constants that specify how panes are shown in a in wide mode. 30 | /// 31 | /// 32 | /// 33 | public enum TwoPaneViewWideModeConfiguration 34 | { 35 | /// 36 | /// Only the pane that has priority is shown, the other pane is hidden. 37 | /// 38 | SinglePane = 0, 39 | 40 | /// 41 | /// The pane that has priority is shown on the left, the other pane is shown on the right. 42 | /// 43 | LeftRight = 1, 44 | 45 | /// 46 | /// The pane that has priority is shown on the right, the other pane is shown on the left. 47 | /// 48 | RightLeft = 2, 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/UnitTests/TestPages/RelativePanel1.xaml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 16 | 20 | 25 | 26 | 30 | 31 | 34 | 35 | 39 | 40 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /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/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/UniversalWPF.SplitView/SplitViewTemplateSettings.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 | 8 | namespace UniversalWPF 9 | { 10 | /// 11 | /// Provides calculated values that can be referenced as TemplatedParent sources 12 | /// when defining templates for a SplitView. Not intended for general use. 13 | /// 14 | public sealed class SplitViewTemplateSettings : DependencyObject 15 | { 16 | internal SplitViewTemplateSettings() { 17 | CompactPaneGridLength = new GridLength(1, GridUnitType.Star); 18 | OpenPaneGridLength = new GridLength(1, GridUnitType.Star); 19 | } 20 | /// 21 | /// Gets the CompactPaneLength value as a GridLength. 22 | /// 23 | /// 24 | /// The CompactPaneLength value as a GridLength. 25 | /// 26 | public GridLength CompactPaneGridLength { get; internal set; } 27 | /// 28 | /// Gets the negative of the OpenPaneLength value. 29 | /// 30 | /// 31 | /// The negative of the OpenPaneLength value. 32 | /// 33 | public double NegativeOpenPaneLength { get; internal set; } 34 | /// 35 | /// Gets the negative of the value calculated by subtracting the CompactPaneLength 36 | /// value from the OpenPaneLength value. 37 | /// 38 | /// 39 | /// The negative of the OpenPaneLength value minus the CompactPaneLength value. 40 | /// 41 | public double NegativeOpenPaneLengthMinusCompactLength { get; internal set; } 42 | /// 43 | /// Gets the OpenPaneLength value as a GridLength. 44 | /// 45 | /// 46 | /// The OpenPaneLength value as a GridLength. 47 | /// 48 | public GridLength OpenPaneGridLength { get; internal set; } 49 | /// 50 | /// Gets the OpenPaneLength value. 51 | /// 52 | /// 53 | /// The OpenPaneLength value. 54 | /// 55 | public double OpenPaneLength { get; internal set; } 56 | /// 57 | /// Gets a value calculated by subtracting the CompactPaneLength value from the OpenPaneLength 58 | /// value. 59 | /// 60 | /// 61 | /// The value calculated by subtracting the CompactPaneLength value from the OpenPaneLength 62 | /// value. 63 | /// 64 | public double OpenPaneLengthMinusCompactLength { get; internal set; } 65 | } 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /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/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/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/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/UwpTestApp/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/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/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/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/UniversalWPF.StateTriggers/VisualStateManagerHook.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Collections.Specialized; 5 | using System.Linq; 6 | using System.Windows; 7 | 8 | namespace UniversalWPF 9 | { 10 | /// 11 | /// Hook a VisualStateManager to keep the UWP visual states updated 12 | /// 13 | internal class VisualStateManagerHook : IDisposable 14 | { 15 | private static readonly DependencyProperty VisualStateManagerHookProperty = DependencyProperty.RegisterAttached( 16 | "VisualStateManagerHookInternal", 17 | typeof(VisualStateManagerHook), 18 | typeof(VisualStateManagerHook)); 19 | 20 | private VisualStateManagerHook(FrameworkElement element) 21 | { 22 | this.Element = element; 23 | 24 | this.VisualStateGroups = (ObservableCollection)element.GetValue(VisualStateManager.VisualStateGroupsProperty); 25 | 26 | this.VisualStateGroups.CollectionChanged += this.CollectionChanged; 27 | 28 | this.ApplyElement(this.VisualStateGroups); 29 | } 30 | 31 | private FrameworkElement Element { get; set; } 32 | 33 | private ObservableCollection VisualStateGroups { get; set; } 34 | 35 | internal static void Set(FrameworkElement element) 36 | { 37 | var hook = new VisualStateManagerHook(element); 38 | 39 | element.SetValue(VisualStateManagerHookProperty, hook); 40 | } 41 | 42 | internal static void UnSet(FrameworkElement element) 43 | { 44 | var hook = element.GetValue(VisualStateManagerHookProperty) as VisualStateManagerHook; 45 | 46 | if (hook != null) 47 | { 48 | element.SetValue(VisualStateManagerHookProperty, null); 49 | hook.Dispose(); 50 | } 51 | } 52 | 53 | public void Dispose() 54 | { 55 | this.RemoveElement(this.VisualStateGroups); 56 | 57 | this.VisualStateGroups.CollectionChanged -= this.CollectionChanged; 58 | 59 | // Probably useless, but still an extra precaution to avoid memory leaks 60 | this.Element = null; 61 | this.VisualStateGroups = null; 62 | } 63 | 64 | private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) 65 | { 66 | if (e.NewItems != null) 67 | { 68 | this.ApplyElement(e.NewItems.OfType()); 69 | } 70 | 71 | if (e.OldItems != null) 72 | { 73 | this.RemoveElement(e.OldItems.OfType()); 74 | } 75 | } 76 | 77 | private void ApplyElement(IEnumerable visualStateGroups) 78 | { 79 | foreach (var group in visualStateGroups) 80 | { 81 | foreach (var state in group.States.OfType()) 82 | { 83 | state.Element = this.Element; 84 | } 85 | } 86 | } 87 | 88 | private void RemoveElement(IEnumerable visualStateGroups) 89 | { 90 | foreach (var group in visualStateGroups) 91 | { 92 | foreach (var state in group.States.OfType()) 93 | { 94 | state.Element = null; 95 | } 96 | } 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /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 tcs; 24 | if (!visual.IsLoaded) 25 | { 26 | tcs = new TaskCompletionSource(); 27 | visual.Loaded += (s, e) => tcs.TrySetResult(null); 28 | await tcs.Task; 29 | } 30 | 31 | RenderTargetBitmap rtb = new RenderTargetBitmap((int)(visual.ActualWidth * scaleFactor ), 32 | (int)(visual.ActualHeight * scaleFactor), 33 | 96 * scaleFactor, 34 | 96 * scaleFactor, 35 | PixelFormats.Pbgra32); 36 | DrawingVisual dv = new DrawingVisual(); 37 | using (DrawingContext ctx = dv.RenderOpen()) 38 | { 39 | VisualBrush vb = new VisualBrush(visual); 40 | ctx.DrawRectangle(vb, null, new Rect(0, 0, visual.ActualWidth, visual.ActualHeight)); 41 | } 42 | rtb.Render(dv); 43 | 44 | var encoder = new PngBitmapEncoder(); 45 | encoder.Frames.Add(BitmapFrame.Create(rtb)); 46 | 47 | // For debugging purposes: 48 | // using (var file = System.IO.File.OpenWrite("e:\\temp\\test.png")) 49 | // { 50 | // encoder.Save(file); 51 | // } 52 | return rtb; 53 | } 54 | 55 | private static async Task RunUITest_Impl(Func action, [System.Runtime.CompilerServices.CallerFilePath] string testFilePath = null, [System.Runtime.CompilerServices.CallerMemberName] string testName = null) 56 | { 57 | TaskCompletionSource tcs = new TaskCompletionSource(); 58 | var w = ApplicationInitializer.window; 59 | await w.Dispatcher.Invoke(async () => 60 | { 61 | var container = w.Content as ContentControl; 62 | container.Content = new ContentControl(); 63 | w.Title = testFilePath + " :: " + testName + "()"; 64 | DisplayInfo info = new DisplayInfo() 65 | { 66 | Width = container.ActualWidth, 67 | Height = container.ActualHeight 68 | }; 69 | var visual = PresentationSource.FromVisual(container); 70 | if (visual != null) 71 | info.ScaleFactor = visual.CompositionTarget.TransformToDevice.M11; 72 | 73 | try 74 | { 75 | await action(container.Content as ContentControl, info); 76 | } 77 | finally 78 | { 79 | container.Content = null; 80 | } 81 | }); 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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 |