Use BindingOperations
Binding binding = new Binding();
binding.Path = new PropertyPath("SomeText");
binding.Source = sourceObject; // view model?
BindingOperations.SetBinding(theTextBlock, TextBlock.TextProperty, binding);
More Related Contents:
- WPF Error: Cannot find governing FrameworkElement for target element
- How to bind multiple values to a single WPF TextBlock?
- RelativeSource binding from a ToolTip or ContextMenu
- How to preserve control state within tab items in a TabControl
- How do I access an element of a control template from within code-behind
- How can I move a WPF Popup when its anchor element moves?
- DataTrigger where value is NOT null?
- Are “{Binding Path=.}” and “{Binding}” really equal
- Set value to null in WPF binding
- WPF Binding to local variable
- Binding WPF DataGrid to DataTable using TemplateColumns
- WPF: Bind DataGrid to List
- Binding errors not showing on output window
- WPF Treeview Databinding Hierarchal Data with mixed types
- WPF StringFormat on Label Content
- WPF StringFormat={0:C} showing as dollars
- Datacontext conflicts
- Bind an element to two sources
- TextBox and default Button binding does update too late
- ComboBox.SelectedValue not updating from binding source
- Difference between {Binding PropertyName} and {Binding Path=PropertyName}
- Problem binding DataGridComboBoxColumn.ItemsSource
- Binding to DateTime.Now. Update the value
- A TwoWay or OneWayToSource binding cannot work on the read-only property
- WPF binding with StringFormat doesn’t work on ToolTips
- Binding ElementName. Does it use Visual Tree or Logical Tree
- ItemsControl ItemTemplate Binding
- WPF DataGrid : CanContentScroll property causing odd behavior
- WPF ViewModel Commands CanExecute issue
- How to access a control from a ContextMenu menuitem via the visual tree?