views:

41

answers:

1

Can someone tell me how to code an event to command in a style for a tabitem? I have no problems using it elsewhere but I can not figure it out for a style.

I am trying to do this in Xaml for WPF using MVVM-Light toolkit.

Here is an example of what I am trying to do:

<DataTemplate x:Key="WorkspacesTemplate">
        <igWindows:XamTabControl
          AllowTabClosing="True" 
          IsSynchronizedWithCurrentItem="True" 
          ItemsSource="{Binding}" TabItemCloseButtonVisibility="Visible" 
          Margin="4"
          Theme="Office2k7Black" >
            <igWindows:XamTabControl.Resources>
                <Style TargetType="{x:Type igWindows:TabItemEx}" 
                       BasedOn="{StaticResource {x:Type igWindows:TabItemEx}}" >
                    <Setter Property="Header" Value="{Binding Path=DisplayName}" />
                    <Style.Triggers>
                        <i:EventTrigger  >
                            <cmd:EventToCommand Command="{Binding Path=CloseCommand}"  />
                        </i:EventTrigger>
                    </Style.Triggers>
                </Style>
            </igWindows:XamTabControl.Resources>
        </igWindows:XamTabControl>
    </DataTemplate>

I am using an infragistics TabControl but it shouldnt be much different than a regular tab control.

A: 

In your example, you don't have an EventName attribute in the EventTrigger element. You need to specify an event on the tab that you want to trigger the command.

Matt Casto