2008-12-22 17 views

cevap

60

Sen ebeveyn TabPage'ler yalnızca bir öğe varsa bunu çökecek bir DataTrigger ile TabItem uygulanan bir Stil kullanabilirsiniz: Eğer TabControl kurtulmak istiyorsanız

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:sys="clr-namespace:System;assembly=mscorlib" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
    <Grid.Resources> 
     <x:Array x:Key="tabData" Type="{x:Type sys:String}"> 
      <sys:String>do</sys:String> 
      <sys:String>re</sys:String> 
      <sys:String>mi</sys:String> 
     </x:Array> 
    </Grid.Resources> 
    <TabControl ItemsSource="{StaticResource tabData}"> 
     <TabControl.ItemContainerStyle> 
      <Style TargetType="{x:Type TabItem}"> 
       <Style.Triggers> 
        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TabControl}}, Path=Items.Count}" Value="1"> 
         <Setter Property="Visibility" Value="Collapsed"/> 
        </DataTrigger> 
       </Style.Triggers>     
      </Style> 
     </TabControl.ItemContainerStyle> 
    </TabControl> 
</Grid> 

sadece bir tane tamamen eğer madde, bu mantık muhtemelen daha yüksek bir düzeyde olmalıdır.

İlgili konular