I'm currently working on something that is probably done in plenty of examples out there. But after some searching I can't find anything.
I'm working with WPF tab control and I'm trying to recreate some basic functionality (which you see in all internet browsers nowadays) to add a new tab by clicking a '+' tab which is the last listed tab.
I already have the '+' tab which adds a new tab. My problem is, I want to move the '+' tab after the new tab (so its the end tab again) and switch view to the new tab that has just been created.
I thought something like:
void tiNewTab_Add(object sender, EventArgs e)
{
int idx = tabControl1.Items.Count;
tabControl1.SelectedIndex = idx - 1;
TabItem ti = new TabItemKPI();
tabControl1.Items.Add(ti);
tabControl1.Items.MoveCurrentToLast();
}
...would work but no luck :(
C# is a programming language. WPF is a technology used to develop rich GUI applications using C# (or any other . NET language).
WPF is still one of the most used app frameworks in use on Windows (right behind WinForms).
Windows Presentation Foundation (WPF) is a UI framework that creates desktop client applications. The WPF development platform supports a broad set of application development features, including an application model, resources, controls, graphics, layout, data binding, documents, and security.
Universal Windows Platform. Both Windows Forms and WPF are old, and Microsoft is pointing developers towards its Universal Windows Platform (UWP) instead. UWP is an evolution of the new application platform introduced in Windows 8 in 2012.
Try something like this:
tabControl1.Items.Insert(tabControl1.Items.Count-1,ti);
This will do because you always have at least one TabItem (the + one)
Then select the second last one by
tabControl1.SelectedIndex=tabControl1.Items.Count-2;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With