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

How to bind complex observerable collection to RADTAB

2 Answers 25 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Angie
Top achievements
Rank 1
Angie asked on 19 Sep 2012, 10:26 PM
I'm trying bind Following type of object collection to rad tab but i get
public ObservableCollection<INavigatableTab> TabViewCollection
       {
           get
           {
               if(_tabViewCollection == null)
                   ProcessTabViews();
 
               return _tabViewCollection;
           }
       }
 
 public void ProcessTabViews()
       {
           var infoKey = new InfoKey()
                             {
                                 AgencyID = ApplicationGlobal.Settings.AgencyInfo.AgencyID,
                                 EndorsementID = ApplicationGlobal.ActiveEndorsement.EndorsementID,
                                 PolicyNumber = ApplicationGlobal.ActiveEndorsement.PolicyNumber
                             };
 
 
           _tabViewCollection = new ObservableCollection<INavigatableTab>()
                                    {new BasicInfoViewNavigatableHandler(infoKey, new EndorsementGeneralDataService())};
 
       }

In Tab Handler

public class BasicInfoViewNavigatableHandler : INavigatableTab
   {
 
       #region Fields
 
       private readonly InfoKey _infoKey;
       private BasicInfoView _view;
       private BasicInfoViewModel _basicInfoVM;
       private readonly IEndorsementGeneralDataService _endorsementGeneralDataService;
 
       #endregion
 
       #region Constructors
 
       public BasicInfoViewNavigatableHandler(InfoKey infoKey, IEndorsementGeneralDataService endorsementGeneralDataService)
       {
           _infoKey = infoKey;
           _endorsementGeneralDataService = endorsementGeneralDataService;
       }
 
       #endregion
 
       #region Properties
 
       BasicInfoViewModel BasicInfoVM
       {
         get { return _basicInfoVM ?? (_basicInfoVM = new BasicInfoViewModel(_infoKey, _endorsementGeneralDataService)); }
       }
       #endregion
 
       #region Events
       #endregion
 
       #region Methods
       #endregion
 
       #region Commands
       #endregion
        
 
       #region INavigatableTab Members
 
       public string TabName
       {
           get { return "Address"; }
       }
 
       public UserControl View
       {
           get { return _view ?? (_view = new BasicInfoView() {DataContext = BasicInfoVM}); }
       }
 
       public Type NextViewType
       {
           get { return typeof (BasicInfoView); }
       }
 
       public Type PreviousViewType
       {
           get { return null; }
       }
 
       public int TabIndex
       {
           get { return 0; }
       }
 
       public int StepIndex
       {
           get { return 0; }
       }
 
       public bool CanProcess(Type viewType)
       {
           return viewType == _view.GetType();
       }
 
       public bool CanProcess(int stepIndex)
       {
           return stepIndex == StepIndex;
       }
 
       #endregion
 
       #region IJumpableTab Members
 
       public event EventHandler<CustomEventArgs.JumpableTabEventArgs> OnJumpTo;
 
       #endregion
   }

In View

<telerik:RadTabControl x:Name="cntrltab"
                                 MinWidth="700" telerik:StyleManager.Theme="Windows7" HorizontalContentAlignment="Left"
                                 SelectedIndex="{Binding CurrentTabIndex, Mode=TwoWay,FallbackValue=0}" BorderThickness="0,1,0,0" 
                                 Margin="0,10,0,0" d:LayoutOverrides="HorizontalAlignment, Width, Height" Grid.Row="1"
                                 Background="{x:Null}"
                                 ItemsSource="{Binding TabViewCollection, Mode=TwoWay}">
                   <telerik:RadTabControl.ItemContainerStyle>
                       <Style TargetType="telerik:RadTabItem">
                           <Setter Property="HeaderTemplate">
                               <Setter.Value>
                                   <DataTemplate>
                                       <TextBlock Text="{Binding TabName}"
                                              FontSize="11"
                                              Margin="5 0 5 0"
                                              VerticalAlignment="Center" />
                                   </DataTemplate>
                               </Setter.Value>
                           </Setter>
                           <Setter Property="ContentTemplate" Value="{Binding View}"/>
                       </Style>
                   </telerik:RadTabControl.ItemContainerStyle>
               </telerik:RadTabControl>


When i run it what i can see is assembly name of TabViewCollection both in tab header and tab content.

Please help

Thanks

2 Answers, 1 is accepted

Sort by
0
Angie
Top achievements
Rank 1
answered on 20 Sep 2012, 02:02 PM
Anybody knw why? Is it possible to bind complex observerable collection to RadTabControls???? Is it possible to bind
ObservableCollection<SomeINterfaceTypeWhichContainsViewNameandUserControl> ????? hope somebody could help me 

Thanks
0
Angie
Top achievements
Rank 1
answered on 20 Sep 2012, 02:55 PM
NVM i solved it my self. Here is the solution

<UserControl.Resources>
        <telerik:HierarchicalDataTemplate x:Key="ItemTemplate1" >
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <TextBlock Text="{Binding TabName}" />
            </Grid>
        </telerik:HierarchicalDataTemplate>
        <telerik:HierarchicalDataTemplate x:Key="ContentTemplate1">
 
            <StackPanel>
                <toolkit:TransitioningContentControl x:Name="ctlMain" Margin="10"  Content="{Binding View}" HorizontalContentAlignment="Left" />
            </StackPanel>
 
        </telerik:HierarchicalDataTemplate>
    </UserControl.Resources>
<telerik:RadTabControl x:Name="cntrltab"
                                  telerik:StyleManager.Theme="Windows7"
                                  MinWidth="700"  HorizontalContentAlignment="Left"
                                  SelectedIndex="{Binding CurrentTabIndex, Mode=TwoWay,FallbackValue=0}" BorderThickness="0,1,0,0" 
                                  Margin="0,10,0,0" d:LayoutOverrides="HorizontalAlignment, Width, Height" Grid.Row="1"
                                  Background="{x:Null}"
                                  ItemsSource="{Binding TabViewCollection, Mode=TwoWay}"
                                  ItemTemplate="{StaticResource ItemTemplate1}"
                                  ContentTemplate="{StaticResource ContentTemplate1}">
                </telerik:RadTabControl>
Tags
TabControl
Asked by
Angie
Top achievements
Rank 1
Answers by
Angie
Top achievements
Rank 1
Share this question
or