In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to use the CM framework of C # to achieve multi-page management". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Traditional way
Background code: ① defines the collection and adds data:
Public IViewModel ActiveWindowView {get; set;} public ObservableCollection ListBoxItems {get; set;} public string SelectedItem {get; set;} ListBoxItems = new ObservableCollection () {}; ListBoxItems.Add ("ShellView"); ListBoxItems.Add ("EventAggregatorView"); ListBoxItems.Add ("ConductorView"); ListBoxItems.Add ("MatchTemplateView"); ListBoxItems.Add ("IndicatorLightView"); ListBoxItems.Add ("MemorandumView") ListBoxItems.Add ("FTPTestView")
Change the selection of ② listbox and switch to the page:
Public void ListBoxItems_SelectionChanged () {switch (SelectedItem) {case "ShellView": ActiveWindowView = new ShellViewModel (); break; case "EventAggregatorView": ActiveWindowView = EventAggregatorViewModel.Instance; break; case "ConductorView": ActiveWindowView = new ConductorViewModel (); break Case "MatchTemplateView": ActiveWindowView = new MatchTemplateViewModel (); break; case "IndicatorLightView": ActiveWindowView = new IndicatorLightViewModel (); break; case "MemorandumView": ActiveWindowView = IoC.Get (); break; case "FTPTestView": ActiveWindowView = new FTPTestViewModel (new FTPConfig ()); break Default:break;}}
③ foreground binding:
Using Conductor under the framework of CM
① backend code: first, you need to inherit Conductor.Collection.OneActive to use the following methods and properties of this class. Secondly, the constructor needs to add the received interface IEnumerable, so the modified code is as follows:
Public MainWindowViewModel (IEnumerable modules) {Items.AddRange (modules); ActivateItem (Items.FirstOrDefault (vm = > vm.GetType () = = typeof (IndicatorLightViewModel));}
If you don't consider the page that is activated for the first time, then the core code has only one sentence:
Items.AddRange (modules)
② foreground code:
In this way, the front and background settings are done, inheriting a framework of multi-screen management class, so that the front and background code is greatly simplified, the function is not reduced, to be exact, it is more powerful, this is the advantage of the CM framework.
This is the end of the content of "how to use the CM framework of C # to achieve multi-page management". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.