Binding WPF Usercontrol datacontext
October 22. 2015
0 Comments
- Posted in:
- WPF
When you bind the DataContext of an UserControl XAML to the code part of the file, you can use this method:
DataContext="{BindingRelativeSource={RelativeSourceSelf}}"
If you want to bind to a property of another element, this is the way to go:
Width="{Binding ElementName=NameOfAnotherControl,Path=Width}"