├── .csharpierrc.json
├── .editorconfig
├── .gitattributes
├── .gitignore
├── AngelSix
├── AngelSix.csproj
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── Converters
│ └── ApplicationPageViewConverter.cs
├── Home.xaml
├── Home.xaml.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── NavigationService.cs
├── ViewModels
│ ├── HomeViewModel.cs
│ ├── LoginViewModel.cs
│ ├── MainViewModel.cs
│ └── ViewModelBase.cs
└── Views
│ ├── ApplicationPage.cs
│ ├── BasePage.cs
│ ├── Login.xaml
│ └── Login.xaml.cs
├── Kevin
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── Kevin.csproj
├── MainViewModel.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── ViewModelBase.cs
├── ViewModels.cs
└── Views
│ ├── Page1.xaml
│ ├── Page1.xaml.cs
│ ├── Page2.xaml
│ ├── Page2.xaml.cs
│ ├── Page3.xaml
│ └── Page3.xaml.cs
├── README.md
├── Sergio
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── NavigationService.cs
├── Sergio.csproj
├── ViewModels
│ ├── HomeViewModel.cs
│ ├── LoginViewModel.cs
│ ├── MainWindowViewModel.cs
│ └── ViewModelBase.cs
└── Views
│ ├── Home.xaml
│ ├── Home.xaml.cs
│ ├── Login.xaml
│ └── Login.xaml.cs
├── SingletonSean
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── NavigationService.cs
├── SingletonSean.csproj
├── UserService.cs
├── ViewModels
│ ├── HomeViewModel.cs
│ ├── LoginViewModel.cs
│ ├── MainViewModel.cs
│ └── ViewModelBase.cs
└── Views
│ ├── Home.xaml
│ ├── Home.xaml.cs
│ ├── Login.xaml
│ ├── Login.xaml.cs
│ ├── MainWindow.xaml
│ └── MainWindow.xaml.cs
├── WpfNavigationDemo.sln
└── mindmap.pdf
/.csharpierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 120,
3 | "useTabs": false,
4 | "tabWidth": 4,
5 | "preprocessorSymbolSets": ["", "DEBUG", "DEBUG,CODE_STYLE"]
6 | }
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BYJRK/WpfNavigationDemo/5a6a3f63d8327e5d36e3f4196ded05af90f2a751/.editorconfig
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # Tye
66 | .tye/
67 |
68 | # ASP.NET Scaffolding
69 | ScaffoldingReadMe.txt
70 |
71 | # StyleCop
72 | StyleCopReport.xml
73 |
74 | # Files built by Visual Studio
75 | *_i.c
76 | *_p.c
77 | *_h.h
78 | *.ilk
79 | *.meta
80 | *.obj
81 | *.iobj
82 | *.pch
83 | *.pdb
84 | *.ipdb
85 | *.pgc
86 | *.pgd
87 | *.rsp
88 | *.sbr
89 | *.tlb
90 | *.tli
91 | *.tlh
92 | *.tmp
93 | *.tmp_proj
94 | *_wpftmp.csproj
95 | *.log
96 | *.tlog
97 | *.vspscc
98 | *.vssscc
99 | .builds
100 | *.pidb
101 | *.svclog
102 | *.scc
103 |
104 | # Chutzpah Test files
105 | _Chutzpah*
106 |
107 | # Visual C++ cache files
108 | ipch/
109 | *.aps
110 | *.ncb
111 | *.opendb
112 | *.opensdf
113 | *.sdf
114 | *.cachefile
115 | *.VC.db
116 | *.VC.VC.opendb
117 |
118 | # Visual Studio profiler
119 | *.psess
120 | *.vsp
121 | *.vspx
122 | *.sap
123 |
124 | # Visual Studio Trace Files
125 | *.e2e
126 |
127 | # TFS 2012 Local Workspace
128 | $tf/
129 |
130 | # Guidance Automation Toolkit
131 | *.gpState
132 |
133 | # ReSharper is a .NET coding add-in
134 | _ReSharper*/
135 | *.[Rr]e[Ss]harper
136 | *.DotSettings.user
137 |
138 | # TeamCity is a build add-in
139 | _TeamCity*
140 |
141 | # DotCover is a Code Coverage Tool
142 | *.dotCover
143 |
144 | # AxoCover is a Code Coverage Tool
145 | .axoCover/*
146 | !.axoCover/settings.json
147 |
148 | # Coverlet is a free, cross platform Code Coverage Tool
149 | coverage*.json
150 | coverage*.xml
151 | coverage*.info
152 |
153 | # Visual Studio code coverage results
154 | *.coverage
155 | *.coveragexml
156 |
157 | # NCrunch
158 | _NCrunch_*
159 | .*crunch*.local.xml
160 | nCrunchTemp_*
161 |
162 | # MightyMoose
163 | *.mm.*
164 | AutoTest.Net/
165 |
166 | # Web workbench (sass)
167 | .sass-cache/
168 |
169 | # Installshield output folder
170 | [Ee]xpress/
171 |
172 | # DocProject is a documentation generator add-in
173 | DocProject/buildhelp/
174 | DocProject/Help/*.HxT
175 | DocProject/Help/*.HxC
176 | DocProject/Help/*.hhc
177 | DocProject/Help/*.hhk
178 | DocProject/Help/*.hhp
179 | DocProject/Help/Html2
180 | DocProject/Help/html
181 |
182 | # Click-Once directory
183 | publish/
184 |
185 | # Publish Web Output
186 | *.[Pp]ublish.xml
187 | *.azurePubxml
188 | # Note: Comment the next line if you want to checkin your web deploy settings,
189 | # but database connection strings (with potential passwords) will be unencrypted
190 | *.pubxml
191 | *.publishproj
192 |
193 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
194 | # checkin your Azure Web App publish settings, but sensitive information contained
195 | # in these scripts will be unencrypted
196 | PublishScripts/
197 |
198 | # NuGet Packages
199 | *.nupkg
200 | # NuGet Symbol Packages
201 | *.snupkg
202 | # The packages folder can be ignored because of Package Restore
203 | **/[Pp]ackages/*
204 | # except build/, which is used as an MSBuild target.
205 | !**/[Pp]ackages/build/
206 | # Uncomment if necessary however generally it will be regenerated when needed
207 | #!**/[Pp]ackages/repositories.config
208 | # NuGet v3's project.json files produces more ignorable files
209 | *.nuget.props
210 | *.nuget.targets
211 |
212 | # Microsoft Azure Build Output
213 | csx/
214 | *.build.csdef
215 |
216 | # Microsoft Azure Emulator
217 | ecf/
218 | rcf/
219 |
220 | # Windows Store app package directories and files
221 | AppPackages/
222 | BundleArtifacts/
223 | Package.StoreAssociation.xml
224 | _pkginfo.txt
225 | *.appx
226 | *.appxbundle
227 | *.appxupload
228 |
229 | # Visual Studio cache files
230 | # files ending in .cache can be ignored
231 | *.[Cc]ache
232 | # but keep track of directories ending in .cache
233 | !?*.[Cc]ache/
234 |
235 | # Others
236 | ClientBin/
237 | ~$*
238 | *~
239 | *.dbmdl
240 | *.dbproj.schemaview
241 | *.jfm
242 | *.pfx
243 | *.publishsettings
244 | orleans.codegen.cs
245 |
246 | # Including strong name files can present a security risk
247 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
248 | #*.snk
249 |
250 | # Since there are multiple workflows, uncomment next line to ignore bower_components
251 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
252 | #bower_components/
253 |
254 | # RIA/Silverlight projects
255 | Generated_Code/
256 |
257 | # Backup & report files from converting an old project file
258 | # to a newer Visual Studio version. Backup files are not needed,
259 | # because we have git ;-)
260 | _UpgradeReport_Files/
261 | Backup*/
262 | UpgradeLog*.XML
263 | UpgradeLog*.htm
264 | ServiceFabricBackup/
265 | *.rptproj.bak
266 |
267 | # SQL Server files
268 | *.mdf
269 | *.ldf
270 | *.ndf
271 |
272 | # Business Intelligence projects
273 | *.rdl.data
274 | *.bim.layout
275 | *.bim_*.settings
276 | *.rptproj.rsuser
277 | *- [Bb]ackup.rdl
278 | *- [Bb]ackup ([0-9]).rdl
279 | *- [Bb]ackup ([0-9][0-9]).rdl
280 |
281 | # Microsoft Fakes
282 | FakesAssemblies/
283 |
284 | # GhostDoc plugin setting file
285 | *.GhostDoc.xml
286 |
287 | # Node.js Tools for Visual Studio
288 | .ntvs_analysis.dat
289 | node_modules/
290 |
291 | # Visual Studio 6 build log
292 | *.plg
293 |
294 | # Visual Studio 6 workspace options file
295 | *.opt
296 |
297 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
298 | *.vbw
299 |
300 | # Visual Studio 6 auto-generated project file (contains which files were open etc.)
301 | *.vbp
302 |
303 | # Visual Studio 6 workspace and project file (working project files containing files to include in project)
304 | *.dsw
305 | *.dsp
306 |
307 | # Visual Studio 6 technical files
308 | *.ncb
309 | *.aps
310 |
311 | # Visual Studio LightSwitch build output
312 | **/*.HTMLClient/GeneratedArtifacts
313 | **/*.DesktopClient/GeneratedArtifacts
314 | **/*.DesktopClient/ModelManifest.xml
315 | **/*.Server/GeneratedArtifacts
316 | **/*.Server/ModelManifest.xml
317 | _Pvt_Extensions
318 |
319 | # Paket dependency manager
320 | .paket/paket.exe
321 | paket-files/
322 |
323 | # FAKE - F# Make
324 | .fake/
325 |
326 | # CodeRush personal settings
327 | .cr/personal
328 |
329 | # Python Tools for Visual Studio (PTVS)
330 | __pycache__/
331 | *.pyc
332 |
333 | # Cake - Uncomment if you are using it
334 | # tools/**
335 | # !tools/packages.config
336 |
337 | # Tabs Studio
338 | *.tss
339 |
340 | # Telerik's JustMock configuration file
341 | *.jmconfig
342 |
343 | # BizTalk build output
344 | *.btp.cs
345 | *.btm.cs
346 | *.odx.cs
347 | *.xsd.cs
348 |
349 | # OpenCover UI analysis results
350 | OpenCover/
351 |
352 | # Azure Stream Analytics local run output
353 | ASALocalRun/
354 |
355 | # MSBuild Binary and Structured Log
356 | *.binlog
357 |
358 | # NVidia Nsight GPU debugger configuration file
359 | *.nvuser
360 |
361 | # MFractors (Xamarin productivity tool) working folder
362 | .mfractor/
363 |
364 | # Local History for Visual Studio
365 | .localhistory/
366 |
367 | # Visual Studio History (VSHistory) files
368 | .vshistory/
369 |
370 | # BeatPulse healthcheck temp database
371 | healthchecksdb
372 |
373 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
374 | MigrationBackup/
375 |
376 | # Ionide (cross platform F# VS Code tools) working folder
377 | .ionide/
378 |
379 | # Fody - auto-generated XML schema
380 | FodyWeavers.xsd
381 |
382 | # VS Code files for those working on multiple tools
383 | .vscode/*
384 | !.vscode/settings.json
385 | !.vscode/tasks.json
386 | !.vscode/launch.json
387 | !.vscode/extensions.json
388 | *.code-workspace
389 |
390 | # Local History for Visual Studio Code
391 | .history/
392 |
393 | # Windows Installer files from build outputs
394 | *.cab
395 | *.msi
396 | *.msix
397 | *.msm
398 | *.msp
399 |
400 | # JetBrains Rider
401 | *.sln.iml
402 |
403 | ##
404 | ## Visual studio for Mac
405 | ##
406 |
407 |
408 | # globs
409 | Makefile.in
410 | *.userprefs
411 | *.usertasks
412 | config.make
413 | config.status
414 | aclocal.m4
415 | install-sh
416 | autom4te.cache/
417 | *.tar.gz
418 | tarballs/
419 | test-results/
420 |
421 | # Mac bundle stuff
422 | *.dmg
423 | *.app
424 |
425 | # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
426 | # General
427 | .DS_Store
428 | .AppleDouble
429 | .LSOverride
430 |
431 | # Icon must end with two \r
432 | Icon
433 |
434 |
435 | # Thumbnails
436 | ._*
437 |
438 | # Files that might appear in the root of a volume
439 | .DocumentRevisions-V100
440 | .fseventsd
441 | .Spotlight-V100
442 | .TemporaryItems
443 | .Trashes
444 | .VolumeIcon.icns
445 | .com.apple.timemachine.donotpresent
446 |
447 | # Directories potentially created on remote AFP share
448 | .AppleDB
449 | .AppleDesktop
450 | Network Trash Folder
451 | Temporary Items
452 | .apdisk
453 |
454 | # content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
455 | # Windows thumbnail cache files
456 | Thumbs.db
457 | ehthumbs.db
458 | ehthumbs_vista.db
459 |
460 | # Dump file
461 | *.stackdump
462 |
463 | # Folder config file
464 | [Dd]esktop.ini
465 |
466 | # Recycle Bin used on file shares
467 | $RECYCLE.BIN/
468 |
469 | # Windows Installer files
470 | *.cab
471 | *.msi
472 | *.msix
473 | *.msm
474 | *.msp
475 |
476 | # Windows shortcuts
477 | *.lnk
478 |
--------------------------------------------------------------------------------
/AngelSix/AngelSix.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net7.0-windows
6 | enable
7 | true
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/AngelSix/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
11 |
12 |
16 |
17 |
21 |
22 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/AngelSix/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 AngelSix
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/AngelSix/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/AngelSix/Converters/ApplicationPageViewConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Controls;
4 | using System.Windows.Data;
5 |
6 | namespace AngelSix.Converters
7 | {
8 | public class ApplicationPageViewConverter : IValueConverter
9 | {
10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11 | {
12 | switch ((ApplicationPage)value)
13 | {
14 | case ApplicationPage.Empty:
15 | return new TextBlock { Text = "404 Not Found" };
16 | case ApplicationPage.Login:
17 | return new Login();
18 | case ApplicationPage.Home:
19 | return new Home();
20 | default:
21 | throw new ArgumentException("Invalid value passed to ApplicationPageViewConverter");
22 | }
23 | }
24 |
25 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
26 | {
27 | throw new NotImplementedException();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/AngelSix/Home.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/AngelSix/Home.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 |
3 | namespace AngelSix
4 | {
5 | ///
6 | /// Home.xaml 的交互逻辑
7 | ///
8 | public partial class Home
9 | {
10 | public Home()
11 | {
12 | InitializeComponent();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/AngelSix/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/AngelSix/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace AngelSix
4 | {
5 | ///
6 | /// Interaction logic for MainWindow.xaml
7 | ///
8 | public partial class MainWindow : Window
9 | {
10 | public MainWindow()
11 | {
12 | InitializeComponent();
13 | }
14 |
15 | private void Window_Loaded(object sender, RoutedEventArgs e)
16 | {
17 | NavigationService.Instance.Navigate(ApplicationPage.Login);
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/AngelSix/NavigationService.cs:
--------------------------------------------------------------------------------
1 | using AngelSix.ViewModels;
2 |
3 | namespace AngelSix
4 | {
5 | class NavigationService
6 | {
7 | public static NavigationService Instance { get; } = new NavigationService();
8 |
9 | private MainViewModel mainVM;
10 |
11 | public void Navigate(ApplicationPage page)
12 | {
13 | if (mainVM == null)
14 | {
15 | mainVM = (MainViewModel)App.Current.MainWindow.DataContext;
16 | }
17 |
18 | mainVM.CurrentPage = page;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/AngelSix/ViewModels/HomeViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace AngelSix.ViewModels
2 | {
3 | public class HomeViewModel : ViewModelBase
4 | {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/AngelSix/ViewModels/LoginViewModel.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.Input;
2 |
3 | namespace AngelSix.ViewModels
4 | {
5 | public partial class LoginViewModel : ViewModelBase
6 | {
7 | public string UserName { get; set; } = "AngelSix";
8 |
9 | [RelayCommand]
10 | void Login()
11 | {
12 | NavigationService.Instance.Navigate(ApplicationPage.Home);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/AngelSix/ViewModels/MainViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace AngelSix.ViewModels
2 | {
3 | public partial class MainViewModel : ViewModelBase
4 | {
5 | [ObservableProperty]
6 | ApplicationPage currentPage;
7 |
8 | public MainViewModel()
9 | {
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/AngelSix/ViewModels/ViewModelBase.cs:
--------------------------------------------------------------------------------
1 | namespace AngelSix.ViewModels
2 | {
3 | public class ViewModelBase : ObservableObject
4 | {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/AngelSix/Views/ApplicationPage.cs:
--------------------------------------------------------------------------------
1 | namespace AngelSix
2 | {
3 | public enum ApplicationPage
4 | {
5 | Empty,
6 | Login,
7 | Home
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/AngelSix/Views/BasePage.cs:
--------------------------------------------------------------------------------
1 | using AngelSix.ViewModels;
2 | using System.Windows.Controls;
3 |
4 | namespace AngelSix
5 | {
6 | public abstract class BasePage : UserControl where VM : ViewModelBase, new()
7 | {
8 | public BasePage()
9 | {
10 | DataContext = new VM();
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/AngelSix/Views/Login.xaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
20 |
21 | Login
22 |
23 | User name:
24 |
25 | Password:
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/AngelSix/Views/Login.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace AngelSix
2 | {
3 | ///
4 | /// Login.xaml 的交互逻辑
5 | ///
6 | public partial class Login
7 | {
8 | public Login()
9 | {
10 | InitializeComponent();
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Kevin/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
12 |
13 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Kevin/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.DependencyInjection;
2 | using System;
3 | using System.Windows;
4 |
5 | namespace Kevin
6 | {
7 | ///
8 | /// Interaction logic for App.xaml
9 | ///
10 | public partial class App : Application
11 | {
12 | public IServiceProvider Services { get; }
13 |
14 | public static new App Current => (App)Application.Current;
15 |
16 | public App()
17 | {
18 | var container = new ServiceCollection();
19 |
20 | container.AddSingleton();
21 | container.AddSingleton();
22 |
23 | container.AddScoped();
24 | container.AddScoped();
25 | container.AddScoped();
26 |
27 | Services = container.BuildServiceProvider();
28 | }
29 |
30 | protected override void OnStartup(StartupEventArgs e)
31 | {
32 | base.OnStartup(e);
33 |
34 | MainWindow = Services.GetRequiredService();
35 | MainWindow.Show();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Kevin/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/Kevin/Kevin.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net7.0-windows
6 | enable
7 | true
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Kevin/MainViewModel.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Kevin
4 | {
5 | public class MainViewModel : ViewModelBase
6 | {
7 | public List ViewModels { get; }
8 |
9 | public MainViewModel(Page1ViewModel p1, Page2ViewModel p2, Page3ViewModel p3)
10 | {
11 | ViewModels = new List { p1, p2, p3 };
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Kevin/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
13 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/Kevin/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.DependencyInjection;
2 | using System.Windows;
3 |
4 | namespace Kevin
5 | {
6 | ///
7 | /// Interaction logic for MainWindow.xaml
8 | ///
9 | public partial class MainWindow : Window
10 | {
11 | public MainWindow(MainViewModel vm)
12 | {
13 | InitializeComponent();
14 |
15 | this.DataContext = vm;
16 |
17 | //Page1.DataContext = App.Current.Services.GetRequiredService();
18 | //Page2.DataContext = App.Current.Services.GetRequiredService();
19 | //Page3.DataContext = App.Current.Services.GetRequiredService();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Kevin/ViewModelBase.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 |
3 | namespace Kevin
4 | {
5 | public abstract class ViewModelBase : INotifyPropertyChanged
6 | {
7 | public event PropertyChangedEventHandler? PropertyChanged;
8 |
9 | protected void OnPropertyChanged(PropertyChangedEventArgs e)
10 | {
11 | PropertyChanged?.Invoke(this, e);
12 | }
13 |
14 | protected void OnPropertyChanged(string propertyName)
15 | {
16 | OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Kevin/ViewModels.cs:
--------------------------------------------------------------------------------
1 | namespace Kevin;
2 |
3 | public abstract class PageViewModelBase : ViewModelBase
4 | {
5 | public string? Header { get; set; }
6 | }
7 |
8 | public class Page1ViewModel : PageViewModelBase
9 | {
10 | public Page1ViewModel() => Header = "Page 1";
11 |
12 | public string PageMessage { get; set; } = "Hello, Page 1";
13 | }
14 |
15 | public class Page2ViewModel : PageViewModelBase
16 | {
17 | public Page2ViewModel() => Header = "Page 2";
18 |
19 | public string PageMessage { get; set; } = "Hello, Page 2";
20 | }
21 |
22 | public class Page3ViewModel : PageViewModelBase
23 | {
24 | public Page3ViewModel() => Header = "Page 3";
25 |
26 | public string PageMessage { get; set; } = "Hello, Page 3";
27 | }
28 |
--------------------------------------------------------------------------------
/Kevin/Views/Page1.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Kevin/Views/Page1.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 |
3 | namespace Kevin.Views
4 | {
5 | ///
6 | /// Page1.xaml 的交互逻辑
7 | ///
8 | public partial class Page1 : UserControl
9 | {
10 | public Page1()
11 | {
12 | InitializeComponent();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Kevin/Views/Page2.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Kevin/Views/Page2.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 |
3 | namespace Kevin.Views
4 | {
5 | ///
6 | /// Page2.xaml 的交互逻辑
7 | ///
8 | public partial class Page2 : UserControl
9 | {
10 | public Page2()
11 | {
12 | InitializeComponent();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Kevin/Views/Page3.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Kevin/Views/Page3.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 |
3 | namespace Kevin.Views
4 | {
5 | ///
6 | /// Page3.xaml 的交互逻辑
7 | ///
8 | public partial class Page3 : UserControl
9 | {
10 | public Page3()
11 | {
12 | InitializeComponent();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BYJRK/WpfNavigationDemo/5a6a3f63d8327e5d36e3f4196ded05af90f2a751/README.md
--------------------------------------------------------------------------------
/Sergio/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
10 |
11 |
15 |
16 |
20 |
21 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Sergio/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using Sergio.ViewModels;
2 | using System;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using System.Windows.Navigation;
6 |
7 | namespace Sergio
8 | {
9 | ///
10 | /// Interaction logic for App.xaml
11 | ///
12 | public partial class App : Application
13 | {
14 | public IServiceProvider Services { get; }
15 |
16 | public static new App Current => (App)Application.Current;
17 |
18 | public App()
19 | {
20 | var container = new ServiceCollection();
21 |
22 | container.AddSingleton(_ => new Frame { NavigationUIVisibility = NavigationUIVisibility.Hidden });
23 |
24 | container.AddSingleton();
25 | container.AddSingleton();
26 |
27 | container.AddTransient();
28 | container.AddTransient();
29 |
30 | container.AddTransient();
31 | container.AddTransient();
32 |
33 | container.AddSingleton();
34 |
35 | Services = container.BuildServiceProvider();
36 | }
37 |
38 | protected override void OnStartup(StartupEventArgs e)
39 | {
40 | base.OnStartup(e);
41 |
42 | MainWindow = Services.GetRequiredService();
43 | MainWindow.Show();
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Sergio/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/Sergio/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Sergio/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using Sergio.ViewModels;
2 | using System;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 |
6 | namespace Sergio
7 | {
8 | ///
9 | /// Interaction logic for MainWindow.xaml
10 | ///
11 | public partial class MainWindow : Window
12 | {
13 | public MainWindow(MainWindowViewModel viewModel, NavigationService navigationService, Frame rootFrame)
14 | {
15 | InitializeComponent();
16 |
17 | DataContext = viewModel;
18 |
19 | this.AddChild(rootFrame);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Sergio/NavigationService.cs:
--------------------------------------------------------------------------------
1 | using Sergio.ViewModels;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Reflection;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Navigation;
9 |
10 | namespace Sergio
11 | {
12 | public class NavigationService
13 | {
14 | private readonly Frame? mainFrame;
15 |
16 | public NavigationService(Frame frame)
17 | {
18 | mainFrame = frame;
19 | mainFrame.LoadCompleted += MainFrame_LoadCompleted;
20 | }
21 |
22 | private void MainFrame_LoadCompleted(object sender, NavigationEventArgs e)
23 | {
24 | if (e.ExtraData is not Dictionary extraData)
25 | return;
26 |
27 | if ((mainFrame?.Content as FrameworkElement)?.DataContext is not ViewModelBase vm)
28 | return;
29 |
30 | foreach (var item in extraData)
31 | {
32 | vm.GetType().GetProperty(item.Key)?.SetValue(vm, item.Value);
33 | }
34 | }
35 |
36 | private readonly Dictionary mapping =
37 | new()
38 | {
39 | [typeof(LoginViewModel)] = typeof(Login),
40 | [typeof(HomeViewModel)] = typeof(Home)
41 | };
42 |
43 | private Type? FindView()
44 | {
45 | return Assembly
46 | .GetAssembly(typeof(VM))
47 | ?.GetTypes()
48 | .FirstOrDefault(t => t.Name == typeof(VM).Name.Replace("ViewModel", ""));
49 | }
50 |
51 | public void Navigate()
52 | where VM : ViewModelBase
53 | {
54 | Navigate(null);
55 | }
56 |
57 | public void Navigate(Dictionary? extraData)
58 | where VM : ViewModelBase
59 | {
60 | var viewType = FindView();
61 | if (viewType is null)
62 | return;
63 |
64 | var page = App.Current.Services.GetService(viewType) as Page;
65 | mainFrame?.Navigate(page, extraData);
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/Sergio/Sergio.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net7.0-windows
6 | enable
7 | true
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Sergio/ViewModels/HomeViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace Sergio.ViewModels
2 | {
3 | public partial class HomeViewModel : ViewModelBase
4 | {
5 | [ObservableProperty]
6 | string? userName;
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Sergio/ViewModels/LoginViewModel.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.Input;
2 | using System.Collections.Generic;
3 |
4 | namespace Sergio.ViewModels
5 | {
6 | public partial class LoginViewModel : ViewModelBase
7 | {
8 | private readonly NavigationService navigationService;
9 |
10 | public string UserName { get; set; } = "Sergio";
11 |
12 | public LoginViewModel(NavigationService navigationService)
13 | {
14 | this.navigationService = navigationService;
15 | }
16 |
17 | [RelayCommand]
18 | void Login()
19 | {
20 | navigationService.Navigate(new Dictionary
21 | {
22 | [nameof(HomeViewModel.UserName)] = UserName
23 | });
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Sergio/ViewModels/MainWindowViewModel.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.Input;
2 |
3 | namespace Sergio.ViewModels
4 | {
5 | public partial class MainWindowViewModel : ViewModelBase
6 | {
7 | private readonly NavigationService navigationService;
8 |
9 | public MainWindowViewModel(NavigationService navigationService)
10 | {
11 | this.navigationService = navigationService;
12 | }
13 |
14 | [RelayCommand]
15 | void Loaded()
16 | {
17 | navigationService.Navigate();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Sergio/ViewModels/ViewModelBase.cs:
--------------------------------------------------------------------------------
1 | namespace Sergio.ViewModels
2 | {
3 | public class ViewModelBase : ObservableObject
4 | {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/Sergio/Views/Home.xaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Sergio/Views/Home.xaml.cs:
--------------------------------------------------------------------------------
1 | using Sergio.ViewModels;
2 | using System.Windows.Controls;
3 |
4 | namespace Sergio
5 | {
6 | ///
7 | /// Home.xaml 的交互逻辑
8 | ///
9 | public partial class Home : Page
10 | {
11 | public Home(HomeViewModel viewModel)
12 | {
13 | InitializeComponent();
14 |
15 | DataContext = viewModel;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Sergio/Views/Login.xaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
21 |
22 | Login
23 |
24 | User name:
25 |
26 | Password:
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Sergio/Views/Login.xaml.cs:
--------------------------------------------------------------------------------
1 | using Sergio.ViewModels;
2 | using System.Windows.Controls;
3 |
4 | namespace Sergio
5 | {
6 | ///
7 | /// Login.xaml 的交互逻辑
8 | ///
9 | public partial class Login : Page
10 | {
11 | public Login(LoginViewModel viewModel)
12 | {
13 | InitializeComponent();
14 |
15 | DataContext = viewModel;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/SingletonSean/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
10 |
11 |
15 |
16 |
20 |
21 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/SingletonSean/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using SingletonSean.ViewModels;
2 | using System.Windows;
3 |
4 | namespace SingletonSean
5 | {
6 | ///
7 | /// Interaction logic for App.xaml
8 | ///
9 | public partial class App : Application
10 | {
11 | public IServiceProvider Services { get; }
12 |
13 | public static new App Current => (App)Application.Current;
14 |
15 | public App()
16 | {
17 | var container = new ServiceCollection();
18 |
19 | container.AddSingleton();
20 | container.AddSingleton();
21 |
22 | container.AddSingleton();
23 | container.AddSingleton();
24 |
25 | container.AddTransient();
26 | container.AddTransient();
27 |
28 | Services = container.BuildServiceProvider();
29 | }
30 |
31 | protected override void OnStartup(StartupEventArgs e)
32 | {
33 | base.OnStartup(e);
34 |
35 | MainWindow = Services.GetRequiredService();
36 | MainWindow.Show();
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/SingletonSean/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/SingletonSean/NavigationService.cs:
--------------------------------------------------------------------------------
1 | using SingletonSean.ViewModels;
2 |
3 | namespace SingletonSean
4 | {
5 | public class NavigationService
6 | {
7 | private ViewModelBase? currentViewModel;
8 |
9 | public ViewModelBase? CurrentViewModel
10 | {
11 | get => currentViewModel;
12 | set
13 | {
14 | currentViewModel = value;
15 | // notify property changed
16 | CurrentViewModelChanged?.Invoke();
17 | }
18 | }
19 |
20 | public event Action? CurrentViewModelChanged;
21 |
22 | public void NavigateTo() where T : ViewModelBase
23 | => CurrentViewModel = App.Current.Services.GetService();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/SingletonSean/SingletonSean.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net7.0-windows
6 | enable
7 | true
8 | enable
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/SingletonSean/UserService.cs:
--------------------------------------------------------------------------------
1 | namespace SingletonSean
2 | {
3 | public class UserService
4 | {
5 | public string? UserName { get; set; }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/SingletonSean/ViewModels/HomeViewModel.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.Input;
2 |
3 | namespace SingletonSean.ViewModels
4 | {
5 | public partial class HomeViewModel : ViewModelBase
6 | {
7 | private readonly NavigationService navigationService;
8 | private readonly UserService userService;
9 |
10 | [ObservableProperty]
11 | string? userName;
12 |
13 | public HomeViewModel(NavigationService navigationService, UserService userService)
14 | {
15 | this.navigationService = navigationService;
16 | this.userService = userService;
17 | UserName = userService.UserName;
18 | }
19 |
20 | [RelayCommand]
21 | void Logout()
22 | {
23 | // navigate back to login page
24 | userService.UserName = null;
25 | navigationService.NavigateTo();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/SingletonSean/ViewModels/LoginViewModel.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.Input;
2 |
3 | namespace SingletonSean.ViewModels
4 | {
5 | public partial class LoginViewModel : ViewModelBase
6 | {
7 | private readonly NavigationService navigationService;
8 | private readonly UserService userService;
9 |
10 | [ObservableProperty]
11 | string? userName = "Sean";
12 |
13 | public LoginViewModel(NavigationService navigationService, UserService userService)
14 | {
15 | this.navigationService = navigationService;
16 | this.userService = userService;
17 | }
18 |
19 | [RelayCommand]
20 | void Login()
21 | {
22 | // navigate to home page
23 | userService.UserName = UserName;
24 | navigationService.NavigateTo();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/SingletonSean/ViewModels/MainViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace SingletonSean.ViewModels
2 | {
3 | public partial class MainViewModel : ViewModelBase
4 | {
5 | private readonly NavigationService navigator;
6 |
7 | [ObservableProperty]
8 | private ViewModelBase? currentViewModel;
9 |
10 | public MainViewModel(NavigationService navigationService)
11 | {
12 | navigator = navigationService;
13 |
14 | navigator.CurrentViewModelChanged += () =>
15 | {
16 | CurrentViewModel = navigationService.CurrentViewModel;
17 | };
18 |
19 | // navigate to login page at first
20 | navigator.NavigateTo();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/SingletonSean/ViewModels/ViewModelBase.cs:
--------------------------------------------------------------------------------
1 | namespace SingletonSean.ViewModels
2 | {
3 | public class ViewModelBase : ObservableObject
4 | {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/SingletonSean/Views/Home.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
18 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/SingletonSean/Views/Home.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 |
3 | namespace SingletonSean.Views
4 | {
5 | ///
6 | /// Home.xaml 的交互逻辑
7 | ///
8 | public partial class Home : UserControl
9 | {
10 | public Home()
11 | {
12 | InitializeComponent();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/SingletonSean/Views/Login.xaml:
--------------------------------------------------------------------------------
1 |
13 |
19 |
20 | Login
21 |
22 | User name:
23 |
24 | Password:
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/SingletonSean/Views/Login.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 |
3 | namespace SingletonSean.Views
4 | {
5 | ///
6 | /// Login.xaml 的交互逻辑
7 | ///
8 | public partial class Login : UserControl
9 | {
10 | public Login()
11 | {
12 | InitializeComponent();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/SingletonSean/Views/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/SingletonSean/Views/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using SingletonSean.ViewModels;
2 | using System.Windows;
3 |
4 | namespace SingletonSean
5 | {
6 | ///
7 | /// Interaction logic for MainWindow.xaml
8 | ///
9 | public partial class MainWindow : Window
10 | {
11 | public MainWindow(MainViewModel viewModel)
12 | {
13 | InitializeComponent();
14 |
15 | DataContext = viewModel;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/WpfNavigationDemo.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.6.33829.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{936886CB-65A8-4909-8880-EC1C63F04077}"
7 | ProjectSection(SolutionItems) = preProject
8 | .csharpierrc.json = .csharpierrc.json
9 | .editorconfig = .editorconfig
10 | .gitignore = .gitignore
11 | README.md = README.md
12 | EndProjectSection
13 | EndProject
14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AngelSix", "AngelSix\AngelSix.csproj", "{8F16463D-C35E-4898-9B81-9375F4AB68CF}"
15 | EndProject
16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kevin", "Kevin\Kevin.csproj", "{F70542F3-5FE2-48EE-A9F8-87C831F898AB}"
17 | EndProject
18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sergio", "Sergio\Sergio.csproj", "{C91A6B36-1EF8-477F-A3EA-9B0697E70E53}"
19 | EndProject
20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SingletonSean", "SingletonSean\SingletonSean.csproj", "{78A9CE89-9487-492C-83FD-C0C32D86CFE7}"
21 | EndProject
22 | Global
23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
24 | Debug|Any CPU = Debug|Any CPU
25 | Release|Any CPU = Release|Any CPU
26 | EndGlobalSection
27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
28 | {8F16463D-C35E-4898-9B81-9375F4AB68CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {8F16463D-C35E-4898-9B81-9375F4AB68CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {8F16463D-C35E-4898-9B81-9375F4AB68CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {8F16463D-C35E-4898-9B81-9375F4AB68CF}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {F70542F3-5FE2-48EE-A9F8-87C831F898AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {F70542F3-5FE2-48EE-A9F8-87C831F898AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {F70542F3-5FE2-48EE-A9F8-87C831F898AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {F70542F3-5FE2-48EE-A9F8-87C831F898AB}.Release|Any CPU.Build.0 = Release|Any CPU
36 | {C91A6B36-1EF8-477F-A3EA-9B0697E70E53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37 | {C91A6B36-1EF8-477F-A3EA-9B0697E70E53}.Debug|Any CPU.Build.0 = Debug|Any CPU
38 | {C91A6B36-1EF8-477F-A3EA-9B0697E70E53}.Release|Any CPU.ActiveCfg = Release|Any CPU
39 | {C91A6B36-1EF8-477F-A3EA-9B0697E70E53}.Release|Any CPU.Build.0 = Release|Any CPU
40 | {78A9CE89-9487-492C-83FD-C0C32D86CFE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41 | {78A9CE89-9487-492C-83FD-C0C32D86CFE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
42 | {78A9CE89-9487-492C-83FD-C0C32D86CFE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
43 | {78A9CE89-9487-492C-83FD-C0C32D86CFE7}.Release|Any CPU.Build.0 = Release|Any CPU
44 | EndGlobalSection
45 | GlobalSection(SolutionProperties) = preSolution
46 | HideSolutionNode = FALSE
47 | EndGlobalSection
48 | GlobalSection(ExtensibilityGlobals) = postSolution
49 | SolutionGuid = {9253AADE-36AD-4245-874C-41EA65D9D0D6}
50 | EndGlobalSection
51 | EndGlobal
52 |
--------------------------------------------------------------------------------
/mindmap.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BYJRK/WpfNavigationDemo/5a6a3f63d8327e5d36e3f4196ded05af90f2a751/mindmap.pdf
--------------------------------------------------------------------------------