WPF TabControl - Hiding tab buttons conditionally

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In my application users generally only have one tab page and I'd like to hide
the tab page buttons (headers?) when this is the case.

I have not been able to find a way to do this. Do I need to re-apply an
entire template to the tab control to have a handle into the appropriate
object, or can I access the default one?

Also, is there a more appropriate place to discuss WPF issues? I've been
trying to use forums.microsoft.com but whenever I try to reply or create a
post it logs me out, bizarrely.

Many thanks,

Drew Noakes.
 
Hello,

you should be able to add a style.trigger to the tabitem element and switch
the IsVisible (or IsEnabled if you want) property to false under certains
conditions. If you want to do this from code you should give the tabitem an
element name (tabitem.Name or x:Name if doesn't expose this) and access it
from your code-behind.

Kind regards,
Henning Krause
 
Hi Henning,

I tried this, but my trigger caused the entire tab page to disappear. My
situtation involves hiding the tab buttons when there's only one tab page to
display, and introducing the buttons when extra pages are added. Perhaps
I've misunderstood your suggestion or my implementation wasn't correct.

Drew.
 
Hello,

ok, I misunderstood your question here.

TabItem inherits from HeaderedContentControl. As such, it should have a
Header.

You can try to set the header content to null with a style trigger. Or
manipulate the HeaderTemplate property.

Albeit from that, I don't have any other idead.

Kind regards,
Henning Krause
 
Back
Top