2010-05-17 117 views
0

請我試着爲每個按鈕分配左側自己的Tab控件。這是例如,當按下Intake表單按鈕時,它將有自己的一組選項卡(它自己的選項卡控件)如何使用多個選項卡控件,並能夠使用按鈕調用選定的選項卡控件

我是否應該在美工板上放置多個選項卡控件,或者是否存在以編程方式更改的方法當按鈕被按在左邊時,選項卡的名稱和內容如何?

謝謝你提前。

,這裏是一個鏈接hxxp://img709.imageshack.us/img709/554/tabcontrol.gif

這裏是迄今爲止

<Window 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
x:Class="service.MainWindow" 
x:Name="Window" 
Title="MainWindow" 
Width="687" Height="480" mc:Ignorable="d"> 
<Window.Resources> 
    <Storyboard x:Key="OnLoaded1"/> 
</Window.Resources> 
<Window.Triggers> 
    <EventTrigger RoutedEvent="FrameworkElement.Loaded"> 
    <BeginStoryboard Storyboard="{StaticResource OnLoaded1}"/> 
    </EventTrigger> 
</Window.Triggers> 

<Grid x:Name="LayoutRoot" Margin="0,0,-16,1"> 
    <Grid.ColumnDefinitions> 
    <ColumnDefinition Width="0*"/> 
    <ColumnDefinition/> 
    </Grid.ColumnDefinitions> 
    <DockPanel Margin="8,8,0,7" LastChildFill="False" Grid.Column="1" HorizontalAlignment="Left" Width="660"> 
    <Menu VerticalAlignment="Top" Width="657" Height="32"> 
    <MenuItem x:Name="file" Header="File"/> 
    <MenuItem x:Name="edit" Header="Edit"> 
    <MenuItem Width="100" Height="100" Header="MenuItem"/> 
    </MenuItem> 
    <MenuItem x:Name="view" Header="View"/> 
    <MenuItem x:Name="preferences" Header="Preferences"/> 
    <MenuItem x:Name="help" Header="Help"/> 
    </Menu> 
    </DockPanel> 
    <TabControl x:Name="tabwin" Margin="137.224,46,19,7" Grid.Column="1"> 
    <TabItem x:Name="intakeformsub" Header="Elegibility Form"> 
    <Grid HorizontalAlignment="Left" Width="490"/> 
    </TabItem> 
    <TabItem Header="TabItem"> 
    <Grid/> 
    </TabItem> 
    <TabItem Header="TabItem"> 
    <Grid/> 
    </TabItem> 
    <TabItem Header="TabItem"> 
    <Grid> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="0.567*"/> 
     <ColumnDefinition Width="0.433*"/> 
    </Grid.ColumnDefinitions> 
    </Grid> 
    </TabItem> 
    <TabItem Header="TabItem"> 
    <Grid/> 
    </TabItem> 
    <TabItem Header="TabItem"> 
    <Grid> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="0.735*"/> 
     <ColumnDefinition Width="0.265*"/> 
    </Grid.ColumnDefinitions> 
    </Grid> 
    </TabItem> 
    <TabItem Header="TabItem"> 
    <Grid/> 
    </TabItem> 
    <TabItem Header="TabItem"> 
    <Grid/> 
    </TabItem> 
    </TabControl> 
    <Grid x:Name="___buttontab" Margin="11.205,61,0,0" Grid.Column="1" HorizontalAlignment="Left" Width="122.019" VerticalAlignment="Top" Height="276"> 
    <Button VerticalAlignment="Top" Height="36" Content="Button"/> 
    <Button Margin="0,40,0,0" Content="Oasis Assessments" VerticalAlignment="Top" Height="36"/> 
    <Button Margin="0,80,0,0" VerticalAlignment="Top" Height="36" Content="Plan of Care"/> 
    <Button Margin="0,120,0,0" VerticalAlignment="Top" Height="36" Content="Medication Profile" RenderTransformOrigin="0.421,5.556"/> 
    <Button Margin="0,0,0,80" VerticalAlignment="Bottom" Height="36" Content="Clinical Notes"/> 
    <Button Margin="0,0,0,40" VerticalAlignment="Bottom" Height="36" Content="Infection Control"/> 
    <Button x:Name="intakeformbtn" VerticalAlignment="Top" Height="36" Content="Intake Form" Click="intakeform"> 
    <Button.BindingGroup> 
    <BindingGroup/> 
    </Button.BindingGroup> 
    </Button> 
    <Button VerticalAlignment="Bottom" Height="36" Content="Discharge Summary"/> 
    </Grid> 
    <ProgressBar HorizontalAlignment="Left" Margin="8,0,0,7" VerticalAlignment="Bottom" Width="104.795" Height="19" Grid.Column="1"/> 
</Grid> 
</Window> 
+0

就個人而言,我想給每個按鈕它自己的標籤控件(有多個選項卡),然後單擊該按鈕時,做一個動畫到該選項卡控制從幻燈片對,並使已經存在的那個消失。 – 2010-05-17 18:57:44

回答

0

代碼來解決這個問題的一種方式使用另一個TabControl而不是按鈕,但其中標籤頁標題被重新設計爲可視化的按鈕代替標籤。這樣你甚至不必處理按鈕的變化。

試試下面的代碼:

<Window 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
x:Class="WpfApplication16.MainWindow" 
x:Name="Window" 
Title="MainWindow" 
Width="687" Height="480" mc:Ignorable="d"> 
    <Window.Resources> 
     <Storyboard x:Key="OnLoaded1"/> 

     <Style TargetType="{x:Type TabItem}" x:Key="TabButtonStyle"> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate TargetType="{x:Type TabItem}"> 
         <ToggleButton IsChecked="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=IsSelected, Mode=TwoWay}" 
                Margin="10"> 
          <ContentPresenter ContentSource="Header" /> 
         </ToggleButton> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 

    </Window.Resources> 
    <Window.Triggers> 
     <EventTrigger RoutedEvent="FrameworkElement.Loaded"> 
      <BeginStoryboard Storyboard="{StaticResource OnLoaded1}"/> 
     </EventTrigger> 
    </Window.Triggers> 

    <Grid x:Name="LayoutRoot" Margin="0,0,-16,1"> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="0*"/> 
      <ColumnDefinition/> 
     </Grid.ColumnDefinitions> 
     <DockPanel Margin="8,8,0,7" LastChildFill="False" Grid.Column="1" HorizontalAlignment="Left" Width="660"> 
      <Menu VerticalAlignment="Top" Width="657" Height="32"> 
       <MenuItem x:Name="file" Header="File"/> 
       <MenuItem x:Name="edit" Header="Edit"> 
        <MenuItem Width="100" Height="100" Header="MenuItem"/> 
       </MenuItem> 
       <MenuItem x:Name="view" Header="View"/> 
       <MenuItem x:Name="preferences" Header="Preferences"/> 
       <MenuItem x:Name="help" Header="Help"/> 
      </Menu> 
     </DockPanel> 
     <TabControl Margin="0,61,0,0" Grid.Column="1" ItemContainerStyle="{StaticResource TabButtonStyle}" TabStripPlacement="Left"> 
      <TabControl.Items> 
       <TabItem Header="Button"> 
        <Grid> 
         <TabControl x:Name="tabwin"> 
          <TabItem x:Name="intakeformsub" Header="Elegibility Form"> 
           <Grid HorizontalAlignment="Left" Width="490"/> 
          </TabItem> 
          <TabItem Header="TabItem"> 
           <Grid/> 
          </TabItem> 
          <TabItem Header="TabItem"> 
           <Grid/> 
          </TabItem> 
          <TabItem Header="TabItem"> 
           <Grid> 
            <Grid.ColumnDefinitions> 
             <ColumnDefinition Width="0.567*"/> 
             <ColumnDefinition Width="0.433*"/> 
            </Grid.ColumnDefinitions> 
           </Grid> 
          </TabItem> 
          <TabItem Header="TabItem"> 
           <Grid/> 
          </TabItem> 
          <TabItem Header="TabItem"> 
           <Grid> 
            <Grid.ColumnDefinitions> 
             <ColumnDefinition Width="0.735*"/> 
             <ColumnDefinition Width="0.265*"/> 
            </Grid.ColumnDefinitions> 
           </Grid> 
          </TabItem> 
          <TabItem Header="TabItem"> 
           <Grid/> 
          </TabItem> 
          <TabItem Header="TabItem"> 
           <Grid/> 
          </TabItem> 
         </TabControl> 
         <ProgressBar HorizontalAlignment="Left" Margin="8,0,0,7" VerticalAlignment="Bottom" Width="104.795" Height="19" Grid.Column="1"/> 
        </Grid> 
       </TabItem> 
       <TabItem Header="Oasis Assessments"> 
        Foo 
       </TabItem> 
       <TabItem Header="Plan of Care"> 
        Bar 
       </TabItem> 
       <TabItem Header="Medication Profile"> 
       </TabItem> 
       <TabItem Header="Clinical Notes"> 
       </TabItem> 
       <TabItem Header="Infection Control"> 
       </TabItem> 
       <TabItem Header="Intake Form"> 
       </TabItem> 
      </TabControl.Items> 
     </TabControl> 
    </Grid> 
</Window> 
+0

非常感謝您的快速回復(我非常感謝) – mojotaker 2010-05-17 19:08:52

+0

男人你是一個天才。謝謝。 – mojotaker 2010-05-17 19:37:52

相關問題