This is a migrated thread and some comments may be shown as answers.

Tab Item gets disable but Disable Style Trigger does not get applied

3 Answers 296 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Abdeali
Top achievements
Rank 1
Abdeali asked on 12 Jun 2015, 01:35 PM

Hello,

I am using Telerik TabControl and have several tab items under it. 

Issue : When I set IsTabEnabled = false in VM, it disables the tabitem but does not apply the below style. The trigger seems to be not getting called when TabItem.IsEnabled Property sets to false. Please suggest.

Thanks,

Abdi

TabItem Style: 

<Style x:Key="TabItemStyle" TargetType="{x:Type telerik:RadTabItem}">       
      <Setter Property="Header" Value="{Binding TabName}" />       
      <Setter Property="IsEnabled" Value="{Binding IsTabEnabled}" />
      <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
      <Setter Property="Template">
          <Setter.Value>
              <ControlTemplate TargetType="{x:Type telerik:RadTabItem}">
                  <Grid x:Name="wrapper">
                      <Grid.RowDefinitions>
                          <RowDefinition/>
                          <RowDefinition/>
                      </Grid.RowDefinitions>
                      <Border
                  Name="Border" Grid.Row="0"
                  Margin="0,0,4,0"
                  Background="{StaticResource TabItem_DefaultBackground}"
                  BorderBrush="{StaticResource TabItem_Border}"
                  BorderThickness="1,1,1,1"
                  CornerRadius="2,5,0,0">
                          <ContentPresenter x:Name="ContentSite"
                  VerticalAlignment="Center"
                  HorizontalAlignment="Center"
                  ContentSource="Header"
                  Margin="16,0,16,0"
                  RecognizesAccessKey="True"/>
                          <i:Interaction.Triggers>
                              <i:EventTrigger EventName="PreviewMouseLeftButtonDown">
                                  <cmd:EventToCommand
                                      Command="{Binding DataContext.TabHeaderMouseDownCommand, Mode=OneWay,
                                      RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadTabControl}}}"
                                      PassEventArgsToCommand="True"/>
                              </i:EventTrigger>
                          </i:Interaction.Triggers>
                      </Border>
                      <Rectangle Grid.ZIndex="1" Name="focusVisualStyle" StrokeThickness="1" Stroke="Black" StrokeDashArray="1 2" SnapsToDevicePixels="true" Visibility="Hidden" Margin="0,0,4,0"/>
                      <Border x:Name="OuterBorder" Grid.Row="1" BorderBrush="{StaticResource GenericSelItem_Border_Background}" BorderThickness="0.5,0,0,0.5" />
                  </Grid>
                  <ControlTemplate.Triggers>
                      <Trigger Property="IsSelected" Value="True">
                          <Setter Property="Panel.ZIndex" Value="100" />
                          <Setter TargetName="Border" Property="Background" Value="{StaticResource PMDarkGreen}" />
                          <Setter TargetName="Border" Property="BorderThickness" Value="1" />
                          <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource PMDarkGreen}" />
                          <Setter TargetName="Border" Property="Height" Value="24" />
                          <Setter Property="Foreground" Value="{StaticResource GenericActive_Foreground}" />
                          <Setter Property="FontFamily" Value="Verdana" />
                          <Setter Property="FontSize" Value="11" />
                          <Setter Property="FontWeight" Value="Bold" />
                          <Setter Property="Opacity" Value="30" />
                      </Trigger>
                      <Trigger Property="IsSelected" Value="False">
                          <Setter Property="Foreground" Value="Black" />
                          <Setter Property="FontFamily" Value="Verdana" />
                          <Setter Property="FontSize" Value="11" />
                          <Setter Property="FontWeight" Value="Bold" />
                          <Setter Property="Opacity" Value="30" />
                          <Setter TargetName="Border" Property="Height" Value="24" />
                      </Trigger>
                      <Trigger Property="IsEnabled" Value="False">
                          <Setter TargetName="Border" Property="Background" Value="{StaticResource GenericDisabled_Background}" />
                          <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource GenericSelItem_Border_Background}" />
                          <Setter Property="Foreground" Value="{StaticResource GenericDisabled_Foreground}" />
                          <Setter TargetName="Border" Property="BorderThickness" Value="1" />
                          <Setter Property="Opacity" Value="20" />
                      </Trigger>
                      <Trigger SourceName="Border" Property="IsMouseOver" Value="True">
                          <Setter Property="Foreground" Value="{StaticResource GenericMouseOver_Foreground}" />
                          <Setter TargetName="OuterBorder" Property="Background" Value="{StaticResource GenericMouseOver_BorderBackground}" />
                          <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource GenericMouseOver_BorderBackground}" />
                          <Setter TargetName="Border" Property="Background" Value="{StaticResource GenericMouseOver_BorderBackground}" />
                      </Trigger>
                      <Trigger Property="IsFocused" Value="True">
                          <Setter TargetName="focusVisualStyle" Property="Visibility" Value="Visible"/>
                      </Trigger>
                  </ControlTemplate.Triggers>
              </ControlTemplate>
          </Setter.Value>
      </Setter>
  </Style>

3 Answers, 1 is accepted

Sort by
0
Kiril Vandov
Telerik team
answered on 15 Jun 2015, 12:46 PM
Hello Abdeali,

I have tried to reproduce the issue on our side but with no success. The code you gave us is applied and runs as expected and the trigger is activated. Please note that this issue might be caused if the ViewModels does not notify for their property changed.

I have attached a sample application using the your code-snippet. Simply tun the application and press the button (the second tab should become green). Please take a look and let us know if it works as expected on your side.

Kind regards,
Kiril Vandov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Abdeali
Top achievements
Rank 1
answered on 02 Jul 2015, 02:32 PM

Hello,

Thanks for your reply.

I noticed that the RaisePropertyChange for IsTabEnabled gets called and tab gets disabled but style for disable state (trigger) does not get rendered.

We are actually switching between two views. So we have a legacy (VB 6.0) view and when I switch to .Net View this issue occurs. After that When I click on any other tab in .Net view, the style gets rendered and works fine.

Please suggest what else can be the issue.

Thanks,

Abdi

0
Kiril Vandov
Telerik team
answered on 03 Jul 2015, 07:41 AM
Hello Abdi,

I am not sure that I understand how you are switching between VB 6.0 view and a .Net one. That is why I would like to ask you to provide us with a sample project reproducing the described behavior, and the steps we need to do in order to reproduce it.

Looking forward to hearing from you.

Kind regards,
Kiril Vandov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
TabControl
Asked by
Abdeali
Top achievements
Rank 1
Answers by
Kiril Vandov
Telerik team
Abdeali
Top achievements
Rank 1
Share this question
or