RadTabControl Header Binding Issue In MVVM Prsim

2 posts, 0 answers
  1. Anand
    Anand avatar
    12 posts
    Member since:
    Apr 2014

    Posted 15 Jul 2014 Link to this post

    hello All,
    I'm new to Silverlight, MVVM, Telerik, Prsim. I'm trying to Create A RadTabControl which will Have 4 Tabs. So I created 1 Module in My Prism project And I have create RadTabControl
    AdminTabControl.xaml
    <telerik:RadTabControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                                  Grid.Column="1" Grid.Row="1"  x:Name="AdminTabContainer"
                                  Prism:RegionManager.RegionName="AdminTabContainerRegion"
                                 >
               <telerik:RadTabControl.ItemContainerStyle >
                   <Style TargetType="telerik:RadTabItem">
                       <Setter Property="HeaderTemplate">
                           <Setter.Value>
                               <DataTemplate>
                                   <TextBlock Text="{Binding ViewTabName}"/>
                               </DataTemplate>
                           </Setter.Value>
                       </Setter>
                   </Style>
               </telerik:RadTabControl.ItemContainerStyle>
               <!-- <telerik:RadTabItem x:Name="UserTab" Header="Users">
                   <Grid Background="Transparent"/>
               </telerik:RadTabItem>-->
           </telerik:RadTabControl>

    And I Created A Another UserTab in View & ViewModel Like this.

       UserTab.xaml
    <telerik:RadGridView x:Name="UserTabGridDataView"
              Grid.Column="0"
              Grid.Row="0"
              HorizontalAlignment="Stretch"            
              VerticalAlignment="Top"
              HorizontalContentAlignment="Left"/>

    And In my AdminModule.cs


    public void Initialize()
           {
               this.RegisterViewsAndServices();
               if (this.regionManager.Regions.ContainsRegionWithName(RegionNames.HPMS_CENTER_REGION))
               {
                   var vm = this.container.Resolve<AdminstratorTab>();
                   this.regionManager.Regions[RegionNames.HPMS_CENTER_REGION].Add(vm);
     
                  var userTab = this.container.Resolve<UsersTabDataGrid>();
                  var b = (IUsersTabDataGridViewViewModel)userTab.ViewModel;
                   b.ViewTabName = "Users";
                    
                   userTab.ViewModel = b;
                   this.regionManager.Regions[RegionNames.HPMS_ADMINTAB_REGION].Add(userTab);
               }
           }
     
           protected void RegisterViewsAndServices()
           {
               this.container.RegisterType<AdminstratorTab>();
               this.container.RegisterType<IAdminstratorTabViewViewModel, AdminstratorTabViewViewModel>();
               this.container.RegisterType<UsersTabDataGrid>();
               this.container.RegisterType<IUsersTabDataGridViewViewModel, UsersTabDataGridViewViewModel>();
     
           }

    My UserViewViewModel  is Like this :
    public class UsersTabDataGridViewViewModel : ViewModelBase, IUsersTabDataGridViewViewModel
        {
            public UsersTabDataGridViewViewModel() {
                this.ViewTabName = "Users";
            }
     
            private string _viewTabName;
            public string ViewTabName
            {
                get { return _viewTabName; }
                set {
                    _viewTabName = value;
                    OnPropertyChanged("ViewTabName");
                }
            }
        }

    now with this code I'm able to Load the Application But Tab Doesn't Show Tile As Users. How to Resolve this.

    Another Confusion:
    1. Without Creating Custom Region Adapter I was able to See My Tab Control & Grid in that 1 tab. I didn't bind my UserDomainService yet. So it is Not Required. As most of the Froum I digged most of the Devleopers have Implemented. So why it is running in my case.
    2. Even After custom Implementation Situation is same.

  2. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 17 Jul 2014 Link to this post

    Hello Anand,

    Thank you for your question.

    I was not able to reproduce your scenario with the provided code. Can you please send me an isolated project that demonstrates your implementation? This will help me in better understanding your scenario and assist you in resolving the reported behavior.

    Thank you for any help you can provide.

    Regards,
    Martin
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. DevCraft banner
Back to Top