Click here to Skip to main content
15,072,391 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi everyone,

I am new to wpf , and have a little knowledge in C#.
I designed a form with some buttons on the left dock of dock panel, and the center part with a tabcontrol.

So when i click a button in the left dock, i need to have a tab in the center dock, with controls I designed in other forms with exact positions.

For eg:

If I click the user button, I need the user.xaml form to be displayed in the tabcontrol.
If I click the customer button, I need the customers.xaml form to be displayed.

I have done it in C# but I have no idea in wpf.

Thank You
First, why? You could always do it all in just WPF, or all just in Forms, with much less trouble.
Anyway, what have you tried so far?
Mahindra Shambharkar 19-Jul-15 8:36am
I assume you have worked on Windows forms and you are trying to relate terms in WPF and WinForms.
Assuming that you have developed user.xaml as seperate file and so on.
1>Create user.xaml,customer.xaml as UserControl, click on add new Item>Usercontrol
2>Add ContentPresenter(eg. Grid) at center of TabControl.Consider naming it "grdUserForm"
3>On click on button > Create object of created user control and add to children of grid eg. grdUserForm.Children.Add(new user())

Hope this will help

1 solution

There is no such concept, "call a form". Besides, if you are new to WPF, you may not know many WPF features and techniques which could free you then need to use System.Windows.Forms in WPF at all. So, my first advice should be to develop all your applications in pure WPF, without any forms.

But if you really need to use Forms in WPF (even though your description does not justify it even a bit), you can do it. Please start here:[^].

By the way, the other way around is also possible:[^].

And finally, just for completeness: I have done a little research to validate: you can use the following rather exotic possibility: in a single process and single application, you can run one UI in one thread, and another UI in another thread, or you can have more threads like that. This way, one thread can run WPF UI, and another one — Forms UI. This is even easy to do. I'm not saying it's of any practical significance though.

Member 11845549 19-Jul-15 12:24pm
Thank You Guys @Sergey and @Mahindra

Let me check it out.
Sergey Alexandrovich Kryukov 19-Jul-15 13:20pm
You are welcome. Please do, and don't forget to accept the answer formally. Your follow-up questions will be welcome in all cases.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900