Using the user control or window as the view model (data context) for XAML

To use a user control or windows code behind as the data context, add this to your XAML in a WPF application:


<... DataContext="{Binding RelativeSource={RelativeSource Self}}" .../>

Post a Comment

Previous Post Next Post