New to Telerik UI for WPF? Download free 30-day trial

ElementName and RelativeSource Bindings Don't Work in the Content of Not-Selected Wizard Pages

Environment

Product Version 2020.2.617
Product RadWizard for WPF

Description

The ElementName and RelativeSource bindings in the content of the wizard pages don't work if the page is not the first to be loaded.

Solution

This behavior happens because the content of the unselected pages is not part of the visual tree until it is selected. Therefore, the ElementName and RelativeSource bindings cannot find the corresponding element. As the WPF framework doesn't re-evaluate these bindings when the content is added in the visual tree, this leads to the non-working binding.

Solution #1

To achieve the desired result, you can use an x:Reference binding instead.

<telerik:WizardPage> 
    <telerik:RadButton Content="Submit Password" Command="{Binding SubmitPasswordCommand}" CommandParameter="{x:Reference WizardWindow}" /> 
</telerik:WizardPage> 

Solution #2

Alternatively, you can use the ContentTemplate property of the page instead of setting its content directly.

<telerik:WizardPage> 
    <telerik:WizardPage.ContentTemplate> 
        <DataTemplate> 
                <telerik:RadButton Content="Submit Password" Command="{Binding SubmitPasswordCommand}" CommandParameter="{Binding ElementName=WizardWindow}"/> 
            </UniformGrid> 
        </DataTemplate> 
    </telerik:WizardPage.ContentTemplate> 
</telerik:WizardPage> 

See Also

In this article
Not finding the help you need? Improve this article