c# - How to load a new user control without opening a new window in WPF? -
I put together
which reads an XML file of the customer , Users and all work well to edit and save them.
However, when users save on the "Manage Customers" page, then the application for "go back" on I want "to show customers" page.
"Page" user controls are being loaded in shell like this:
using the system; Using System.Collections.Generic; Using System.Windows; Using System.Windows.Controls; Using System.Windows.Documents; Using the system. Using TestDynamicForm123.View; Namespace TestDynamicForm123 {Public partial class shell: window {personal dictionary & lt; String, IBaseView & gt; _userControls = New Dictionary & lt; String, IBaseView & gt; (); Public dictionary & lt; String, IBaseView & gt; GetUserControls () {Return _userControls; } Public Shell () {InitializeComponent (); & Lt; String & gt; UserControlKeys = New list & lt; String & gt; (); UserControlKeys.Add ("WelcomeView"); UserControlKeys.Add ("CustomersView"); UserControlKeys.Add ("ManageCustomersView"); Type type = this.GetType (); Assembly assembly = type Assembly; Foreach (UserControlKeys in String User Controlling) {string userControlFullName = String.Format ("{0} .view. {1}", type namespace, user control); IBaseView userControl = (IBaseView) assembly CreateInstance (userControlFullName); _userControls.Add (userControlKey, userControl); } // Set default page btnWelcome.RaiseEvent (New Routing AventAge (button. ClickEvent)); } Private Zero btnGeneral_Click (Object Sender, RoutedEventArgs e) {PanelMainContent.Children.Clear (); Button Button = (Button) e.OriginalSource; Panelmand druper Header = Button material; Type type = this.GetType (); Assembly assembly = type Assembly; IBaseView userControl = _userControls [button.Tag.ToString ()] as IBaseView; UserControl.SetDataContext (); Panelman content children. Add (user control as UserControl); } So when ManageCustomersView gets loaded and handles clicks, I try to get back to the CustomersView page , Which works, but it opens a new window Every time a user edits a customer, a new window pops up .
Private Zero Onavev (Object Sender, System.index.industry.edu.AntArguesE) Customer Customer = Customer; Customer.Save (customer); // back to default shell shell = new shell (); Button as btnCustomers = shell.FindName ("btn client") button; BtnCustomers.RaiseEvent (New Routing Aventure (buttonclive event)); Shell.Show (); } How can I change the above code inside a UserControl so that its parent can unload the current user control and Can others load, as of now another example of application?
New window was clearly decided because you are called onSave every time a new one You are creating shell objects, you need it.
Shell parents shell = window. Gatevondo (this) as Shell;
Comments
Post a Comment