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

UserControl as Tab Content

1 Answer 92 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Lilia
Top achievements
Rank 1
Lilia asked on 13 Jul 2011, 04:40 PM
Hello Telerik team,

I'm using this article from your tutorial to add Close buttons to RadTabControl. I added the buttons, but I cannot seem to manage to add UserControl as Content for the tab

<Setter Property="ContentTemplate">
           <Setter.Value>
               <DataTemplate>
                   <Grid>
                       <UserControl Content="{Binding Content}" />
                   </Grid>
               </DataTemplate>
           </Setter.Value>
       </Setter>

The Content property is of type UserControl. Can you give mi a hint how to do that? 
The example this way is loading my custom user control in the tab, but when I load multiple tabs (for example lets call them 1 and 2) and when I select 1 tab, then 2 tab and then 1 again an exception is thrown:

{System.ArgumentException: Value does not fall within the expected range.
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
   at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
   at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
   at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
   at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
   at System.Windows.Data.BindingExpression.SendDataToTarget()
   at System.Windows.Data.BindingExpression.SourceAcquired()
   at System.Windows.Data.BindingExpression.System.Windows.IDataContextChangedListener.OnDataContextChanged(Object sender, DataContextChangedEventArgs e)
   at System.Windows.Data.BindingExpression.DataContextChanged(Object sender, DataContextChangedEventArgs e)
   at System.Windows.FrameworkElement.OnDataContextChanged(DataContextChangedEventArgs e)
   at System.Windows.FrameworkElement.OnTreeParentUpdated(DependencyObject newParent, Boolean bIsNewParentAlive)
   at System.Windows.DependencyObject.UpdateTreeParent(IManagedPeer oldParent, IManagedPeer newParent, Boolean bIsNewParentAlive, Boolean keepReferenceToParent)
   at MS.Internal.FrameworkCallbacks.ManagedPeerTreeUpdate(IntPtr oldParentElement, IntPtr parentElement, IntPtr childElement, Byte bIsParentAlive, Byte bKeepReferenceToParent, Byte bCanCreateParent)}



1 Answer, 1 is accepted

Sort by
0
Lilia
Top achievements
Rank 1
answered on 13 Jul 2011, 05:11 PM
Tags
TabControl
Asked by
Lilia
Top achievements
Rank 1
Answers by
Lilia
Top achievements
Rank 1
Share this question
or