Describe the bug
<SettingsExpander.ItemTemplate>
<DataTemplate x:DataType="MyModel">
<SettingsCard>
<Button Content="{x:Bind Content}" Loaded="Button_Loaded"/>
</SettingsCard>
</DataTemplate>
</SettingsExpander.ItemTemplate>
From the Button_Loaded, I can get the instance of the button. However, it's DataContext is null instead of MyModel
Steps to reproduce
Expected behavior
- UI element in the DataTemplate should be able to get the DataContext
Screenshots
No response
Code Platform
Windows Build Number
Other Windows Build number
No response
App minimum and target SDK version
Other SDK version
No response
Visual Studio Version
2026
Visual Studio Build Number
No response
Device form factor
Desktop
Additional context
No response
Help us help you
No, I'm unable to contribute a solution.
Describe the bug
From the
Button_Loaded, I can get the instance of the button. However, it's DataContext is null instead ofMyModelSteps to reproduce
Expected behavior
Screenshots
No response
Code Platform
Windows Build Number
Other Windows Build number
No response
App minimum and target SDK version
Other SDK version
No response
Visual Studio Version
2026
Visual Studio Build Number
No response
Device form factor
Desktop
Additional context
No response
Help us help you
No, I'm unable to contribute a solution.