Tabbed interface in WPF using only built-in tools?

I saw here two threads about TDI and C #. Both of them really did not answer my questions ...

Since TDI today is pretty much similar to the standard, I can hardly imagine that I need to buy a special control (for example, AvalonDock or SandDock). This should be possible with the tab (?) Built-in control somehow! I do not need special features such as docking stations and dragging tabs. Just open each form in a new tab. Here it is.

How to add content controls of all forms to user controls and, upon request (button, menu click ...), add a new tab and place the corresponding user control on it ... something like this.

How would you do that? It can't be IT complicated (even for me), or am I missing something ?!

Thank you very much!

+4
source share
2 answers

It is not that difficult. This seems difficult because there are many different ways to do this.

Try the following:

<TabControl x:Name="documentArea"/> 

Handler for the AddForm button:

 private void AddFormClick(object sender, RoutedEventArgs e) { object form = GetNewForm(); documentArea.Items.Add(form); } 

What is it. You must implement GetNewForm() one of two ways. Ask him to return the user control that displays the form.

Or better yet, return the document you want to display. Use the DataTemplate to select the controls used to display this document. This method will be more difficult to configure.

+5
source

Perhaps a Josh Smith article on MVVM may give you an idea of ​​how to create such a user interface. Construction example: there is a convenient tabbed interface, so you can use it as a starting block.

+6
source

Source: https://habr.com/ru/post/1286566/


All Articles