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

User Defined constructor with ViewModel injected not firing when using RadTransitionControl

3 Answers 137 Views
TransitionControl
This is a migrated thread and some comments may be shown as answers.
Jinish
Top achievements
Rank 1
Jinish asked on 02 Nov 2011, 10:02 PM
Hello,

I am having some trouble while using the RadTransition control. The way i am using it is below:

<UserControl.Resources>
       <Style x:Key="TransitionFrameStyle"
               TargetType="sdk:Frame">
            <Setter Property="Background"
                    Value="Transparent" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="sdk:Frame">
                        <Border CornerRadius="5">
                            <Grid Background="{TemplateBinding Background}">
                                <telerik:RadTransitionControl x:Name="PART_FrameCP"
                                                              Content="{TemplateBinding Content}"
                                                              ContentTemplate="{TemplateBinding ContentTemplate}">
                                    <telerik:RadTransitionControl.Transition>
                                        <TransitionEffects:SlideAndZoomTransition MinAlpha="0.1"
                                                                                  MinZoom="0.9"
                                                                                  SlideDirection="LeftToRight"
                                                                                  StartSlideAt="0.25" />
                                    </telerik:RadTransitionControl.Transition>
                                </telerik:RadTransitionControl>
                                <Border BorderBrush="{TemplateBinding BorderBrush}"
                                        BorderThickness="{TemplateBinding BorderThickness}"
                                        Padding="{TemplateBinding Padding}" />
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
</UserControl.Resources>

Then using a frame control as below on the page:
<sdk:Frame Style="{StaticResource TransitionFrameStyle}"
                           Grid.Row="1"
                           NavigationFailed="Frame_NavigationFailed"
                           Source="{Binding Path=SelectedPage.PageUri}" />

Then in the Viewmodel for this page:
private readonly ObservableCollection<FramePage> pages;
 
public UserManagementSummaryViewModel(IRegionManager regionManager)
        {
            if (regionManager == null)
            {
                throw new ArgumentNullException("regionManager");
            }
 
            this.regionManager = regionManager;
            this.BackCommand = new DelegateCommand(this.NavigateToMainScreen);
            this.RefreshCommand = new DelegateCommand(this.RefreshUserPanel);
            this.ShowIconViewCommand = new DelegateCommand(this.ShowIconView);
            this.ShowListViewCommand = new DelegateCommand(this.ShowListView);
 
            this.pages = new ObservableCollection<FramePage>();
            pages.Add(new FramePage("Icon View", "/XYZ.UserManagementModule;component/Views/UserIconView.xaml"));
            pages.Add(new FramePage("List View", "/XYZ.UserManagementModule;component/Views/UserListView.xaml"));
 
            //// Set the default view to the Icons View page
            this.SelectedPage = this.pages[0];
        }
 
/// <summary>
        /// Gets or sets the selected page to display in the frame
        /// </summary>
        public FramePage SelectedPage
        {
            get
            {
                return GetProperty(() => this.SelectedPage);
            }
 
            set
            {
                SetProperty(() => this.SelectedPage, value);
            }
        }
        /// <summary>
        /// Gets the pages collection that can be displayed in the transition frame
        /// </summary>
        public ObservableCollection<FramePage> Pages
        {
            get
            {
                return this.pages;
            }
        }
 
/// <summary>
        /// Shows the Icon view page in the transition frame
        /// </summary>
        private void ShowIconView()
        {
            this.SelectedPage = this.pages[0];
        }
 
        /// <summary>
        /// Shows the List view page in the transition frame
        /// </summary>
        private void ShowListView()
        {
            this.SelectedPage = this.pages[1];
        }


Now i can navigate to the UserIconView and UserListView pages, thats nto a problem. The problem is that when i transition to any of these pages, in the code-behind, i have 2 constructors defined like this:

/// <summary>
        /// Initializes a new instance of the <see cref="UserListView"/> class.
        /// </summary>
        public UserListView()
        {
            this.InitializeComponent();
        }
 
        /// <summary>
        /// Initializes a new instance of the <see cref="UserListView"/> class.
        /// </summary>
        /// <param name="userManagementViewModel">View model for <see cref="UserListView"/></param>
        public UserListView(UserManagementViewModel userManagementViewModel)
            : this()
        {
            this.DataContext = userManagementViewModel;
        }


The problem is that it only hits the Default constructor, the second user defined constructor is not fired at all, so basically i am not able to access my view model for these views.

Any help would be appreciated.

3 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 03 Nov 2011, 08:33 AM
Hi Jinish,

Are you able to get the correct behavior if you replace the RadTransitionControl with a ContentControl?

Greetings,
Valeri Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jinish
Top achievements
Rank 1
answered on 03 Nov 2011, 10:23 AM
Hi Valeri,

Yes, the problem apparently seems also with a ContentControl. Will need to dig a bit more into it.
0
Jinish
Top achievements
Rank 1
answered on 03 Nov 2011, 11:20 AM
Solved the problem by making the Frame a Prism region and using the RegionManager's "RequestNavigate" method to navigate to the view. That seems to work fine, although, still couldnt figure out what was wrong in the original approach.
Tags
TransitionControl
Asked by
Jinish
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Jinish
Top achievements
Rank 1
Share this question
or