This is not really a ideal solution, but as you create your tabs and add them to the tab control, you can just store the tab that is currently open, then switch to the tab you have just created, and then switch back. To the user it would just be a slight flicker but in reality you have just tricked winforms (or wpf accordingly) into drawing the object.
I tried doing something similar but for the life of me couldn't figure out how to change the visible tab programmatically. Tried setting TabControl. SelectedItem to a TabItem as well as incrementing the TabControl.
SelectedIndex property. – sohum Jan 11 '10 at 5:48 Actually..... I just realized that what I was doing was trying to change the tabs after the save button had been clicked, from within the handler... so I guess there was no opportunity for the tab to be repainted? I guess if I do this when adding the tabs it won't be an issue.
– sohum Jan 11 '10 at 5:50 Just tried it, it did not work. WPF seems to optimize and only paint the last tab opened. – sohum Jan 11 '10 at 5:54 In that case, you could always go through your tabs one by one, saving each as you go – caesay Jan 11 '10 at 4:54 I'm pretty sure I've tried that already, but I'll give it another swing.
– sohum Jan 11 '10 at 18:34.
Finally figured it out, thanks to this blog post. The solution involved creating an extension method for UIElement with a Refresh method that invoked an empty delegate with render priority. Apparently scheduling something with Render priority caused all other more important items to be executed, thus changing the tab.
Code replicated here in case blog is deleted: public static class ExtensionMethods { private static Action EmptyDelegate = delegate() { }; public static void Refresh(this UIElement uiElement) { uiElement.Dispatcher. Invoke(DispatcherPriority. Render, EmptyDelegate); } } void Page_Loaded(object sender, RoutedEventArgs e) { // irrelevant code foreach (// iterate over content that is added to each tab) { TabItem tabItem = new TabItem(); // load content tabPanel.Items.
Add(tabItem); tabItem. IsSelected = true; tabItem.Refresh(); } // tabPanel. SelectedIndex = 0; } To use it, just include the extension namespace in the code file that you need to use this functionality and it will appear in the list of methods.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.