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

RadTabControl - value does not fall within the expected range

17 Answers 371 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Murugesan Loganathan
Top achievements
Rank 1
Murugesan Loganathan asked on 15 Mar 2010, 10:45 AM
We are using RadTabControl and RadTabItems are rendered at the runtime by using RadTabcontrol's Itemsource property.

The radtabitems are rendering properly, but its showing error message "value does not fall within the expected range" when selecting the tabitem and if the scrollbar is displayed to scroll the tab items.

If the scrollbar is not displayed, the error message does not show up.

Any workaround to resolve the error is very much appreciated.

17 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 17 Mar 2010, 02:49 PM
Hi Murugesan,

Unfortunately I was not able to reproduce the issue. Is it possible to send us a small project showing the problem. If attaching a project is not an option, could you please paste us code snippets reproducing the issue. I'd be glad to further assist you.

Regards,
Kiril Stanoev
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Praveen
Top achievements
Rank 1
answered on 25 Apr 2010, 09:37 AM
We are also getting the same error "value does not fall within the expected range"

Any resolution for this? Below is the error details

 

at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)\r\n at MS.Internal.XcpImports.MethodPack(IntPtr objectPtr, String methodName, Object[] rawData)\r\n at MS.Internal.XcpImports.UIElement_TransformToVisual(UIElement element, UIElement visual)\r\n at System.Windows.UIElement.TransformToVisual(UIElement visual)\r\n at Telerik.Windows.Controls.RadTabControl.CalculateContainerHorizontalVisibility(FrameworkElement container)\r\n at Telerik.Windows.Controls.RadTabControl.CalculateContainerDirectionalVisibility(FrameworkElement container)\r\n at Telerik.Windows.Controls.RadTabControl.ScrollIntoView(Object item)\r\n at Telerik.Windows.Controls.RadTabControl.OnSelectionChanged(IList removedItems, IList addedItems)\r\n at Telerik.Windows.Controls.RadTabControl.OnSelectionChanged(Object sender, SelectionChangedEventArgs e)\r\n at Telerik.Windows.Controls.SelectionChanger`1.InvokeSelectionChangedEvent(SelectionChangedEventArgs e)\r\n at Telerik.Windows.Controls.SelectionCha

nger`1.End()\r\n at Telerik.Windows.Controls.SelectionChanger`1.AddJustThis(T item)\r\n at Telerik.Windows.Controls.RadTabControl.OnSelectedIndexChanged(Int32 oldIndex, Int32 newIndex)\r\n at Telerik.Windows.Controls.RadTabControl.OnSelectedIndexChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)\r\n at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)\r\n at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object newValue, Object oldValue)\r\n at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle, PropertyInvalidationReason reason)\r\n at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)\r\n at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)\r\n at Telerik.Windows.Controls.RadTabControl.set_SelectedIndex(Int32 value)\r\n at Telerik.Windows.Controls.RadTabControl.NotifyChildIsSelectedChanged(RadTabItem child)\r\n at Telerik.Windows.Controls.RadTabItem.OnIsSelectedChanged(Boolean oldValue, Boolean newValue)\r\n at Telerik.Windows.Controls.RadTabItem.OnIsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)\r\n at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)\r\n at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle, PropertyInvalidationReason reason)\r\n at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)\r\n at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)\r\n at Telerik.Windows.Controls.RadTabItem.set_IsSelected(Boolean value)\r\n at Telerik.Windows.Controls.RadTabItem.OnHeaderMouseLeftButtonDown(Object sender, MouseButtonEventArgs e)\r\n at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)\r\n at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)"

0
Kiril Stanoev
Telerik team
answered on 28 Apr 2010, 04:03 PM
Hello Praveen,

Do you use a TabItem in the ItemTemplate of the TabControl? Something like this:

<telerikNavigation:RadTabControl>
    <telerikNavigation:RadTabControl.ItemTemplate>
        <DataTemplate>
            <telerikNavigation:RadTabItem Header="{Binding SomeProperty}" />
        </DataTemplate>
    </telerikNavigation:RadTabControl.ItemTemplate>
</telerikNavigation:RadTabControl>

If that is the case, then this is a possible cause for the issue. Instead of a TabItem, you need to use just a ContentPresenter:

<telerikNavigation:RadTabControl>
    <telerikNavigation:RadTabControl.ItemTemplate>
        <DataTemplate>
            <ContentPresenter Content="{Binding SomeProperty}" />
        </DataTemplate>
    </telerikNavigation:RadTabControl.ItemTemplate>
</telerikNavigation:RadTabControl>

If this does not help, could you please elaborate a little bit more on you scenario and the implementation. Also, it would be great if you can attach a sample project demonstrating the issue. This way, we will be better able to assist you.

Greetings,
Kiril Stanoev
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Praveen
Top achievements
Rank 1
answered on 03 May 2010, 04:43 AM
As the code is dynamic we have changed the code. It worked fine

From
 tabControl.ContentTemplate =  DynamicDataTemplate;
 tabControl.ItemTemplate = DynamicDataTemplate;
  
 Changed to
   
  tabControl.SelectedContentTemplate = DynamicDataTemplate;
  tabitem.Content = DynamicDataTemplate;

Thanks

 

0
Kakone
Top achievements
Rank 1
answered on 08 May 2010, 10:14 PM
Hello,

I have the same exception (I send a Bug Report with a test program). I have a TabControl like this :
<telerikNavigation:RadTabControl ItemsSource="{Binding Items}" DisplayMemberPath="Title">  
  <telerikNavigation:RadTabControl.ContentTemplate>  
    <DataTemplate>  
      <ContentPresenter Content="{Binding UserControl}" />  
    </DataTemplate> 
  </telerikNavigation:RadTabControl.ContentTemplate>  
</telerikNavigation:RadTabControl>

My ViewModel class is very simple (MyUserControl class is just a UserControl with a TextBlock) :
public class ViewModel  
{  
  public ViewModel()  
  {  
    Items = new ObservableCollection<TabItemContent>();  
    Items.Add(new TabItemContent("TabPage n°1"new MyUserControl("Click on tabPage n°2, then click on tabPage n°1")));  
    Items.Add(new TabItemContent("TabPage n°2"new MyUserControl("Now, click on tabPage n°1")));  
  }  
  
  public ObservableCollection<TabItemContent> Items 
  {  
    get;  
    private set;  
  }  
}

and this is the TabItemContent class :
public class TabItemContent  
{  
  public TabItemContent(string title, UIElement userControl)  
  {  
    Title = title;  
    UserControl = userControl;  
  }  
 
  public string Title  
  {  
    get;  
    private set;  
  }  
  
  public UIElement UserControl  
  {  
    get;  
    private set;  
  }  

When I show the TabControl and I click on the TabItem n°2, then I come back to the TabItem n°1, I've got the exception : Value does not fall within the expected range

Cordially,
Stephane.
0
Tina Stancheva
Telerik team
answered on 12 May 2010, 01:14 PM
Hello Stéphane Mitermite,

The cause for your issue is that the UserControl is already a child of another element so you will need to change the TabItemContent class in order to ensure that the UserControl property doesn't have more than one parent:

public class TabItemContent
{
   private FrameworkElement control;
   public TabItemContent(string title, UIElement userControl)
   {
       Title = title;
       control = (FrameworkElement)userControl;
   }
 
 
   public string Title
   {
       get;
       private set;
   }
 
   public UIElement UserControl
   {
    get
    {
        if (control.Parent != null)
        {
            (control.Parent as UserControl).Content = null;
        }
        return control;
    }
    private set
    {
        this.control = (FrameworkElement)value;
 
    }
 
    }
}

We modified the project you sent with the BugReport and attached it there. Please give it a try and let us know if we can further assist you.


Regards,
Tina Stancheva
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Kakone
Top achievements
Rank 1
answered on 12 May 2010, 02:39 PM
Thanks,

This workaround works well in my project.

Cordially,
Stephane.
0
Lauren
Top achievements
Rank 1
answered on 20 Aug 2010, 10:40 PM
Hi,

It seems i have a similar issue.

I have a tab control and tab items are added at runtime.
There is no problem adding tab item as long as there is no need for the scrollbar.
Once the scrollbar shows, for the next item i want to add, i have the same Exception "Value does not fall within the expected range."

I can't figure out why,

--- RadTabControl is created in code-behind:

 

 

RadTabControl childTabs = new RadTabControl() { Background = new SolidColorBrush(Colors.Transparent),

 

BackgroundVisibility = System.Windows.

 

Visibility.Collapsed };

--- as well as the RadTabItem:

 

 

 

RadTabItem item = new RadTabItem();

 

item.HeaderTemplate =

 

this.Resources["headerTemplateClosable"] as DataTemplate;

 

item.Style =

 

this.Resources["RadTabItemStyle"] as Style;

 

item.Header = "tab";

item.IsSelected =

 

true;

 

item.Content = ScrollViewer;

--- HeaderTemplate ---

 

 

 

 

<DataTemplate x:Key="headerTemplateClosable">

 

 

 

 

 

 

 

 

 

<Grid>

 

 

 

 

 

 

 

 

 

<Grid.ColumnDefinitions>

 

 

 

 

 

 

 

 

 

<ColumnDefinition Width="1*" />

 

 

 

 

 

 

 

 

 

<ColumnDefinition Width="9*" />

 

 

 

 

 

 

 

 

 

</Grid.ColumnDefinitions>

 

 

 

 

 

 

 

 

 

<TextBlock Text="{Binding}" Grid.Column="1"/>

 

 

 

 

<Button x:Name="btnClose"

 

 

 

Grid.Column="0"

 

 

 

 

 

 

 

 

Visibility="Visible"

 

 

 

 

 

 

 

 

HorizontalAlignment="Right"

 

 

 

 

 

 

 

 

Margin="2,0,0,0"

 

 

 

 

 

 

 

 

Click="CloseTabButton_Click"

 

 

 

 

 

 

 

 

Background="Red"

 

 

 

 

 

 

 

 

BorderBrush="Transparent"

 

 

 

 

 

 

 

 

ToolTipService.ToolTip="Close Tab">

 

 

 

 

 

 

 

 

 

<Button.Content>

 

 

 

 

 

 

 

 

 

<Image Source="images/navigate_cross.png" Stretch="None"></Image>

 

 

 

 

 

 

 

 

 

</Button.Content>

 

 

 

 

 

 

 

 

 

</Button>

 

 

 

 

 

 

 

 

 

</Grid>

 

 

 

 

 

 

 

 

 

</DataTemplate>

 

--- Style ---

 

 

 

 

<Thickness x:Key="TabItem_OuterBorderThickness">1 1 1 0</Thickness>

 

 

 

 

 

 

 

 

 

<SolidColorBrush x:Key="ControlForeground_Normal" Color="#FF000000" />

 

 

 

 

 

 

 

 

 

<SolidColorBrush x:Key="TabItem_Background_Normal" Color="Transparent" />

 

 

 

 

 

 

 

 

 

<SolidColorBrush x:Key="TabItem_OuterBorder_Normal" Color="Transparent" />

 

 

 

 

 

 

 

 

 

<SolidColorBrush x:Key="TabItem_InnerBorder_Normal" Color="Transparent" />

 

 

 

 

 

 

 

 

 

<Thickness x:Key="TabItem_InnerBorderThickness">1 1 1 0</Thickness>

 

 

 

 

 

 

 

 

 

<CornerRadius x:Key="TabItem_InnerCornerRadius">2 2 0 0</CornerRadius>

 

 

 

 

 

 

 

 

 

<CornerRadius x:Key="TabItem_OuterCornerRadius">3 3 0 0</CornerRadius>

 

 

 

 

 

 

 

 

 

<Thickness x:Key="TabItem_Margin">0 2 0 0</Thickness>

 

 

 

 

 

 

 

 

 

<SolidColorBrush x:Key="TabItem_OuterBorder_MouseOver" Color="#FF848484" />

 

 

 

 

 

 

 

 

 

<LinearGradientBrush x:Key="TabItem_Background_MouseOver" EndPoint="0.5,1" StartPoint="0.5,0">

 

 

 

 

 

 

 

 

 

<GradientStop Color="#FFFFFBA3" Offset="1" />

 

 

 

 

 

 

 

 

 

<GradientStop Color="#FFFFFBDA" />

 

 

 

 

 

 

 

 

 

</LinearGradientBrush>

 

 

 

 

 

 

 

 

 

<SolidColorBrush x:Key="TabItem_InnerBorder_MouseOver" Color="#FFFFFFFF" />

 

 

 

 

 

 

 

 

 

<SolidColorBrush x:Key="TabItem_OuterBorder_Selected" Color="#FF848484" />

 

 

 

 

 

 

 

 

 

<LinearGradientBrush x:Key="TabItem_Background_Selected" EndPoint="0.5,1" StartPoint="0.5,0">

 

 

 

 

 

 

 

 

 

<GradientStop Color="White" />

 

 

 

 

 

 

 

 

 

<GradientStop Color="#FFFAFAFA" Offset="1" />

 

 

 

 

 

 

 

 

 

</LinearGradientBrush>

 

 

 

 

 

 

 

 

 

<SolidColorBrush x:Key="TabItem_InnerBorder_Selected" Color="#FFFFFFFF" />

 

 

 

 

 

 

 

 

 

<Thickness x:Key="TabItem_Margin_Selected">0</Thickness>

 

 

 

 

 

 

 

 

 

<SolidColorBrush x:Key="TabItem_OuterBorder_SelectedMouseOver" Color="#FFFFC92B"/>

 

 

 

 

<!--RadTabItem ControlTemplate-->

 

 

 

 

 

 

 

 

 

<ControlTemplate x:Key="TabItemTemplate" TargetType="telerikNavigation:RadTabItem">

 

 

 

 

 

 

 

 

 

<Grid x:Name="wrapper">

 

 

 

 

 

 

 

 

 

<VisualStateManager.VisualStateGroups>

 

 

 

 

 

 

 

 

 

<VisualStateGroup x:Name="CommonStateGroup">

 

 

 

 

 

 

 

 

 

<VisualState x:Name="MouseOver">

 

 

 

 

 

 

 

 

 

<Storyboard>

 

 

 

 

 

 

 

 

 

<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)"

 

 

 

 

 

 

 

 

Storyboard.TargetName="MouseOverVisual" />

 

 

 

 

 

 

 

 

 

<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="FontWeight"

 

 

 

 

 

 

 

 

Storyboard.TargetName="HeaderElement">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame KeyTime="0" Value="Bold" />

 

 

 

 

 

 

 

 

 

</ObjectAnimationUsingKeyFrames>

 

 

 

 

 

 

 

 

 

<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Foreground"

 

 

 

 

 

 

 

 

Storyboard.TargetName="HeaderElement">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame KeyTime="0" Value="Black" />

 

 

 

 

 

 

 

 

 

</ObjectAnimationUsingKeyFrames>

 

 

 

 

 

 

 

 

 

</Storyboard>

 

 

 

 

 

 

 

 

 

</VisualState>

 

 

 

 

 

 

 

 

 

<VisualState x:Name="Normal" />

 

 

 

 

 

 

 

 

 

<!--Selected VisualState-->

 

 

 

 

 

 

 

 

 

<VisualState x:Name="Selected">

 

 

 

 

 

 

 

 

 

<Storyboard>

 

 

 

 

 

 

 

 

 

<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)"

 

 

 

 

 

 

 

 

Storyboard.TargetName="SelectionVisual" />

 

 

 

 

 

 

 

 

 

<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)"

 

 

 

 

 

 

 

 

Storyboard.TargetName="MouseOverVisual" />

 

 

 

 

 

 

 

 

 

<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="FontWeight"

 

 

 

 

 

 

 

 

Storyboard.TargetName="HeaderElement">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame KeyTime="0" Value="Bold" />

 

 

 

 

 

 

 

 

 

</ObjectAnimationUsingKeyFrames>

 

 

 

 

 

 

 

 

 

<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Foreground"

 

 

 

 

 

 

 

 

Storyboard.TargetName="HeaderElement">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame KeyTime="0" Value="Black" />

 

 

 

 

 

 

 

 

 

</ObjectAnimationUsingKeyFrames>

 

 

 

 

 

 

 

 

 

</Storyboard>

 

 

 

 

 

 

 

 

 

</VisualState>

 

 

 

 

 

 

 

 

 

<!--Selected VisualState-->

 

 

 

 

 

 

 

 

 

<!--SelectedMouseOver VisualState-->

 

 

 

 

 

 

 

 

 

<VisualState x:Name="SelectedMouseOver">

 

 

 

 

 

 

 

 

 

<Storyboard>

 

 

 

 

 

 

 

 

 

<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)"

 

 

 

 

 

 

 

 

Storyboard.TargetName="MouseOverVisual" />

 

 

 

 

 

 

 

 

 

<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)"

 

 

 

 

 

 

 

 

Storyboard.TargetName="SelectionVisual" />

 

 

 

 

 

 

 

 

 

<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="BorderBrush"

 

 

 

 

 

 

 

 

Storyboard.TargetName="SelectionVisual">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame KeyTime="0"

 

 

 

 

 

 

 

 

Value="{StaticResource TabItem_OuterBorder_SelectedMouseOver}" />

 

 

 

 

 

 

 

 

 

</ObjectAnimationUsingKeyFrames>

 

 

 

 

 

 

 

 

 

<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="FontWeight"

 

 

 

 

 

 

 

 

Storyboard.TargetName="HeaderElement">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame KeyTime="0" Value="Bold" />

 

 

 

 

 

 

 

 

 

</ObjectAnimationUsingKeyFrames>

 

 

 

 

 

 

 

 

 

<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Foreground"

 

 

 

 

 

 

 

 

Storyboard.TargetName="HeaderElement">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame KeyTime="0" Value="Black" />

 

 

 

 

 

 

 

 

 

</ObjectAnimationUsingKeyFrames>

 

 

 

 

 

 

 

 

 

</Storyboard>

 

 

 

 

 

 

 

 

 

</VisualState>

 

 

 

 

 

 

 

 

 

<!--SelectedMouseOver VisualState-->

 

 

 

 

 

 

 

 

 

<VisualState x:Name="Disabled">

 

 

 

 

 

 

 

 

 

<Storyboard>

 

 

 

 

 

 

 

 

 

<DoubleAnimation Duration="0:0:0.1" To="0.3" Storyboard.TargetProperty="Opacity"

 

 

 

 

 

 

 

 

Storyboard.TargetName="HeaderElement" />

 

 

 

 

 

 

 

 

 

<DoubleAnimation Duration="0:0:0.1" To="0" Storyboard.TargetProperty="Opacity"

 

 

 

 

 

 

 

 

Storyboard.TargetName="NormalVisual" />

 

 

 

 

 

 

 

 

 

</Storyboard>

 

 

 

 

 

 

 

 

 

</VisualState>

 

 

 

 

 

 

 

 

 

</VisualStateGroup>

 

 

 

 

 

 

 

 

 

<VisualStateGroup x:Name="PlacementStates">

 

 

 

 

 

 

 

 

 

<VisualState x:Name="HorizontalTop" />

 

 

 

 

 

 

 

 

 

<VisualState x:Name="HorizontalLeft">

 

 

 

 

 

 

 

 

 

<Storyboard>

 

 

 

 

 

 

 

 

 

<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="LayoutTransform"

 

 

 

 

 

 

 

 

Storyboard.TargetName="OrientationTransform">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame KeyTime="0">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame.Value>

 

 

 

 

 

 

 

 

 

<RotateTransform Angle="180" />

 

 

 

 

 

 

 

 

 

</DiscreteObjectKeyFrame.Value>

 

 

 

 

 

 

 

 

 

</DiscreteObjectKeyFrame>

 

 

 

 

 

 

 

 

 

</ObjectAnimationUsingKeyFrames>

 

 

 

 

 

 

 

 

 

</Storyboard>

 

 

 

 

 

 

 

 

 

</VisualState>

 

 

 

 

 

 

 

 

 

<VisualState x:Name="HorizontalRight" />

 

 

 

 

 

 

 

 

 

<VisualState x:Name="HorizontalBottom">

 

 

 

 

 

 

 

 

 

<Storyboard>

 

 

 

 

 

 

 

 

 

<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="LayoutTransform"

 

 

 

 

 

 

 

 

Storyboard.TargetName="OrientationTransform">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame KeyTime="0">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame.Value>

 

 

 

 

 

 

 

 

 

<RotateTransform Angle="180" />

 

 

 

 

 

 

 

 

 

</DiscreteObjectKeyFrame.Value>

 

 

 

 

 

 

 

 

 

</DiscreteObjectKeyFrame>

 

 

 

 

 

 

 

 

 

</ObjectAnimationUsingKeyFrames>

 

 

 

 

 

 

 

 

 

</Storyboard>

 

 

 

 

 

 

 

 

 

</VisualState>

 

 

 

 

 

 

 

 

 

<VisualState x:Name="VerticalTop">

 

 

 

 

 

 

 

 

 

<Storyboard>

 

 

 

 

 

 

 

 

 

<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="LayoutTransform"

 

 

 

 

 

 

 

 

Storyboard.TargetName="OrientationTransform">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame KeyTime="0">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame.Value>

 

 

 

 

 

 

 

 

 

<RotateTransform Angle="-90" />

 

 

 

 

 

 

 

 

 

</DiscreteObjectKeyFrame.Value>

 

 

 

 

 

 

 

 

 

</DiscreteObjectKeyFrame>

 

 

 

 

 

 

 

 

 

</ObjectAnimationUsingKeyFrames>

 

 

 

 

 

 

 

 

 

</Storyboard>

 

 

 

 

 

 

 

 

 

</VisualState>

 

 

 

 

 

 

 

 

 

<VisualState x:Name="VerticalLeft">

 

 

 

 

 

 

 

 

 

<Storyboard>

 

 

 

 

 

 

 

 

 

<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="LayoutTransform"

 

 

 

 

 

 

 

 

Storyboard.TargetName="OrientationTransform">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame KeyTime="0">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame.Value>

 

 

 

 

 

 

 

 

 

<RotateTransform Angle="90" />

 

 

 

 

 

 

 

 

 

</DiscreteObjectKeyFrame.Value>

 

 

 

 

 

 

 

 

 

</DiscreteObjectKeyFrame>

 

 

 

 

 

 

 

 

 

</ObjectAnimationUsingKeyFrames>

 

 

 

 

 

 

 

 

 

</Storyboard>

 

 

 

 

 

 

 

 

 

</VisualState>

 

 

 

 

 

 

 

 

 

<VisualState x:Name="VerticalRight">

 

 

 

 

 

 

 

 

 

<Storyboard>

 

 

 

 

 

 

 

 

 

<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="LayoutTransform"

 

 

 

 

 

 

 

 

Storyboard.TargetName="OrientationTransform">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame KeyTime="0">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame.Value>

 

 

 

 

 

 

 

 

 

<RotateTransform Angle="-90" />

 

 

 

 

 

 

 

 

 

</DiscreteObjectKeyFrame.Value>

 

 

 

 

 

 

 

 

 

</DiscreteObjectKeyFrame>

 

 

 

 

 

 

 

 

 

</ObjectAnimationUsingKeyFrames>

 

 

 

 

 

 

 

 

 

</Storyboard>

 

 

 

 

 

 

 

 

 

</VisualState>

 

 

 

 

 

 

 

 

 

<VisualState x:Name="VerticalBottom">

 

 

 

 

 

 

 

 

 

<Storyboard>

 

 

 

 

 

 

 

 

 

<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="LayoutTransform"

 

 

 

 

 

 

 

 

Storyboard.TargetName="OrientationTransform">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame KeyTime="0">

 

 

 

 

 

 

 

 

 

<DiscreteObjectKeyFrame.Value>

 

 

 

 

 

 

 

 

 

<RotateTransform Angle="-90" />

 

 

 

 

 

 

 

 

 

</DiscreteObjectKeyFrame.Value>

 

 

 

 

 

 

 

 

 

</DiscreteObjectKeyFrame>

 

 

 

 

 

 

 

 

 

</ObjectAnimationUsingKeyFrames>

 

 

 

 

 

 

 

 

 

</Storyboard>

 

 

 

 

 

 

 

 

 

</VisualState>

 

 

 

 

 

 

 

 

 

</VisualStateGroup>

 

 

 

 

 

 

 

 

 

<VisualStateGroup x:Name="FocusStates">

 

 

 

 

 

 

 

 

 

<VisualState x:Name="Unfocused" />

 

 

 

 

 

 

 

 

 

<VisualState x:Name="Focused" />

 

 

 

 

 

 

 

 

 

</VisualStateGroup>

 

 

 

 

 

 

 

 

 

</VisualStateManager.VisualStateGroups>

 

 

 

 

 

 

 

 

 

<Border x:Name="NormalVisual" BorderBrush="{TemplateBinding BorderBrush}"

 

 

 

 

 

 

 

 

BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"

 

 

 

 

 

 

 

 

CornerRadius="{StaticResource TabItem_OuterCornerRadius}"

 

 

 

 

 

 

 

 

Margin="{StaticResource TabItem_Margin}">

 

 

 

 

 

 

 

 

 

<Border BorderBrush="{StaticResource TabItem_InnerBorder_Normal}"

 

 

 

 

 

 

 

 

BorderThickness="{StaticResource TabItem_InnerBorderThickness}"

 

 

 

 

 

 

 

 

CornerRadius="{StaticResource TabItem_InnerCornerRadius}" />

 

 

 

 

 

 

 

 

 

</Border>

 

 

 

 

 

 

 

 

 

<Border x:Name="MouseOverVisual" BorderBrush="{StaticResource TabItem_OuterBorder_MouseOver}"

 

 

 

 

 

 

 

 

BorderThickness="{StaticResource TabItem_OuterBorderThickness}"

 

 

 

 

 

 

 

 

Background="{StaticResource TabItem_Background_MouseOver}"

 

 

 

 

 

 

 

 

CornerRadius="{StaticResource TabItem_OuterCornerRadius}"

 

 

 

 

 

 

 

 

Margin="{StaticResource TabItem_Margin}" Opacity="0">

 

 

 

 

 

 

 

 

 

<Border BorderBrush="{StaticResource TabItem_InnerBorder_MouseOver}"

 

 

 

 

 

 

 

 

BorderThickness="{StaticResource TabItem_InnerBorderThickness}"

 

 

 

 

 

 

 

 

CornerRadius="{StaticResource TabItem_InnerCornerRadius}" />

 

 

 

 

 

 

 

 

 

</Border>

 

 

 

 

 

 

 

 

 

<Border x:Name="SelectionVisual" BorderBrush="{StaticResource TabItem_OuterBorder_Selected}"

 

 

 

 

 

 

 

 

BorderThickness="{StaticResource TabItem_OuterBorderThickness}"

 

 

 

 

 

 

 

 

Background="{StaticResource TabItem_Background_Selected}"

 

 

 

 

 

 

 

 

CornerRadius="{StaticResource TabItem_OuterCornerRadius}"

 

 

 

 

 

 

 

 

Margin="{StaticResource TabItem_Margin_Selected}" Opacity="0">

 

 

 

 

 

 

 

 

 

<Border BorderBrush="{StaticResource TabItem_InnerBorder_Selected}"

 

 

 

 

 

 

 

 

BorderThickness="{StaticResource TabItem_InnerBorderThickness}"

 

 

 

 

 

 

 

 

CornerRadius="{StaticResource TabItem_InnerCornerRadius}" />

 

 

 

 

 

 

 

 

 

</Border>

 

 

 

 

 

 

 

 

 

<Telerik_Windows_Controls_Primitives:LayoutTransformControl x:Name="OrientationTransform">

 

 

 

 

 

 

 

 

 

<!--HeaderElement-->

 

 

 

 

 

 

 

 

 

<ContentControl x:Name="HeaderElement" Content="{TemplateBinding Header}"

 

 

 

 

 

 

 

 

ContentTemplate="{TemplateBinding HeaderTemplate}"

 

 

 

 

 

 

 

 

HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"

 

 

 

 

 

 

 

 

Margin="{TemplateBinding Padding}" Foreground="White"

 

 

 

 

 

 

 

 

VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />

 

 

 

 

 

 

 

 

 

<!--HeaderElement-->

 

 

 

 

 

 

 

 

 

</Telerik_Windows_Controls_Primitives:LayoutTransformControl>

 

 

 

 

 

 

 

 

 

</Grid>

 

 

 

 

 

 

 

 

 

</ControlTemplate>

 

 

 

 

 

 

 

 

 

<!--RadTabItem ControlTemplate-->

 

 

 

 

 

 

 

 

 

<!--RadTabItemStyle-->

 

 

 

 

 

 

 

 

 

<Style x:Key="RadTabItemStyle" TargetType="telerikNavigation:RadTabItem">

 

 

 

 

 

 

 

 

 

<Setter Property="MinWidth" Value="5" />

 

 

 

 

 

 

 

 

 

<Setter Property="BorderThickness" Value="{StaticResource TabItem_OuterBorderThickness}" />

 

 

 

 

 

 

 

 

 

<Setter Property="Foreground" Value="{StaticResource ControlForeground_Normal}" />

 

 

 

 

 

 

 

 

 

<Setter Property="MinHeight" Value="5" />

 

 

 

 

 

 

 

 

 

<Setter Property="Background" Value="{StaticResource TabItem_Background_Normal}" />

 

 

 

 

 

 

 

 

 

<Setter Property="BorderBrush" Value="{StaticResource TabItem_OuterBorder_Normal}" />

 

 

 

 

 

 

 

 

 

<Setter Property="HorizontalContentAlignment" Value="Center" />

 

 

 

 

 

 

 

 

 

<Setter Property="VerticalContentAlignment" Value="Center" />

 

 

 

 

 

 

 

 

 

<Setter Property="Padding" Value="6 3" />

 

 

 

 

 

 

 

 

 

<Setter Property="IsTabStop" Value="False" />

 

 

 

 

 

 

 

 

 

<Setter Property="Template" Value="{StaticResource TabItemTemplate}" />

 

 

 

 

 

 

 

 

 

</Style>

 

 

 

 

 

 

 

 

 

<!--RadTabItemStyle-->

 

Any idea what could cause the exception ?
Thanks

 

 

 

 

 

 

 

 

 

0
Lauren
Top achievements
Rank 1
answered on 20 Aug 2010, 10:42 PM
Hi,

It seems i have a similar issue.

I have a tab control and tab items are added at runtime.
There is no problem adding tab item as long as there is no need for the scrollbar.
Once the scrollbar shows, for the next item i want to add, i have the same Exception "Value does not fall within the expected range."

I can't figure out why,

--- RadTabControl is created in code-behind:

 

RadTabControl childTabs = new RadTabControl() { Background = new SolidColorBrush(Colors.Transparent), 
BackgroundVisibility = System.Windows.
Visibility.Collapsed };

 


--- as well as the RadTabItem:
 

 

 

RadTabItem item = new RadTabItem(); 
item.HeaderTemplate = this.Resources["headerTemplateClosable"] as DataTemplate; 
item.Style = this.Resources["RadTabItemStyle"] as Style;
item.Header = "tab";
item.IsSelected = true;
item.Content = ScrollViewer;

--- HeaderTemplate ---

<DataTemplate x:Key="headerTemplateClosable">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*" />
            <ColumnDefinition Width="9*" />
        </Grid.ColumnDefinitions>
        <TextBlock Text="{Binding}" Grid.Column="1"/>
                <Button x:Name="btnClose" 
                        Grid.Column="0"
                            Visibility="Visible"
                            HorizontalAlignment="Right"
                            Margin="2,0,0,0"
                            Click="CloseTabButton_Click"
                            Background="Red"
                            BorderBrush="Transparent"
                            ToolTipService.ToolTip="Close Tab">
            <Button.Content>
                <Image Source="images/navigate_cross.png" Stretch="None"></Image>
            </Button.Content>
        </Button>
    </Grid>
</DataTemplate>

 

 

 

--- Style ---

 

<Thickness x:Key="TabItem_OuterBorderThickness">1 1 1 0</Thickness>
 <SolidColorBrush x:Key="ControlForeground_Normal" Color="#FF000000" />
 <SolidColorBrush x:Key="TabItem_Background_Normal" Color="Transparent" />
 <SolidColorBrush x:Key="TabItem_OuterBorder_Normal" Color="Transparent" />
 <SolidColorBrush x:Key="TabItem_InnerBorder_Normal" Color="Transparent" />
 <Thickness x:Key="TabItem_InnerBorderThickness">1 1 1 0</Thickness>
 <CornerRadius x:Key="TabItem_InnerCornerRadius">2 2 0 0</CornerRadius>
 <CornerRadius x:Key="TabItem_OuterCornerRadius">3 3 0 0</CornerRadius>
 <Thickness x:Key="TabItem_Margin">0 2 0 0</Thickness>
 <SolidColorBrush x:Key="TabItem_OuterBorder_MouseOver" Color="#FF848484" />
 <LinearGradientBrush x:Key="TabItem_Background_MouseOver" EndPoint="0.5,1" StartPoint="0.5,0">
     <GradientStop Color="#FFFFFBA3" Offset="1" />
     <GradientStop Color="#FFFFFBDA" />
 </LinearGradientBrush>
 <SolidColorBrush x:Key="TabItem_InnerBorder_MouseOver" Color="#FFFFFFFF" />
 <SolidColorBrush x:Key="TabItem_OuterBorder_Selected" Color="#FF848484" />
 <LinearGradientBrush x:Key="TabItem_Background_Selected" EndPoint="0.5,1" StartPoint="0.5,0">
     <GradientStop Color="White" />
     <GradientStop Color="#FFFAFAFA" Offset="1" />
 </LinearGradientBrush>
 <SolidColorBrush x:Key="TabItem_InnerBorder_Selected" Color="#FFFFFFFF" />
 <Thickness x:Key="TabItem_Margin_Selected">0</Thickness>
 <SolidColorBrush x:Key="TabItem_OuterBorder_SelectedMouseOver" Color="#FFFFC92B"/>
<!--RadTabItem ControlTemplate-->
        <ControlTemplate x:Key="TabItemTemplate" TargetType="telerikNavigation:RadTabItem">
            <Grid x:Name="wrapper">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStateGroup">
                        <VisualState x:Name="MouseOver">
                            <Storyboard>
                                <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)"
                                        Storyboard.TargetName="MouseOverVisual" />
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="FontWeight"
                                        Storyboard.TargetName="HeaderElement">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="Bold" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Foreground"
                                        Storyboard.TargetName="HeaderElement">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="Black" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Normal" />
  
                        <!--Selected VisualState-->
                        <VisualState x:Name="Selected">
                            <Storyboard>
                                <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)"
                                        Storyboard.TargetName="SelectionVisual" />
                                <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)"
                                        Storyboard.TargetName="MouseOverVisual" />
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="FontWeight"
                                        Storyboard.TargetName="HeaderElement">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="Bold" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Foreground"
                                        Storyboard.TargetName="HeaderElement">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="Black" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <!--Selected VisualState-->
  
                        <!--SelectedMouseOver VisualState-->
                        <VisualState x:Name="SelectedMouseOver">
                            <Storyboard>
                                <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)"
                                        Storyboard.TargetName="MouseOverVisual" />
                                <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)"
                                        Storyboard.TargetName="SelectionVisual" />
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="BorderBrush"
                                        Storyboard.TargetName="SelectionVisual">
                                    <DiscreteObjectKeyFrame KeyTime="0"
                                            Value="{StaticResource TabItem_OuterBorder_SelectedMouseOver}" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="FontWeight"
                                        Storyboard.TargetName="HeaderElement">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="Bold" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Foreground"
                                        Storyboard.TargetName="HeaderElement">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="Black" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <!--SelectedMouseOver VisualState-->
  
                        <VisualState x:Name="Disabled">
                            <Storyboard>
                                <DoubleAnimation Duration="0:0:0.1" To="0.3" Storyboard.TargetProperty="Opacity"
                                        Storyboard.TargetName="HeaderElement" />
                                <DoubleAnimation Duration="0:0:0.1" To="0" Storyboard.TargetProperty="Opacity"
                                        Storyboard.TargetName="NormalVisual" />
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="PlacementStates">
                        <VisualState x:Name="HorizontalTop" />
                        <VisualState x:Name="HorizontalLeft">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="LayoutTransform"
                                        Storyboard.TargetName="OrientationTransform">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <RotateTransform Angle="180" />
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="HorizontalRight" />
                        <VisualState x:Name="HorizontalBottom">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="LayoutTransform"
                                        Storyboard.TargetName="OrientationTransform">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <RotateTransform Angle="180" />
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="VerticalTop">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="LayoutTransform"
                                        Storyboard.TargetName="OrientationTransform">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <RotateTransform Angle="-90" />
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="VerticalLeft">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="LayoutTransform"
                                        Storyboard.TargetName="OrientationTransform">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <RotateTransform Angle="90" />
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="VerticalRight">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="LayoutTransform"
                                        Storyboard.TargetName="OrientationTransform">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <RotateTransform Angle="-90" />
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="VerticalBottom">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="LayoutTransform"
                                        Storyboard.TargetName="OrientationTransform">
                                    <DiscreteObjectKeyFrame KeyTime="0">
                                        <DiscreteObjectKeyFrame.Value>
                                            <RotateTransform Angle="-90" />
                                        </DiscreteObjectKeyFrame.Value>
                                    </DiscreteObjectKeyFrame>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="FocusStates">
                        <VisualState x:Name="Unfocused" />
                        <VisualState x:Name="Focused" />
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Border x:Name="NormalVisual" BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"
                        CornerRadius="{StaticResource TabItem_OuterCornerRadius}"
                        Margin="{StaticResource TabItem_Margin}">
                    <Border BorderBrush="{StaticResource TabItem_InnerBorder_Normal}"
                            BorderThickness="{StaticResource TabItem_InnerBorderThickness}"
                            CornerRadius="{StaticResource TabItem_InnerCornerRadius}" />
                </Border>
                <Border x:Name="MouseOverVisual" BorderBrush="{StaticResource TabItem_OuterBorder_MouseOver}"
                        BorderThickness="{StaticResource TabItem_OuterBorderThickness}"
                        Background="{StaticResource TabItem_Background_MouseOver}"
                        CornerRadius="{StaticResource TabItem_OuterCornerRadius}"
                        Margin="{StaticResource TabItem_Margin}" Opacity="0">
                    <Border BorderBrush="{StaticResource TabItem_InnerBorder_MouseOver}"
                            BorderThickness="{StaticResource TabItem_InnerBorderThickness}"
                            CornerRadius="{StaticResource TabItem_InnerCornerRadius}" />
                </Border>
                <Border x:Name="SelectionVisual" BorderBrush="{StaticResource TabItem_OuterBorder_Selected}"
                        BorderThickness="{StaticResource TabItem_OuterBorderThickness}"
                        Background="{StaticResource TabItem_Background_Selected}"
                        CornerRadius="{StaticResource TabItem_OuterCornerRadius}"
                        Margin="{StaticResource TabItem_Margin_Selected}" Opacity="0">
                    <Border BorderBrush="{StaticResource TabItem_InnerBorder_Selected}"
                            BorderThickness="{StaticResource TabItem_InnerBorderThickness}"
                            CornerRadius="{StaticResource TabItem_InnerCornerRadius}" />
                </Border>
                <Telerik_Windows_Controls_Primitives:LayoutTransformControl x:Name="OrientationTransform">
                    <!--HeaderElement-->
                    <ContentControl x:Name="HeaderElement" Content="{TemplateBinding Header}"
                            ContentTemplate="{TemplateBinding HeaderTemplate}"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            Margin="{TemplateBinding Padding}" Foreground="White"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    <!--HeaderElement-->
                </Telerik_Windows_Controls_Primitives:LayoutTransformControl>
            </Grid>
        </ControlTemplate>
        <!--RadTabItem ControlTemplate-->
  
        <!--RadTabItemStyle-->
        <Style x:Key="RadTabItemStyle" TargetType="telerikNavigation:RadTabItem">
            <Setter Property="MinWidth" Value="5" />
            <Setter Property="BorderThickness" Value="{StaticResource TabItem_OuterBorderThickness}" />
            <Setter Property="Foreground" Value="{StaticResource ControlForeground_Normal}" />
            <Setter Property="MinHeight" Value="5" />
            <Setter Property="Background" Value="{StaticResource TabItem_Background_Normal}" />
            <Setter Property="BorderBrush" Value="{StaticResource TabItem_OuterBorder_Normal}" />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="Padding" Value="6 3" />
            <Setter Property="IsTabStop" Value="False" />
            <Setter Property="Template" Value="{StaticResource TabItemTemplate}" />
        </Style>
        <!--RadTabItemStyle-->

 

 

Any idea what could cause the exception ?
Thanks

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0
Lauren
Top achievements
Rank 1
answered on 23 Aug 2010, 05:42 PM
Hi,

One more detail about the above post.
If i set the TabOverFlowMode to Wrap, then it works fine.
As soon as i set it the Scroll, i get the exception "Value does not fall within the expected".
Also, i remove the headerTemplate and the style previously applied to the RadTabItem, but still get the exception. SO i dont think the issue comes from the template i use.

Please, any help on this ?

Thank you.
0
Miroslav
Telerik team
answered on 25 Aug 2010, 03:39 PM
Hi Lauren,

This is unexpected. Normally this exception appears when one UIElement appears in the visual tree twice (which is not allowed). Yet in this case I am not sure what may be causing it -

 I tried reproducing this with the attached example, I tried this with the latest Q2 SP1 release and with an older version.

Are you seeing the exception in the attached project?
Which version of the Silverlight / controls are you using?
Can you help us reproduce it in the attached project or otherwise?
Can you send us the call stack of the exception?

Best wishes,
Miroslav
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
bohebolo
Top achievements
Rank 1
answered on 24 Sep 2010, 05:07 PM
I'm also get this exception, BUT ONLY when DropDown clicked (i set it to DropDownDisplayMode="WhenNeeded").

        <!-- mainTab container binding template -->
        <telerik:ContainerBindingCollection x:Key="mainTabContainerBindingTemplate">
            <telerik:ContainerBinding PropertyName="IsSelected"
Binding="{Binding Selected, Mode=TwoWay}" />
        </telerik:ContainerBindingCollection>
         
        <!-- mainTab item container's style -->
        <Style x:Key="mainTabItemContainerStyle" TargetType="telerikNavigation:RadTabItem">
            <Setter Property="HeaderTemplate">
                <Setter.Value>
                    <DataTemplate telerik:ContainerBinding.ContainerBindings="{StaticResource mainTabContainerBindingTemplate}">
                        <Grid Cursor="Hand" ToolTipService.ToolTip="{Binding Header}" ToolTipService.Placement="Mouse">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <ContentPresenter Grid.Column="0" Margin="0 1 3 1" Content="{Binding Icon}" VerticalAlignment="Center" />
                            <TextBlock Grid.Column="1" TextTrimming="WordEllipsis" MaxWidth="150" VerticalAlignment="Center" Text="{Binding Header}" />
                            <Image Grid.Column="2" Margin="3 0 0 0" Source="images/icons/close.png" VerticalAlignment="Center" Tag="{Binding MenuId}" ToolTipService.ToolTip="{Binding StringCaptions, Source={StaticResource vm}, Converter={StaticResource StringCaptionsConverter}, ConverterParameter='ToolTipCloseTab'}" ToolTipService.Placement="Mouse" MouseLeftButtonUp="tabCloseImage_MouseLeftButtonUp" MouseEnter="tabCloseImage_MouseEnter" MouseLeave="tabCloseImage_MouseLeave" Opacity="0.5" Width="12" Height="12" Stretch="UniformToFill" />
                        </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <ContentPresenter Content="{Binding Content}" />
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>

<telerikNavigation:RadTabControl x:Name="mainTab" Grid.Row="1" BorderThickness="0"
                                 DropDownDisplayMode="WhenNeeded" OverflowMode="Scroll" ScrollMode="Viewport"
                                 Background="{StaticResource backgroundPicture}"
                                 ItemContainerStyle="{StaticResource mainTabItemContainerStyle}" 
                                 ItemsSource="{Binding TabItems, Mode=TwoWay}"
/>

And when dropdown is clicked, it doesn't show list of tabs opened, instead it only show empty list.
For example, when i have 5 tabs opened, then dropdown will show 5 listitems (i can select it, then it will show the proper tab).
But each listitem is empty, no tab header title & icon, just my 'close tab' button appears.
Please see the captured image.
0
Kiril Stanoev
Telerik team
answered on 29 Sep 2010, 12:07 PM
Hi bohebolo,

I've tried to reproduce the issue with your code but was unable to do so. Please find attached my sample project. Have a look at it and let me know if I am missing something.

Kind regards,
Kiril Stanoev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
bohebolo
Top achievements
Rank 1
answered on 29 Sep 2010, 01:17 PM
Hi Kiril Stanoev,

I have modified your sample project, so it will reproduce this behaviour.
I have added header's icon that binding to Icon property in ViewModel.

It seems i can't upload zip file to this forum, so here is changes that I made:

public class ViewModel
{
    public ViewModel()
    {
        this.TabItems = new ObservableCollection<TabItem>();
        for (int i = 0; i < 15; i++)
        {
            TabItem tabItem = new TabItem();
            tabItem.Header = string.Format("Item {0} Header", i);
            tabItem.Content = string.Format("Item {0} Content", i);
            tabItem.Icon = new Image()
                {
                    Width = 16,
                    Height = 16,
                    Source = new BitmapImage(new Uri("icon.png", UriKind.Relative))
                };
            this.TabItems.Add(tabItem);
        }
    }
 
    public ObservableCollection<TabItem> TabItems { get; set; }
}
 
public class TabItem
{
    public string Header { get; set; }
    public object Content { get; set; }
    public Image Icon
    {
        get
        {
            return _icon;
        }
        set
        {
            if (value != null & value != _icon)
            {
                _icon = value;
            }
        }
    }
    private Image _icon;
}


thanks.



0
KM
Top achievements
Rank 1
answered on 01 Oct 2010, 02:48 PM
Hello Stephane,

What kind of project are you working on ?

Regards
0
Kiril Stanoev
Telerik team
answered on 04 Oct 2010, 01:30 PM
Hi Bohe,

The problem is that your Icon property is of type Image (which is a visual element) and one visual element cannot appear at two places in the visual tree. Also such approach does not conform with the whole MVVM pattern. Therefore, my advise is to make your Icon property to be of type BitmapImage. Please find attached an updated version of the previous project. Let me know if this works for you.

All the best,
Kiril Stanoev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
bohebolo
Top achievements
Rank 1
answered on 04 Oct 2010, 03:47 PM
Hi Kiril Stanoev,

Yes your solution is working, thanks a lot..


Tags
TabControl
Asked by
Murugesan Loganathan
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Praveen
Top achievements
Rank 1
Kakone
Top achievements
Rank 1
Tina Stancheva
Telerik team
Lauren
Top achievements
Rank 1
Miroslav
Telerik team
bohebolo
Top achievements
Rank 1
KM
Top achievements
Rank 1
Share this question
or