My problem is simple: In my RadExpander header template, I am unable to access the properties of the data context of the expander itself. Why does the header not have the same data context?
Here is a simple example: A main Window with a label and a RadExpander (with HeaderTemplate). The simple label easily accesses the "Name" property. The RadExpander's HeaderTemplate cannot
<Window x:Class="TestTelerik.MainWindow" xmlns:testTelerik="clr-namespace:TestTelerik" Title="MainWindow" Height="350" Width="525" > <StackPanel> <!-- This shows up just fine --> <Label Content="{Binding HeaderTitle}"/> <tk:RadExpander> <tk:RadExpander.HeaderTemplate> <DataTemplate> <!-- This does not show. Why not? --> <Label Content="{Binding HeaderTitle}"/> </DataTemplate> </tk:RadExpander.HeaderTemplate> </tk:RadExpander> </StackPanel></Window>
The DataContext of this window is just itself:
public partial class MainWindow : Window{ public MainWindow() { InitializeComponent(); DataContext = this; } public string HeaderTitle => "Items!";}My real-world use case it actually quite a bit more complicated so it's not a viable solution for me to try to bind the "RadExpander.Header" property directly.
Nor can I use the "ElementName=" binding syntax. Not in my case
What is the best way to make the RadExpander HeaderTemplate inherit its the RadExpander's data context?
