Quantcast
Viewing all articles
Browse latest Browse all 18858

Set TabItem.IsSelected when HeaderTemplate Button is Clicked.

I have the following Style, and want to set the TabItems IsSelected Property to True when the Button is clicked or IsPressed. how can i achieve this?

<Style x:Key="ClosableStyle" TargetType="TabItem"><Setter Property="HeaderTemplate"><Setter.Value><DataTemplate><Grid><Grid.ColumnDefinitions><ColumnDefinition Width="*" /><ColumnDefinition Width="Auto" /></Grid.ColumnDefinitions><ContentControl x:Name="designerContent" 
                                        Content="{Binding Title}" /><Button Grid.Column="1" 
                                Width="16"
                                Name="CloseButton"
                                Height="16"
                                Margin="3 0 0 0"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                VerticalContentAlignment="Center"
                                assets:RoutedEventHelper.EnableRoutedClick="True"
                                Padding="0"><Path x:Name="Path" 
                                  Stretch="Fill" 
                                  StrokeThickness="0.5" 
                                  Stroke="#FF333333" 
                                  Fill="#FF969696" 
                                  Data="F1 M 2.28484e-007,1.33331L 1.33333,0L 4.00001,2.66669L 6.66667,6.10352e-005L 8,1.33331L 5.33334,4L 8,6.66669L 6.66667,8L 4,5.33331L 1.33333,8L 1.086e-007,6.66669L 2.66667,4L 2.28484e-007,1.33331 Z " 
                                  HorizontalAlignment="Stretch" 
                                  VerticalAlignment="Stretch"/></Button></Grid>   </DataTemplate></Setter.Value></Setter><Setter Property="IsSelected" Value="{Binding IsSelected,Mode=TwoWay}"/><Setter Property="ContentTemplate"><Setter.Value><DataTemplate><Grid><ContentControl Content="{Binding Content}" 
                                        HorizontalAlignment="Stretch" 
                                        VerticalAlignment="Stretch"/></Grid></DataTemplate></Setter.Value></Setter></Style>


Viewing all articles
Browse latest Browse all 18858

Trending Articles