tabcontrol

Stop TabControl from recreating its children

荒凉一梦 提交于 2019-11-26 15:11:19
I have an IList of viewmodels which are bound to a TabControl . This IList will not change over the lifetime of the TabControl . <TabControl ItemsSource="{Binding Tabs}" SelectedIndex="0" > <TabControl.ItemContainerStyle> <Style TargetType="TabItem"> <Setter Property="Content" Value="{Binding}" /> </Style> </TabControl.ItemContainerStyle> </TabControl> Each viewmodel has a DataTemplate which is specified in a ResourceDictionary . <DataTemplate TargetType={x:Type vm:MyViewModel}> <v:MyView/> </DataTemplate> Each of the views specified in the DataTemplate are resource intensive enough to create

WPF TabControl - Preventing Unload on Tab Change?

我的未来我决定 提交于 2019-11-26 14:35:52
Is there a way to prevent the Tab Unload/Reload when a tab changes in a WPF tab control? Or if that is not possible, is there a recommended method for caching the tabs contents so they don't have to be regenerated with each tab change? For example, one tab's UI is completely customizable and stored in the database. When the user selects an object to work on, the items in the customized layout get populated with that object's data. Users expect a minor delay on initial load or when retrieving data, but not when changing back and forth between tabs, and the delay when changing tabs is very

How to hide TabPage from TabControl [duplicate]

无人久伴 提交于 2019-11-26 13:04:40
This question already has an answer here: Hiding and Showing TabPages in tabControl 18 answers How to hide TabPage from TabControl in WinForms 2.0? No, this doesn't exist. You have to remove the tab and re-add it when you want it. Or use a different (3rd-party) tab control. moonshine Code Snippet for Hiding a TabPage private void HideTab1_Click(object sender, EventArgs e) { tabControl1.TabPages.Remove(tabPage1); } Code Snippet for Showing a TabPage private void ShowTab1_Click(object sender, EventArgs e) { tabControl1.TabPages.Add(tabPage1); } I realize the question is old, and the accepted

Hiding and Showing TabPages in tabControl

爱⌒轻易说出口 提交于 2019-11-26 12:30:54
I am trying to show or hide tabpages as per user choice. If user selects gender male then form for male in a tabpage "male" should be displayed and if user selects female then similar next form should be displayed in next tab "female" I tried using tabControl1.TabPages.Remove(...) and tabControl1.TabPages.Add(...) It adds and removes the tabpages but doing so will loose my controls on tabpages too... i can't see them back. what's the problem here? You could remove the tab page from the TabControl.TabPages collection and store it in a list. For example: private List<TabPage> hiddenPages = new

Set TabPage Header Color

夙愿已清 提交于 2019-11-26 12:16:39
问题 Greetings, I have a tab control and I want to have 1 of the tabs have it\'s text color changed on a event. I\'ve found answers like C# - TabPage Color event and C# Winform: How to set the Base Color of a TabControl (not the tabpage) but using these sets all colors instead of one. So I was hoping there is a way to implement this with the tab I wish to change as a method instead of a event? Something like: public void SetTabPageHeaderColor(TabPage page, Color color) { //Text Here } 回答1: If you

How to create trapezoid tabs in WPF tab control

让人想犯罪 __ 提交于 2019-11-26 11:46:30
问题 How to create trapezoid tabs in WPF tab control? I\'d like to create non rectangular tabs that look like tabs in Google Chrome or like tabs in code editor of VS 2008. Can it be done with WPF styles or it must be drawn in code? Is there any example of code available on internet? Edit: There is lots of examples that show how to round corners or change colors of tabs, but I could not find any that changes geometry of tab like this two examples: VS 2008 Code Editor Tabs Google Chrome tabs Tabs in

Hide TabControl buttons to manage stacked Panel controls

拥有回忆 提交于 2019-11-26 11:22:00
I need to handle multiple panels, containing variuous data masks. Each panel shall be visible using a TreeView control. At this time, I handle the panels visibility manually, by making the selected one visible and bring it on top. Actually this is not much confortable, especially in the UI designer, since when I add a brand new panel I have to resize every panel and then design it... A good solution would be using a TabControl, and each panel is contained in a TabPage. But I cannot find any way to hide the TabControl buttons, since I already have a TreeView for selecting items. Another

In C# WPF, why is my TabControl&#39;s SelectionChanged event firing too often?

北城余情 提交于 2019-11-26 10:56:57
问题 I have a tabbed GUI with each tab containing a Frame. In one of these Frames there is a DataGrid. When the user selects this tab, I need my datagrid sorted, so I\'m using the TabControl SelectionChanged event to trigger the sort. However, this event triggers every time an item is selected from the DataGrid, even though the tabs themselves remain untouched. I\'ve tried number of different events: GotFocus for a TabItem RequestBringIntoView for a TabItem but they all seem to suffer from this

How to stop Wpf Tabcontrol to unload Visual tree on Tab change

时光总嘲笑我的痴心妄想 提交于 2019-11-26 09:44:45
问题 Hi My usercontrols placed in tabs are unloaded and loaded every time the tabs are changed.It creates some unnecessary lag in the application.I am looking for some way to fix this behavior.I know i have to subclass tabcontrol to change this behavior but how..? 回答1: You can find two different approaches to prevent this in this StackOverflow question: WPF TabControl - how to preserve control state within tab items (MVVM pattern) I recommend: Keeping the WPF Tab Control from destroying its

TabControl with Close and Add Button

被刻印的时光 ゝ 提交于 2019-11-26 08:29:54
问题 I\'m tring to make a tab control have a \"x\" (close button) and \"+\" (new tab button). I found a solution to add a x button, the tab looks like this now: But I want to add a + where\'s that black circle right now. I have no idea how, I tried draw on Paint event of the last tab, like this: var p = tabs.TabPages[tabs.TabCount - 1]; p.Paint += new PaintEventHandler(tab_OnDrawPage); private void tab_OnDrawPage(object sender, PaintEventArgs e) { // e.ClipRectangle. e.Graphics.DrawString(\"+\",