%3CLINGO-SUB%20id%3D%22lingo-sub-1451944%22%20slang%3D%22en-US%22%3EModernization%20Story%3A%20Windows%20Forms%20to%20.NET%20Core%2C%20XAML%20Islands%20and%20MSIX%20Core%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1451944%22%20slang%3D%22en-US%22%3E%3CP%3E%3C%2FP%3E%3CDIV%20class%3D%22video-embed-center%20video-embed%22%3E%3CIFRAME%20class%3D%22embedly-embed%22%20src%3D%22https%3A%2F%2Fcdn.embedly.com%2Fwidgets%2Fmedia.html%3Fsrc%3Dhttps%253A%252F%252Fwww.youtube.com%252Fembed%252FFvzYTI3Adh0%253Ffeature%253Doembed%26amp%3Bdisplay_name%3DYouTube%26amp%3Burl%3Dhttps%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DFvzYTI3Adh0%26amp%3Bimage%3Dhttps%253A%252F%252Fi.ytimg.com%252Fvi%252FFvzYTI3Adh0%252Fhqdefault.jpg%26amp%3Bkey%3Db0d40caa4f094c68be7c29880b16f56e%26amp%3Btype%3Dtext%252Fhtml%26amp%3Bschema%3Dyoutube%22%20width%3D%22400%22%20height%3D%22225%22%20scrolling%3D%22no%22%20title%3D%22YouTube%20embed%22%20frameborder%3D%220%22%20allow%3D%22autoplay%3B%20fullscreen%22%20allowfullscreen%3D%22true%22%3E%3C%2FIFRAME%3E%3C%2FDIV%3E%3CP%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20customer%20scenario%2C%20the%20customer%20has%20a%20Windows%20Forms%20application%20built%20on%20.NET%20Framework.%20They%20are%20interested%20in%20%E2%80%9Cmodernizing%E2%80%9D%20the%20user%20interface%20to%20support%20touch%20and%20ink%20in%20addition%20to%20support%20for%20high%20DPI%20monitors.%20In%20addition%20they%20are%20interested%20in%20leveraging%20MSIX%20for%20deployment.%20A%20few%20twists%3A%20their%20current%20implementation%20dynamically%20creates%20and%20adds%20controls%20to%20their%20form%20at%20runtime.%20The%20%E2%80%9Cdefinition%E2%80%9D%20of%20their%20form%20is%20serialized%20to%20xml%20%E2%80%93%20as%20their%20line%20of%20business%20application%20is%20very%20dynamic%20with%20many%20different%20%E2%80%9Cforms%E2%80%9D%20generated%20at%20runtime.%20This%20proof%20of%20concept%20should%20also%20do%20the%20same.%20Another%20complexity%20%E2%80%93%20they%20have%20not%20migrated%20all%20of%20their%20users%20to%20Windows%2010%20yet%2C%20many%20are%20still%20on%20Windows%207.%20The%20interim%20solution%20should%20be%20a%20stepping%20stone%20towards%20modernization%20demonstrating%20a%20single%20package%20that%20will%20work%20on%20both%20Windows%207%20and%20Windows%2010%20and%20if%20the%20modern%20controls%20are%20not%20available%20%E2%80%93%20fall%20back%20to%20the%20standard%20.NET%20Framework%20implementation.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3ELet%E2%80%99s%20break%20this%20Proof%20of%20concept%20into%204%20parts%2C%20as%20shown%20in%20the%20video%3A%3C%2FEM%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EStep%201%20-%20Recreate%20the%20current%20Windows%20Forms%20application%20(simplified)%3C%2FLI%3E%0A%3CLI%3EStep%202%20-%20Migrate%20it%20to%20Core%20%26amp%3B%20enable%20high-DPI.%3C%2FLI%3E%0A%3CLI%3EStep%203%20-%20Add%20Xaml%20Islands%20%26amp%3B%20dynamic%20controls%3C%2FLI%3E%0A%3CLI%3EStep%204%20-%20Add%20MSIX%20packaging%20(and%20MSIX%20Core)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3EStep%202%20-%20Migrate%20it%20to%20Core%20%26amp%3B%20enable%20high-DPI.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EI%E2%80%99m%20going%20to%20skip%20Step%201%20because%20it%20is%20just%20regular%20Windows%20Forms%2C%20.NET%20Framework%204.7.2%2C%20standard%20stuff.%20Step%202%20is%20where%20things%20start%20to%20get%20interesting.%26nbsp%3B%20In%20September%20of%202019%20Microsoft%20released%20.NET%20Core%20support%20for%20building%20Windows%20desktop%20applications%20which%20includes%20WPF%20and%20Windows%20Forms.%20.NET%20Core%20is%20the%20future%20of%20.NET.%20All%20the%20major%20improvements%20will%20be%20made%20in%20.NET%20Core%20(not%20.NET%20Framework).%20Migrating%20to%20Core%20brings%20improved%20runtime%20performance%2C%20single%20.exe%20files%2C%20smaller%20app%20size%2C%20self-contained%20deployment%20and%20side-by-side%20deployment.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3EIf%20this%20had%20been%20a%20more%20complex%20project%2C%20perhaps%20with%20Nuget%20packages%2C%20we%20would%20have%20used%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fdotnet%2Ftry-convert%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Etry-convert%3C%2FA%3E%20tool%20route.%26nbsp%3B%20Instead%2C%20I%20directly%20edited%20my%20project%20file%20by%20right-clicking%20the%20project%20in%20Visual%20Studio%202019%20Preview%2C%20and%20selecting%20%22Edit%20Project%20File%22.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22editp.gif%22%20style%3D%22width%3A%20444px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197693i11AFB6574CA3482D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22editp.gif%22%20alt%3D%22editp.gif%22%20%2F%3E%3C%2FSPAN%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E.NET%20Core%20has%20a%20vastly%20simplified%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fdotnet%2Fproject-system%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eproject%20system%3C%2FA%3E%20and%20project%20file.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-html%22%3E%3CCODE%3E%3CPROJECT%20sdk%3D%22Microsoft.NET.Sdk.WindowsDesktop%22%3E%0A%20%3CPROPERTYGROUP%3E%0A%20%20%3COUTPUTTYPE%3EWinExe%3C%2FOUTPUTTYPE%3E%0A%20%20%3CTARGETFRAMEWORK%3Enetcoreapp3.1%3C%2FTARGETFRAMEWORK%3E%0A%20%20%3CUSEWINDOWSFORMS%3Etrue%3C%2FUSEWINDOWSFORMS%3E%0A%20%20%3CAPPLICATIONMANIFEST%3Eapp.manifest%3C%2FAPPLICATIONMANIFEST%3E%0A%20%20%3CNULLABLE%3Eannotations%3C%2FNULLABLE%3E%0A%20%20%3CPLATFORMS%3EAnyCPU%3Bx64%3C%2FPLATFORMS%3E%0A%20%3C%2FPROPERTYGROUP%3E%0A%0A%20%20%3CPROPERTYGROUP%20condition%3D%22'%24(Configuration)%7C%24(Platform)'%3D%3D'Debug%7CAnyCPU'%22%3E%0A%20%20%3CPLATFORMTARGET%3Ex64%3C%2FPLATFORMTARGET%3E%0A%20%3C%2FPROPERTYGROUP%3E%0A%0A%20%20%3CPROPERTYGROUP%20condition%3D%22'%24(Configuration)%7C%24(Platform)'%3D%3D'Debug%7Cx64'%22%3E%0A%20%20%20%20%3CPLATFORMTARGET%3Ex64%3C%2FPLATFORMTARGET%3E%0A%20%20%3C%2FPROPERTYGROUP%3E%0A%0A%20%3CITEMGROUP%3E%0A%20%20%20%3CPACKAGEREFERENCE%20include%3D%22Microsoft.Toolkit.Forms.UI.Controls%22%20version%3D%226.1.0-preview1%22%3E%3C%2FPACKAGEREFERENCE%3E%0A%20%20%20%3CPACKAGEREFERENCE%20include%3D%22Microsoft.Toolkit.Forms.UI.Controls.WebView%22%20version%3D%226.1.0-preview1%22%3E%3C%2FPACKAGEREFERENCE%3E%0A%20%20%20%3CPACKAGEREFERENCE%20include%3D%22Microsoft.Toolkit.Forms.UI.XamlHost%22%20version%3D%226.1.0-preview1%22%3E%3C%2FPACKAGEREFERENCE%3E%0A%20%3C%2FITEMGROUP%3E%0A%20%20%3CTARGET%20name%3D%22CheckIfShouldKillVBCSCompiler%22%3E%3C%2FTARGET%3E%0A%3C%2FPROJECT%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20might%20wonder%20about%20the%20target%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fdotnet%2Froslyn%2Fissues%2F21627%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECheckIfShouldKillVBCSCompiler%3C%2FA%3E%2C%20I%20ran%20into%20a%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Faspnet%2FRoslynCodeDomProvider%2Fissues%2F57%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eproblem%3C%2FA%3E%20compiling%20with%20.NET%20Core%20compiling%20with%20the%20XamlHost%2C%20that%20target%20fixed%20it.%3C%2FP%3E%0A%3CP%3EI%20also%20added%20an%20app.manifest%20file%20with%20DPI%20settings.%20The%20combination%20of%20below%20two%20tags%20have%20the%20following%20effect%20%3A%201)%20Per-Monitor%20for%20%26gt%3B%3D%20Windows%2010%20Anniversary%20Update%2C%26nbsp%3B2)%20System%20%26lt%3B%20Windows%2010%20Anniversary%20Update.%20This%20indicates%20that%20the%20application%20is%20DPI-aware%20and%20will%20not%20be%20automatically%20scaled%20by%20Windows%20at%20higher%20DPIs%2C%20thus%20preventing%20the%20rasterization.%20Windows%20Presentation%20Foundation%20(WPF)%20applications%20are%20automatically%20DPI-aware%20and%20do%20not%20need%20to%20opt%20in%20but%20Windows%20Forms%20applications%20targeting%20.NET%20Framework%204.6%20that%20opt%20into%20this%20setting%2C%20should%20also%20set%20the%20'%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fframework%2Fconfigure-apps%2Ffile-schema%2Fwinforms%2Fwindows-forms-add-configuration-element%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EEnableWindowsFormsHighDpiAutoResizing%3C%2FA%3E'%20setting%20to%20'true'%20in%20their%20app.config.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-html%22%3E%3CCODE%3E%20%3CAPPLICATION%20xmlns%3D%22urn%3Aschemas-microsoft-com%3Aasm.v3%22%3E%0A%20%20%3CWINDOWSSETTINGS%3E%0A%20%20%20%3CDPIAWARE%20xmlns%3D%22http%3A%2F%2Fschemas.microsoft.com%2FSMI%2F2005%2FWindowsSettings%22%3Etrue%2FPM%3C%2FDPIAWARE%3E%0A%20%20%20%3CDPIAWARENESS%20xmlns%3D%22http%3A%2F%2Fschemas.microsoft.com%2FSMI%2F2016%2FWindowsSettings%22%3EPerMonitorV2%2C%20PerMonitor%3C%2FDPIAWARENESS%3E%0A%20%20%3C%2FWINDOWSSETTINGS%3E%0A%20%3C%2FAPPLICATION%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20addition%2C%20in%20our%20Program%20Main()%20I%20added%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3EApplication.SetHighDpiMode(HighDpiMode.SystemAware)%3B%20%2F%2F--%20setting%20DPI%20aware%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20finally%2C%20our%20application%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fdotnet%2Fdocs%2Fissues%2F6234%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Econfiguration%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-html%22%3E%3CCODE%3E%0A%3CCONFIGURATION%3E%0A%20%20%20%20%3CSTARTUP%3E%20%0A%20%20%20%20%20%20%20%20%3CSUPPORTEDRUNTIME%20version%3D%22v4.0%22%20sku%3D%22.NETFramework%2CVersion%3Dv4.7.2%22%3E%3C%2FSUPPORTEDRUNTIME%3E%0A%20%20%20%20%3C%2FSTARTUP%3E%0A%20%3CSYSTEM.WINDOWS.FORMS.APPLICATIONCONFIGURATIONSECTION%3E%0A%20%20%3CADD%20key%3D%22DpiAwareness%22%20value%3D%22PerMonitorV2%22%3E%3C%2FADD%3E%0A%20%3C%2FSYSTEM.WINDOWS.FORMS.APPLICATIONCONFIGURATIONSECTION%3E%0A%20%3CSYSTEM.CODEDOM%3E%0A%20%20%3CCOMPILERS%3E%0A%20%20%20%3CCOMPILER%20language%3D%22c%23%3Bcs%3Bcsharp%22%20extension%3D%22.cs%22%20type%3D%22Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider%2C%20Microsoft.CodeDom.Providers.DotNetCompilerPlatform%2C%20Version%3D2.0.0.0%2C%20Culture%3Dneutral%2C%20internalKeyToken%3D31bf3856ad364e35%22%20warninglevel%3D%224%22%20compileroptions%3D%22%2Flangversion%3Adefault%20%2Fnowarn%3A1659%3B1699%3B1701%22%3E%3C%2FCOMPILER%3E%0A%20%20%20%3CCOMPILER%20language%3D%22vb%3Bvbs%3Bvisualbasic%3Bvbscript%22%20extension%3D%22.vb%22%20type%3D%22Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider%2C%20Microsoft.CodeDom.Providers.DotNetCompilerPlatform%2C%20Version%3D2.0.0.0%2C%20Culture%3Dneutral%2C%20internalKeyToken%3D31bf3856ad364e35%22%20warninglevel%3D%224%22%20compileroptions%3D%22%2Flangversion%3Adefault%20%2Fnowarn%3A41008%20%2Fdefine%3A_MYTYPE%3D%5C%26amp%3Bquot%3BWeb%5C%26amp%3Bquot%3B%20%2FoptionInfer%2B%22%3E%3C%2FCOMPILER%3E%0A%20%20%3C%2FCOMPILERS%3E%0A%20%3C%2FSYSTEM.CODEDOM%3E%0A%3C%2FCONFIGURATION%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20were%20a%20few%20other%20minor%20adjustments%20shown%20in%20the%20video.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3EStep%203%20-%20Add%20Xaml%20Islands%20%26amp%3B%20dynamic%20controls%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EFor%20this%20step%20we%20introduce%20%3CA%20href%3D%22https%3A%2F%2Fblogs.windows.com%2Fwindowsdeveloper%2F2018%2F11%2F02%2Fxaml-islands-a-deep-dive-part-1%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EXAML%20Islands%3C%2FA%3E.%20Most%20of%20the%20cool%20new%20touch-enabled%20features%20for%20Windows%2010%20have%20been%20supported%20for%20UWP%20(Universal%20Windows%20Platform)%20apps%20only.%20Not%20anymore.%20With%20XAML%20Islands%20we%20can%20now%20call%20UWP%20UI%20APIs%20from%20the%20.NET%20framework.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20are%20three%20nuget%20packages%20we%20will%20leverage%20that%20make%20it%20even%20easier%20to%20implement%20XAML%20Islands%20in%20our%20Windows%20Forms%20application.%3C%2FP%3E%0A%3CP%3EFirst%20is%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.nuget.org%2Fpackages%2FMicrosoft.Toolkit.Forms.UI.Controls%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMicrosoft.Toolkit.Forms.UI.Controls%3C%2FA%3E.%20This%20package%20is%20just%20chock%20full%20of%20wonderful%20awesomesauce.%20With%20it%20we%20get%20five%20pre-wrapped%20controls%20-%20with%20properties%20and%20event%20handlers%20expose.%20We%20will%20make%20use%20of%20four%20out%20of%20the%20five%20in%20our%20demo.%26nbsp%3BIt%20gives%20us%20the%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fuwp%2Fapi%2Fwindows.ui.xaml.controls.inkcanvas%3Fview%3Dwinrt-19041%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EInkCanvas%3C%2FA%3E%20which%20receives%20and%20displays%20ink%20strokes%2C%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fuwp%2Fapi%2Fwindows.ui.xaml.controls.inktoolbar%3Fview%3Dwinrt-19041%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EInkToolbar%3C%2FA%3E%20which%20shows%20a%20collection%20of%20buttons%20that%20activate%20ink-related%20features.%20The%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fuwp%2Fapi%2Fwindows.ui.xaml.controls.maps.mapcontrol%3Fview%3Dwinrt-19041%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMapControl%3C%2FA%3E%20which%20is%20for%20rendering%20digital%20maps%20from%20different%20providers%20(like%20OpenStreetMap%20and%20Bing%20Maps)%20and%20various%20types%20of%20map%20overlays.%20Also%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fuwp%2Fapi%2Fwindows.ui.xaml.controls.mediaplayerelement%3Fview%3Dwinrt-19041%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMediaPlayerElement%3C%2FA%3E%20which%20embeds%20a%20view%20that%20streams%20and%20renders%20media%20content%20such%20as%20video.%20Finally%2C%20although%20we%20are%20not%20using%20it%20in%20our%20demo%2C%20this%20library%20also%20includes%20the%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fuwp%2Fapi%2Fwindows.ui.xaml.controls.swapchainpanel%3Fview%3Dwinrt-19041%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESwapChainPanel%3C%2FA%3E%26nbsp%3Bwhich%20provides%20a%20hosting%20surface%20for%20DirectX%20swap%20chains%20to%20provide%20content%20that%20can%20be%20rendered%20into%20a%20XAML%20UI%20-%20that%20opens%20the%20doors%20for%20some%20super%20exciting%20advanced%20animation%20capabilities.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20are%20also%20leveraging%20the%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.nuget.org%2Fpackages%2FMicrosoft.Toolkit.Forms.UI.Controls.WebView%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMicrosoft.Toolkit.Forms.UI.Controls.WebView%3C%2FA%3E%26nbsp%3Bpackage%2C%20which%20provides%20a%20WebView%20XAML%20control%20for%20for%20web%20content%20that%20unlike%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fframework%2Fwinforms%2Fcontrols%2Fwebbrowser-control-windows-forms%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EWebBrowser%3C%2FA%3E%20control%20in%20Windows%20Forms%20this%20one%20renders%20richly%20formatted%20HTML5%20content%2C%20dynamically%20generated%20code%2C%20or%20even%20content%20files.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELastly%20we%20leverage%20the%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.nuget.org%2Fpackages%2FMicrosoft.Toolkit.Forms.UI.XamlHost%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMicrosoft.Toolkit.Forms.UI.XamlHost%3C%2FA%3E%26nbsp%3Blibrary%20which%20provides%20interop%20helpers%20for%20to%20easily%20leverage%20the%20built-in%20UWP%20controls%20such%20as%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fuwp%2Fapi%2Fwindows.ui.xaml.controls.textbox%3Fview%3Dwinrt-19041%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ETextBox%3C%2FA%3E%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fuwp%2Fapi%2Fwindows.ui.xaml.controls.combobox%3Fview%3Dwinrt-19041%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EComboBox%3C%2FA%3E%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fuwp%2Fdesign%2Fcontrols-and-patterns%2Fbuttons%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EButton%3C%2FA%3E%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fuwp%2Fdesign%2Fcontrols-and-patterns%2Fcalendar-view%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECalendar%3C%2FA%3E.%20All%20of%20the%20UWP%20controls%20that%20are%20touch%20friendly%20out-of-the-box.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThen%20we%20implemented%20a%20simple%20factory%20pattern%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3E%20%20%20%20%20%20%20%20%20%20%20%20ControlFactory%20factory%20%3D%20(isXaml)%20%3F%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20(ControlFactory)(new%20ControlFactoryXaml())%20%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20(ControlFactory)(new%20ControlFactoryNet())%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3EStep%204%20-%20Add%20MSIX%20packaging%20(and%20MSIX%20Core)%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EFinally%20in%20step%20four%20we%20added%20MSIX%20packaging%20and%20then%20MSIX%20Core%20support.%3C%2FP%3E%0A%3CP%3EFirst%20I%20added%20what%20we%20refer%20to%20as%20a%20%22WAP%22%20(pronounced%20%3CEM%3Ewhap%3C%2FEM%3E)%20project%2C%20or%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmsix%2Fdesktop%2Fdesktop-to-uwp-packaging-dot-net%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EWindows%20Application%20Packaging%3C%2FA%3E%20project.%20Then%20set%20that%20as%20your%20start%20project%2C%20and%20add%20an%20application%20reference%20to%20our%20Windows%20Forms%20project%2C%20like%20this%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22WAP.gif%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F197719iAC0523EA09B4C370%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22WAP.gif%22%20alt%3D%22WAP.gif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20finally%2C%20in%20order%20to%20support%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmsix%2Fmsix-core%2Fmsixcore%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMSIX%20Core%3C%2FA%3E%20(so%20we%20can%20install%20this%20on%20Windows%207%20SP1)%2C%20we%20added%20that%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fuwp%2Fschemas%2Fappxpackage%2Fuapmanifestschema%2Felement-targetdevicefamily%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ETargetDeviceFamily%3C%2FA%3E%20to%20our%20Dependencies%20node%20in%20our%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fuwp%2Fschemas%2Fappxpackage%2Fuapmanifestschema%2Fgenerate-package-manifest%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPackage.appxmanifest%3C%2FA%3E%20like%20this.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-html%22%3E%3CCODE%3E%20%20%20%3CTARGETDEVICEFAMILY%20name%3D%22MSIXCore.Desktop%22%20minversion%3D%226.1.7601.0%22%20maxversiontested%3D%2210.0.10240.0%22%3E%3C%2FTARGETDEVICEFAMILY%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFind%20the%20full%20sample%20code%20here%3A%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3E%3CA%20href%3D%22http%3A%2F%2Faka.ms%2Fmodernizationstory%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Faka.ms%2Fmodernizationstory%3C%2FA%3E%26nbsp%3B%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3EEnjoy!%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1451944%22%20slang%3D%22en-US%22%3E%3CP%3EModernizing%20a%20Windows%20Forms%20application%20via%20migration%20to%20.NET%20Core%2C%20Xaml%20Islands%20and%20MSIX%20Core.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1463149%22%20slang%3D%22en-US%22%3ERe%3A%20Modernization%20Story%3A%20Windows%20Forms%20to%20.NET%20Core%2C%20XAML%20Islands%20and%20MSIX%20Core%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1463149%22%20slang%3D%22en-US%22%3E%3CP%3EA%20very%20nice%20post!%20and%20very%20timely.%20We%20started%20porting%20our%20current%20.NET%20Framework%20application%20to%20.NET%20Core.%20It%20will%20take%20quite%20a%20long%20time%20as%20we%20used%20remoting%2C%20App%20Domains%2C%20dynamic%20compilation%20and%20many%20more%20things.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOne%20of%20our%20biggest%20problems%20at%20the%20moment%20is%20that%20we%20used%20ClickOnce%20to%20deploy%20our%20client%20software.%20We%20generated%20the%20manifest%20files%20for%20the%20deployments%20dynamically%20so%20that%20we%20could%20add%20configuration%20files%20that%20administrators%20can%20modify%20centrally%20at%20the%20server%20(for%20example%20with%20the%20url%20to%20the%20server%20itself%20).%20Could%20this%20be%20done%20with%20MSIX%3F%20As%20I%20understand%20it%2C%20the%20MSIX%20packages%20are%20signed%20and%20cannot%20be%20modified%20later%20(post%20deployment%20at%20our%20customer's%20locations).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOr%20is%20there%20a%20way%20of%20using%20a%20MSIX%20package%20with%20the%20software%20itself%20and%20define%20a%20%22satellite%20package%22%20with%20files%20generated%20dynamically%20with%20configuration%20information%20(or%20other%20things).%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1463264%22%20slang%3D%22en-US%22%3ERe%3A%20Modernization%20Story%3A%20Windows%20Forms%20to%20.NET%20Core%2C%20XAML%20Islands%20and%20MSIX%20Core%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1463264%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'm%20glad%20to%20hear%20you%20have%20begun%20your%20own%20modernization%20journey!%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20Windows%2010%2C%20version%201809%2C%20we%20introduced%20a%20new%20type%20of%20MSIX%20package%20called%20a%20modification%20package.%20Modification%20packages%20are%20MSIX%20packages%20that%20store%20customizations%20-%20such%20as%20registry%20changes%20or%20configurations.%20That%20is%20probably%20the%20way%20to%20go%20for%20what%20you%20are%20describing.%20You%20can%20create%20a%20modification%20package%20by%20using%20the%20latest%20version%20of%20the%20MSIX%20packaging%20tool%20(for%20Windows%2010%20version%201809%20or%20later).%20However%2C%20those%20those%20are%20distributed%20-%20not%20dynamically%20generated%20as%20you%20are%20describing%20also.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20MSIX%20there%20is%20no%20restriction%20preventing%20you%20from%20separately%20dynamically%20generating%20files%20-%20so%20long%20as%20you%20are%20not%20saving%20them%20to%20your%20install%20directory%20nor%20a%20system%20protected%20folder.%20So%20if%20you%20want%20to%20download%20and%2For%20dynamically%20generate%20some%20configuration%20file%20on%20first%20run%20that%20is%20an%20option%20also%2C%20if%20you%20wanted%20to%20perform%20that%20operation%20outside%20of%20your%20application%20you%20might%20want%20to%20check%20out%20PSF%20with%20the%20new%20scripting%20capabilities%20-%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmsix%2Fpsf%2Frun-scripts-with-package-support-framework%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmsix%2Fpsf%2Frun-scripts-with-package-support-framework%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EModification%20packages%20%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmsix%2Fmodification-packages%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmsix%2Fmodification-packages%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1469837%22%20slang%3D%22en-US%22%3ERe%3A%20Modernization%20Story%3A%20Windows%20Forms%20to%20.NET%20Core%2C%20XAML%20Islands%20and%20MSIX%20Core%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1469837%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20very%20much%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F262555%22%20target%3D%22_blank%22%3E%40Robert_Evans%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20will%20take%20a%20look%20at%20the%20modification%20packages!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1494210%22%20slang%3D%22en-US%22%3ERe%3A%20Modernization%20Story%3A%20Windows%20Forms%20to%20.NET%20Core%2C%20XAML%20Islands%20and%20MSIX%20Core%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1494210%22%20slang%3D%22en-US%22%3E%3CP%3ERaul%2C%3C%2FP%3E%3CP%3EI%20understand%20ReportViewer%20won%E2%80%99t%20be%20ported%20to%20core.%20You%20seem%20to%20have%20a%20pretty%20complex%20app.%20Are%20you%20not%20using%20ReportViewer%3F%3C%2FP%3E%3CP%3EReportViewer%20is%20a%20show%20stopper%20to%20us.%20Do%20you%20guys%20know%20of%20a%20replacement%20for%20ReportViewer%3F%20PowerBI%20doesn%E2%80%99t%20seem%20to%20fit%20our%20needs%20of%20showing%20typical%20documents%2C%20sales%20orders%2C%20etc.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1495385%22%20slang%3D%22en-US%22%3ERe%3A%20Modernization%20Story%3A%20Windows%20Forms%20to%20.NET%20Core%2C%20XAML%20Islands%20and%20MSIX%20Core%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1495385%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Sterenas%2C%3C%2FP%3E%3CP%3Ewe%20don't%20use%20the%20ReportViewer.%20Our%20software%20is%20built%20on%20DevExpress%20components%20and%20we%20use%20their%20reports.%20They%20already%20migrated%20all%20the%20components%20to%20.NET%20Core.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

 

In this customer scenario, the customer has a Windows Forms application built on .NET Framework. They are interested in “modernizing” the user interface to support touch and ink in addition to support for high DPI monitors. In addition they are interested in leveraging MSIX for deployment. A few twists: their current implementation dynamically creates and adds controls to their form at runtime. The “definition” of their form is serialized to xml – as their line of business application is very dynamic with many different “forms” generated at runtime. This proof of concept should also do the same. Another complexity – they have not migrated all of their users to Windows 10 yet, many are still on Windows 7. The interim solution should be a stepping stone towards modernization demonstrating a single package that will work on both Windows 7 and Windows 10 and if the modern controls are not available – fall back to the standard .NET Framework implementation.

 

Let’s break this Proof of concept into 4 parts, as shown in the video:

  • Step 1 - Recreate the current Windows Forms application (simplified)
  • Step 2 - Migrate it to Core & enable high-DPI.
  • Step 3 - Add Xaml Islands & dynamic controls
  • Step 4 - Add MSIX packaging (and MSIX Core)

 

Step 2 - Migrate it to Core & enable high-DPI.

I’m going to skip Step 1 because it is just regular Windows Forms, .NET Framework 4.7.2, standard stuff. Step 2 is where things start to get interesting.  In September of 2019 Microsoft released .NET Core support for building Windows desktop applications which includes WPF and Windows Forms. .NET Core is the future of .NET. All the major improvements will be made in .NET Core (not .NET Framework). Migrating to Core brings improved runtime performance, single .exe files, smaller app size, self-contained deployment and side-by-side deployment. 


If this had been a more complex project, perhaps with Nuget packages, we would have used the try-convert tool route.  Instead, I directly edited my project file by right-clicking the project in Visual Studio 2019 Preview, and selecting "Edit Project File".

 

editp.gif 

 

.NET Core has a vastly simplified project system and project file. 

 

 

 

 

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
	<PropertyGroup>
		<OutputType>WinExe</OutputType>
		<TargetFramework>netcoreapp3.1</TargetFramework>
		<UseWindowsForms>true</UseWindowsForms>
		<ApplicationManifest>app.manifest</ApplicationManifest>
		<Nullable>annotations</Nullable>
		<Platforms>AnyCPU;x64</Platforms>
	</PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
		<PlatformTarget>x64</PlatformTarget>
	</PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>

	<ItemGroup>
	  <PackageReference Include="Microsoft.Toolkit.Forms.UI.Controls" Version="6.1.0-preview1" />
	  <PackageReference Include="Microsoft.Toolkit.Forms.UI.Controls.WebView" Version="6.1.0-preview1" />
	  <PackageReference Include="Microsoft.Toolkit.Forms.UI.XamlHost" Version="6.1.0-preview1" />
	</ItemGroup>
  <Target Name="CheckIfShouldKillVBCSCompiler" />
</Project>

 

 

 

 

You might wonder about the target CheckIfShouldKillVBCSCompiler, I ran into a problem compiling with .NET Core compiling with the XamlHost, that target fixed it.

I also added an app.manifest file with DPI settings. The combination of below two tags have the following effect : 1) Per-Monitor for >= Windows 10 Anniversary Update, 2) System < Windows 10 Anniversary Update. This indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher DPIs, thus preventing the rasterization. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need to opt in but Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config.

 

 

 

 

	<application xmlns="urn:schemas-microsoft-com:asm.v3">
		<windowsSettings>
			<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
			<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
		</windowsSettings>
	</application>

 

 

 

In addition, in our Program Main() I added:

 

 

 

Application.SetHighDpiMode(HighDpiMode.SystemAware); //-- setting DPI aware

 

 

 

And finally, our application configuration.

 

 

 

 

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
    </startup>
	<System.Windows.Forms.ApplicationConfigurationSection>
		<add key="DpiAwareness" value="PerMonitorV2"/>
	</System.Windows.Forms.ApplicationConfigurationSection>
	<system.codedom>
		<compilers>
			<compiler language="c#;cs;csharp" extension=".cs"
			  type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, internalKeyToken=31bf3856ad364e35"
			  warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
			<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
			  type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, internalKeyToken=31bf3856ad364e35"
			  warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
		</compilers>
	</system.codedom>
</configuration>

 

 

 

 

There were a few other minor adjustments shown in the video.

 

Step 3 - Add Xaml Islands & dynamic controls

For this step we introduce XAML Islands. Most of the cool new touch-enabled features for Windows 10 have been supported for UWP (Universal Windows Platform) apps only. Not anymore. With XAML Islands we can now call UWP UI APIs from the .NET framework. 

 

There are three nuget packages we will leverage that make it even easier to implement XAML Islands in our Windows Forms application.

First is Microsoft.Toolkit.Forms.UI.Controls. This package is just chock full of wonderful awesomesauce. With it we get five pre-wrapped controls - with properties and event handlers expose. We will make use of four out of the five in our demo. It gives us the InkCanvas which receives and displays ink strokes, the InkToolbar which shows a collection of buttons that activate ink-related features. The MapControl which is for rendering digital maps from different providers (like OpenStreetMap and Bing Maps) and various types of map overlays. Also the MediaPlayerElement which embeds a view that streams and renders media content such as video. Finally, although we are not using it in our demo, this library also includes the SwapChainPanel which provides a hosting surface for DirectX swap chains to provide content that can be rendered into a XAML UI - that opens the doors for some super exciting advanced animation capabilities.

 

We are also leveraging the Microsoft.Toolkit.Forms.UI.Controls.WebView package, which provides a WebView XAML control for for web content that unlike the WebBrowser control in Windows Forms this one renders richly formatted HTML5 content, dynamically generated code, or even content files.

 

Lastly we leverage the Microsoft.Toolkit.Forms.UI.XamlHost library which provides interop helpers for to easily leverage the built-in UWP controls such as TextBox, ComboBox, Button, Calendar. All of the UWP controls that are touch friendly out-of-the-box.  

 

Then we implemented a simple factory pattern:

 

 

            ControlFactory factory = (isXaml) ?
                (ControlFactory)(new ControlFactoryXaml()) :
                (ControlFactory)(new ControlFactoryNet());

 

 

 

Step 4 - Add MSIX packaging (and MSIX Core)

Finally in step four we added MSIX packaging and then MSIX Core support.

First I added what we refer to as a "WAP" (pronounced whap) project, or Windows Application Packaging project. Then set that as your start project, and add an application reference to our Windows Forms project, like this:

WAP.gif

 

 

And finally, in order to support MSIX Core (so we can install this on Windows 7 SP1), we added that TargetDeviceFamily to our Dependencies node in our Package.appxmanifest like this.

 

 

	  <TargetDeviceFamily Name="MSIXCore.Desktop" MinVersion="6.1.7601.0" MaxVersionTested="10.0.10240.0" />

 

 

Find the full sample code here:

http://aka.ms/modernizationstory 

 

Enjoy!

 

 

5 Comments
Regular Visitor

A very nice post! and very timely. We started porting our current .NET Framework application to .NET Core. It will take quite a long time as we used remoting, App Domains, dynamic compilation and many more things.

 

One of our biggest problems at the moment is that we used ClickOnce to deploy our client software. We generated the manifest files for the deployments dynamically so that we could add configuration files that administrators can modify centrally at the server (for example with the url to the server itself ). Could this be done with MSIX? As I understand it, the MSIX packages are signed and cannot be modified later (post deployment at our customer's locations).

 

Or is there a way of using a MSIX package with the software itself and define a "satellite package" with files generated dynamically with configuration information (or other things).

Microsoft

Hello,

 

I'm glad to hear you have begun your own modernization journey! 

 

In Windows 10, version 1809, we introduced a new type of MSIX package called a modification package. Modification packages are MSIX packages that store customizations - such as registry changes or configurations. That is probably the way to go for what you are describing. You can create a modification package by using the latest version of the MSIX packaging tool (for Windows 10 version 1809 or later). However, those those are distributed - not dynamically generated as you are describing also.

 

With MSIX there is no restriction preventing you from separately dynamically generating files - so long as you are not saving them to your install directory nor a system protected folder. So if you want to download and/or dynamically generate some configuration file on first run that is an option also, if you wanted to perform that operation outside of your application you might want to check out PSF with the new scripting capabilities - https://docs.microsoft.com/en-us/windows/msix/psf/run-scripts-with-package-support-framework

Modification packages : https://docs.microsoft.com/en-us/windows/msix/modification-packages

 

 

Regular Visitor

Thank you very much @Robert_Evans 

I will take a look at the modification packages!

Occasional Visitor

Raul,

I understand ReportViewer won’t be ported to core. You seem to have a pretty complex app. Are you not using ReportViewer?

ReportViewer is a show stopper to us. Do you guys know of a replacement for ReportViewer? PowerBI doesn’t seem to fit our needs of showing typical documents, sales orders, etc.

Regular Visitor

Hello Sterenas,

we don't use the ReportViewer. Our software is built on DevExpress components and we use their reports. They already migrated all the components to .NET Core.