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


Product Version 2020.2.617
Product RadWizard for WPF


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.


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:RadButton Content="Submit Password" Command="{Binding SubmitPasswordCommand}" CommandParameter="{x:Reference WizardWindow}" /> 

Solution #2

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

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

See Also

In this article