Closing an XAML form - windows-8

I am creating a windows 8 store application using vs2012.
I am tying to switch to another xaml form by click of a button but cannot do it.
I want the code to close or hide the current form and to switch over to new form .
Regards

If you are looking to wholesale replace the content then you can use the Frame.Navigate() method.
Frame rootFrame = Window.Current.Content as Frame;
rootFrame.Navigate(typeof(YourPageClass));
or simply
this.Frame.Navigate(typeof(YourPageClass));

remember that not every elemet has property hide or something like that. If you want to hide a grid with form or do a simillar thing you need to know the property that is responsible for visibility (in most cases it is Visibility and it is a bool).
The second thing is that you can be a newbie but if you want help make some effort and give us what you want
The third thing. If you want to change a page after click use Marc`s solution

Related

Including another window forms with in an "Iframe" in vb.net

I want to include another form in my code instead of constantly contacting the other form and making the form move with each other, which takes a lot of time to code in each form. And now I need something that takes less time and is much easier to do, like putting one windows form inside another windows form
EDIT: Unclear Question
I want to display a windows form inside another windows form,
just the same functionality as an Iframe in HTML, but instead
of including a web page I want it to include a form
MDI interface would be best, but if you really want to do this then look at this : (formFrame is the form that is shown inside formHost)
formFrame.TopLevel = false;
formHost.Controls.Add(formFrame);
formFrame.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
formFrame.Dock = DockStyle.Fill; // can be different for you needs
formFrame.Show();

Making multiple forms appear as one in VB.NET

I am writing a Windows Forms application in VB.NET. I have three forms: the main form, which shows a list of accounts, the account form which allows the user to view/edit the information for a specific account, and the policy form which allows the user to view/edit the information on a specific policy for that account. I want the forms to appear as if they are all the same window. Example: when the application starts, the user clicks an account name in the list box on the main form and clicks "edit". What I want to happen is that the window stays in the exact same place and stays the same exact size, only the content of the main form appears to be replaced with the content of the account form. Same thing if the user then chooses to edit a policy from the account form. When the user finishes and clicks "save", the main form comes back up. Through this entire use case, it would appear to the user as if they were viewing the same window the entire time, with the content of that window changing.
How can I do this? I have tried something like:
Dim newForm as New AcctForm
newForm.Location = Me.Location
newForm.Show()
Me.Close()
The problem is that if the user moves the original window, the new window appears where the parent form originally appeared, not where it ended up.
I see this is already in the comments, but what I have done in this case in the past is build each "form" in the application as a custom control. Then I have one actual form, and navigation works by changing which custom control is currently loaded on the parent form. To move from one screen/view to another, you remove the current custom control from the form's controls collection and add the new custom control.
I believe this is superior to manually setting the startup position and size, because you can use the form's .SuspendLayout()/.ResumeLayout() methods to hide the interim state, where there is no control loaded, from the user. This is harder to do when you want one form to be completely replaced by another.
This also makes it easy to set certain form properties in one place and have them be consistent for the application. You can even have an area on the form with controls that will now show in every view.
When using this pattern, I typically have each of my custom controls inherit from a common base. You may not have anything specific you will do with that base at the outset, but it almost always comes in handy later.
Finally, switching to use this scheme is easier than you think. Just go to the code for the each of your current forms, and you will find that each class currently inherits from System.Windows.Forms.Form. Most of the time, all you really need to do is change them to inherit from System.Windows.Forms.Panel and you're most of the way there.
As others have said, it may be better to redesign your application using custom controls or panels etc.
However, to answer your question regarding the seemingly random location of your forms, the first thing to check is that each form has it's StartPosition property set to Manual.
If your main form is resizable, then I would also add code to adjust newForm to the same size too.
I hope that helps with your immediate issues; so that you can move on to redesigning the application!
good morning there is another way . set property for second form to (top most) and use also
from2.show();
that make you switch between forms and keep form2 top other
Thanks
try using ShowDialog()
Dim newForm as New AcctForm
newForm.Location = Me.Location
newForm.ShowDialog()
Me.Close() <-- removed this

Multiple Views One Form

I'm looking to have a navigation pane on the left side of my form which will change the right side of the form accordingly. I could always use panels and store the controls on the panels but is there a better way to do this? A tab control would be nice but I wouldn't want to see the actual tabs ...
Is there a way to do this?
Edit after seeing the answer:
Dim uc As New UserControl1
Form1.Controls.Add(uc)
Will add everything in the user control to the form1. Alternatively, if I had a Panel, I could do:
Panel1.controls.add(uc)
That would add it to the panel.
You can use panels, but you could also have your panes as UserControls and load them into a single panel instance, or even directly into the form.
Putting them into UserControls also means your form's generated class won't be cluttered with control members.
I would have to agree with #Dai Here is a great thread on it. It explains how to setup the panels in the ide.

How to edit Expression Blend selected control part?

I am trying to edit a specific control part within a custom TabItem Template. In this case, it's the TemplateBottomSelected control part.
I'm having an issue where I cannot seem to view or edit any control parts within the template editor except the default TemplateTopSelected. Here's a screenshot of what I'm talking about:
Even though I'm selecting the "TemplateBottomSelected" grid, the only thing I can see is the template for the TemplateTopSelected item.
How the heck do I edit the other control parts within the template using the editor?
Thanks!
that's because these templates are either collapsed or the opacity of them is set to 0. :)
you can use the eye toggle button to only show the one you want to modify at design time, set the visibility to visible, do your changes, and reset it to collapsed.
please let me know if you need more info.

How does the tooltip control enhance all controls on the form with a new property?

When answering another question I started to wonder how I could Add new properties to all controls in a form just like the ToolTip-control does.
For example I could use that to Add a "IsDirty"-flag to all textboxes just by adding the component to the form and it would handle this for every textbox.
When adding the tooltip-control to the form all controls magically gets a new property "Tooltip on tooltip1" that can be set both programatically and in design view.
I want to be able to do my own enhancer like that.
It's an Extender Provider.