Cannot Find Source for Data Binding with ElementName Reference
Environment
Product Version | 2019.3.917 |
Product | RadWizard for WPF |
Description
Cannot find the source of data binding with ElementName reference when the elements are in the RadWizardPage's Content.
The following code snippet shows the setup that reproduces the issue.
<telerik:WizardPage.Content>
<DataTemplate>
<StackPanel>
<Label Target="{Binding ElementName=txt_Code2}" Content="_code." />
<TextBox Name="txt_Code2" />
</StackPanel>
</DataTemplate>
</telerik:WizardPage.Content>
Solution
This behavior comes from an optimization in the RadWizard control. To resolve it, you can use ContentTemplate, instead of Content.
<telerik:WizardPage.ContentTemplate>
<DataTemplate>
<StackPanel>
<Label Target="{Binding ElementName=txt_Code2}" Content="code." />
<TextBox Name="txt_Code2" />
</StackPanel>
</DataTemplate>
</telerik:WizardPage.ContentTemplate>
<telerik:WizardPage.Content>
<StackPanel>
<Label Target="{Binding Source={x:Reference txt_Code2}}" Content="_code." />
<TextBox Name="txt_Code2" />
</StackPanel>
</telerik:WizardPage.Content>