Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tabbed document interface in WPF using only on-board means?

I've seen two threads here about TDI & C#. Both of them didn't really answer the questions I have ...

Since TDIs are pretty much like a standard nowadays, I can hardly imagine, that I have to buy a special control (like AvalonDock or SandDock). This must be possible with built in the tab-control(?) somehow! I don't need special features like dock- and draggable tabitems. Just open every form in a new tab. Thats it.

Like putting every forms content controls into user controls and by request (button, menu click ...) add a new tab and put the corresponding user control on it ... something like this.

How would you do it? This can't be THAT complicated (even for me) or am I missing something?!

thanks a lot!

like image 539
Michael Niemand Avatar asked Jun 22 '09 12:06

Michael Niemand


2 Answers

Maybe Josh Smith's article on MVVM can give you an idea how to design such user interface. Example being built there is kinda tabbed document interface so you can use it as a starting block.

like image 75
idursun Avatar answered Nov 02 '22 15:11

idursun


It's not that hard. It seems hard because there are a lot of different ways to do it.

Try this:

<TabControl x:Name="documentArea"/>

Handler for AddForm button:

private void AddFormClick(object sender, RoutedEventArgs e)
{
    object form = GetNewForm();

    documentArea.Items.Add(form);
}

That's it. You have to implement GetNewForm() in one of two ways. Have it return a user control that displays the form.

OR better yet, have it return your document that you want to display. Use a DataTemplate to select the controls to use for displaying this document. This method is going to be more complex to set up.

like image 36
Josh G Avatar answered Nov 02 '22 15:11

Josh G