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

Acess elements inside FooterTemplate

2 Answers 208 Views
Wizard
This is a migrated thread and some comments may be shown as answers.
Ricardo
Top achievements
Rank 1
Ricardo asked on 29 May 2018, 09:05 AM

Hello,

 

I have created a Radwizard Application (c#) that has a HeaderTemplate and a FooterTemplate.

 

Inside the footer i have created custom radbuttons for back, cancel, next and finish. However, i cannot seem to access them in the code behind.this.Rad.

 

RadWizard.xaml:

<Window
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                xmlns:wizard="clr-namespace:Telerik.Windows.Controls.Wizard;assembly=Telerik.Windows.Controls.Navigation"
                x:Class="App.MainWindow"  
                Height="450" Width="600"
                Title="MyApp">
    <telerik:RadWizard x:Name="Rad" IsContentPreserved="True" Background="#dee3e9">
        <telerik:WizardPage HeaderHeight="90">
            <telerik:WizardPage.HeaderTemplate>
            ...
            </telerik:WizardPage.HeaderTemplate>
            <telerik:WizardPage.FooterTemplate>
<DataTemplate>
                    <StackPanel Orientation="Horizontal" Margin="-0.5 -0.5 -1.51 -2" HorizontalAlignment="Left" Width="650">
                        <telerik:RadButton x:Name="Back"
                                           Content="< Back"  
                                           Margin="160 5 5 5"
                                           Command="wizard:RadWizardCommands.MoveCurrentToPrevious"/>
                    </StackPanel>
</DataTemplate>
            </telerik:WizardPage.FooterTemplate>
</Window>

I need to acess the RadButton inside the footertemplate from the code behind.

 

Can anyone help me?

 

Regards

2 Answers, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 31 May 2018, 12:46 PM
Hello Ricardo,

This is expected. The WPF framework doesn't give you direct access from code-behind to elements defined in a DataTemplate. Based on your scenarios there are different approaches that you can use to interact with the elements. For example, you can use the ChildrenOfType<T>() method to find the element that you need after the RadWizard control is loaded. Or you can set the Command property of the button which will allow you to define an ICommand and bind it to the button.

If you tell me why you need to access the elements inside the FooterTemplate I will think of a suitable approach for your case.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Ricardo
Top achievements
Rank 1
answered on 04 Jun 2018, 08:45 AM

Hi Martin,

 

I used your solution and i got access to the radbuttons inside the footer.

 

Thank you for the information.

Tags
Wizard
Asked by
Ricardo
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Ricardo
Top achievements
Rank 1
Share this question
or