For first one, try :
<UserControl DataContext="{Binding RelativeSource={RelativeSource Self}}">
And for second question, I think using ElementName
or AncestorBinding
is best way to bind to UserControl
‘s properties.
More Related Contents:
- Setting DataContext within UserControl is affecting bindings in parent
- Binding to static property
- WPF Databinding: How do I access the “parent” data context?
- Why does the binding update without implementing INotifyPropertyChanged?
- WPF: Canvas mouse events not firing on empty space
- OneWayToSource binding from readonly property in XAML
- How can I apply a custom sort rule to a WPF DataGrid?
- What approaches are available to dummy design-time data in WPF?
- What does the WPF star do (Width=”100*”)
- Calling a parameterized constructor from XAML
- How to make overlay control above all other controls?
- What is the difference between x:Reference and ElementName?
- DataTrigger where value is NOT null?
- Trouble referencing a Resource Dictionary that contains a Merged Dictionary
- Are “{Binding Path=.}” and “{Binding}” really equal
- XAML Combine styles going beyond BasedOn?
- WPF: XAML property declarations not being set via Setters?
- WPF TreeView: How to style selected items with rounded corners like in Explorer
- How can I reduce RadioButton binding code?
- TextBox TextTrimming
- Creating an instance of a nested class in XAML
- Different views / data template based on member variable
- Difference between {Binding PropertyName} and {Binding Path=PropertyName}
- WPF: Changing Resources (colors) from the App.xaml during runtime
- How to change MahApps.Metro dialog content template width?
- How to set DataGrid’s row Background, based on a property value using data bindings
- App.xaml file does not get parsed if my app does not set a StartupUri?
- How to disable a databound ListBox item based on a property value?
- How to access a control from a ContextMenu menuitem via the visual tree?
- How can I tell my DataTemplate to bind to a property in the PARENT ViewModel?