Linked Questions
19 questions linked to/from Access parent DataContext from DataTemplate
0 votes
0 answers
835 views
Binding the DataContext of a UserControl to a property in my main ViewModel [duplicate]
Using MVVM Light, When binding my UserControl's DataContext to a ViewModel property within my main ViewModel, the UI won't reflect anything. Following many of the other answers I found on stack ...
0 votes
1 answer
227 views
Binding Foreground for a TextBlock lying within ListBox.ItemTemplate [duplicate]
I have a ListBox in WPF Window and an image + text block as item. I am trying to set the foreground of the text block via a property (i.e. ItemForegroundColor). ItemForegroundColor is a property in ...
0 votes
0 answers
25 views
.Net 5 binding combo box within a datagrid (MVVM) [duplicate]
I'm trying to learn WPF and I'm currently creating a grid and binding data to it. Currently text column data binds ok but when doing a combobox it displays no data in the list. public class ...
672 votes
14 answers
541k views
How do I use WPF bindings with RelativeSource?
How do I use RelativeSource with WPF bindings and what are the different use-cases?
11 votes
3 answers
19k views
Binding to a property of the DataContext of another control
iv'e got 2 panels in an app game they are both bound to different elements . GameDetailsPanel.DataContext = game ; GameBoardPanel.DataContext = gameBoard ; *Game has a Turn Property * . ...
2 votes
1 answer
4k views
Binding to Parent DataTemplate Property from ItemsControl
Say I have this ViewModel and xaml: class MyViewModel { public MyStringValue {get;set;} = "HelloWorld" public IList<CustomObject> ChildViewModels{get;set;} } <DataTemplate DataType=...
0 votes
1 answer
6k views
Silverlight: Access parent data context from DataTemplate?
I'm using Silverlight 4. I have an ItemsControl with a custom DataTemplate. From that DataTemplate, I would like to bind to something in the UserControl's DataContext - not the DataContext of a ...
6 votes
1 answer
3k views
WPF user controls and name scoping
I've been playing around with WPF and MVVM and noticed a strange thing. When using {Binding ElementName=...} on a custom user control, the name of the root element within the user control seems to be ...
2 votes
2 answers
2k views
WPF - How to implement two-way data binding with the dynamically created control?
I'm writing a program that dynamically creates Control based on the data type of the properties extracted using reflection. Here is the view in subject for examination. <ListView ItemsSource="{...
0 votes
1 answer
2k views
Binding a property with a different ItemSource WPF C#
I have a list bound as ItemSource that contains two strings: Option 1 and option 2, I have 2 text boxes where I bind and display these two options. I also have two radio buttons next to the two ...
1 vote
1 answer
1k views
Binding a Command to HierarchicalDataTemplate MenuItem
I am trying to bind a VM method as a command in MenuItem. Though menu is displays correctly the function never get called.I expecting the MenuCommand Method to be get called from the command binding. ...
0 votes
2 answers
1k views
ReactiveUI in WPF: how to bind a command from the parent's ViewModel to a button in ItemsControl.ItemTemplate?
It's the code from YouIandReactiveUI Is there a more elegant way to achieve this? Or is there any way to bind in code with IViewFor? <ItemsControl.ItemTemplate> ...
1 vote
1 answer
713 views
Cannot bind correctly the command to viewmodel
I've got a wpf view that has a telerik:RadListBox with a contextmenu associated on each item defined as <DataTemplate x:Key="ListBoxItemTemplate"> <Grid > <telerik:...
1 vote
4 answers
231 views
Visible name in XAML
I have a datagrid with a column containing a ComboBox. I've set the Name for my combobox, but this name is not visible in code, why? <DataGrid ...> <DataGrid.Columns> <...
0 votes
1 answer
289 views
WPF: Access parent DataTemplate from DataContext
I have the below situation: <DataTemplate DataType="{x:Type tra:Presenter}"> <DockPanel> <GroupBox> <ie:DifferentControl DataContext="{...