2012-02-06 3 views
0

I SelectionChangingという名前のカスタムDependencyPropertyを持つカスタムTabControlがあります。さて、TabItemにアクセスしてアニメーション化したいのですが、アクセスする方法がわかりません。このコードは "tabItem"を見つけることができないという例外をスローしますストーリーボードTargetName WPF

EventTriggerからこの要素 "tabItem"を参照するにはどうすればよいですか?

<DataTemplate x:Key="WorkSpaceTemplate"> 
    <aero:SystemDropShadowChrome> 
     <controls:PinardTabControl IsSynchronizedWithCurrentItem="True" 
        Margin="0" 
        Padding="0" 
        BorderThickness="2" 
        BorderBrush="{StaticResource WorkspaceBorderBrush}" 
        Background="{StaticResource WorkspaceBackgroundBrush}" 
        ItemsSource="{Binding}" SnapsToDevicePixels="True"> 
      <controls:PinardTabControl.Resources> 
       <Style TargetType="{x:Type TabItem}"> 
        <Setter Property="Template" Value="{StaticResource ClosableTabItemTemplate}" /> 
       </Style> 
      </controls:PinardTabControl.Resources> 
      <controls:PinardTabControl.Template> 
       <ControlTemplate TargetType="{x:Type TabControl}"> 
        **<Grid x:Name="tabItem"** 
         ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local"> 
         <Grid.RowDefinitions> 
          <RowDefinition Height="Auto"/> 
          <RowDefinition Height="*"/> 
         </Grid.RowDefinitions> 
         <TabPanel x:Name="HeaderPanel" IsItemsHost="true" Margin="2,2,2,0" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/> 
         <Border x:Name="ContentPanel" CornerRadius="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local"> 
          <ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> 
         </Border> 
        </Grid> 
       </ControlTemplate> 

      </controls:PinardTabControl.Template> 
      <controls:PinardTabControl.Triggers> 
       <EventTrigger RoutedEvent="controls:PinardTabControl.SelectionChanging"> 
        <BeginStoryboard> 
         <Storyboard Name="FormFade"> 
          <DoubleAnimation Name="FormFadeAnimation" 
             **Storyboard.TargetName="tabItem"** 
             Storyboard.TargetProperty="(UIElement.Opacity)" 
             From="0.0" To="1.0" Duration="0:0:0.25" 
             AutoReverse="False" RepeatBehavior="1x" 
            /> 
         </Storyboard> 
        </BeginStoryboard> 
       </EventTrigger> 
      </controls:PinardTabControl.Triggers> 
     </controls:PinardTabControl> 
    </aero:SystemDropShadowChrome> 
</DataTemplate> 

答えて

3

テンプレート内の要素のスコープが異なるため、外側からアクセスすることはできません。おそらく、アニメーション部分をテンプレートにも移動しようとする可能性があります(ControlTemplate.Triggers)。

+0

オハイオ州H.B.、私はそのときその方法を試みます。ありがとうございました! –

+0

あなたは歓迎します、それは(おそらく)助けて嬉しい:) –

関連する問題