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

爷,独闯天下 提交于 2019-12-01 04:14:24

问题


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!


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/1026912/tabbed-document-interface-in-wpf-using-only-on-board-means

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!