Questions tagged [datacontext]

A DataContext is used in WPF, Silverlight and various other .NET technologies. When used with WPF or Silverlight, a DataContext is an object holding the data that the form (or page in case of Silverlight) uses as a display source for its UI elements.

A DataContext is used in WPF, Silverlight and various other .NET technologies. When used with WPF or Silverlight, a DataContext is an object holding the data that the form (or page in case of Silverlight) uses as a display source for its UI elements. The DataContext in this case is the default object to bind against for any bindings that you have specified for other properties on the UI elements.

Ref: FrameworkElement.DataContext

1485 questions
-1
votes
2 answers

What is data context in UWP?

public string Name { get { return this.name; } set { this.name = value; } } here this is equivalent to public string Name{ get; set; } right? similarly for the class variable public NewsItem ns { get {…
Os Snehith Ab
  • 67
  • 1
  • 7
-1
votes
1 answer

Linq to SQL Server Name Changes

We have a C# desktop app that used datacontext for linq to sql. It's running well for quite and while and then the IT guys move the database to a different server. Ouch, the app had to be recompiled with the new server name. Is there a way to set…
Bernie Hunt
  • 306
  • 4
  • 22
-1
votes
1 answer

in Silverlight DataGrid, CheckBox's DataContext sometimes null when Checked/Unchecked

I have a DataGrid. One of the columns is a template with a CheckBox in it. When the Checked or Unchecked events trigger, (it happens with both) the CheckBox's DataContext is sometimes null, which causes my code to error. It seems to be null most…
Tim S.
  • 55,448
  • 7
  • 96
  • 122
-1
votes
1 answer

Setting Datacontext

Okay, I'm going to try and explain my excercise now.. This is my PageOverzicht.xaml, and this code works. It gives me a dropdown with the colors of the flowers in (blue, orange, white, ...). Now the datacontext is hardcoded to find the flowers with…
-1
votes
1 answer

Wrong DataContext binding ToolTipService.IsEnabled in DataGridTextColumn

I want to display an image on hover of a DataGridTextColumn with use of ToolTip. It's working great so far but I need to disable the ToolTip if there is no image available. This is my Code so far:
Tommehh
  • 872
  • 1
  • 17
  • 44
-1
votes
1 answer

WPF: Usercontrol datacontext binding does not reflect changes to ViewModel

I have a collection bound to Combobox and it's SelectedItem is bound to my viewmodel property SelectedItem. The class of SelectedItem is as…
Jayakrishnan
  • 4,232
  • 2
  • 23
  • 35
-1
votes
1 answer

Linq to SQL DataContext missing SET clause on calling SubmitChanges

I am currently stumbling across some C# Linq to SQL DataContext misbehavior when retrieving a data set, changing it and invoking SubmitChanges to save the changes back to the database. I searched around and found this SO-Question pointing out…
Thomas
  • 76
  • 8
-1
votes
2 answers

C# WPF Databinding and Datacontext

I am (new in C# and WPF and) trying to bind data from more sources (class properties) and I am a bit confused from different guides and advices. I want to dynamically add Users in userList and showing for example the last insert and whole list at…
dreamer
  • 63
  • 4
-1
votes
1 answer

multi Datacontext wpf

Who can explain to me how to use two different datacontext ? this is my file.xaml.cs : public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DataContext = new string[] { "Female", "Male",…
astrocurieux
  • 53
  • 1
  • 8
-1
votes
2 answers

Setting datacontext inside ViewModel

I have a MainWindowView that has a grid with 2 columns each having 1 UserControl View. MainWindowView constructor creates instance of MainWindowVM and sets the data context to this new instance. this.DataContext = new MainWindowVM(this) Now…
-1
votes
1 answer

How can I bind to the View's DataContext and not the innermost DataContext?

Some pseudo-code to serve as an example:
DonBoitnott
  • 10,787
  • 6
  • 49
  • 68
-1
votes
1 answer

Multi-level databinding on UserControl menu dependant on each other

I have a property Tours : Tours is an ObservableCollection of class Tour Each "Tour" has an ObservableCollection Parties of class Partie Each Partie has an ObservableCollection Equipes of class Equipe I have 3 menus : The first is is bond…
maxeber
  • 71
  • 1
  • 10
-1
votes
1 answer

Why does this.datacontext (Window) show data from viewModel and FrameContent.datacontext (page) does not?

Why does this.datacontext (Window) show data from viewModel and FrameContent.datacontext (page) does not? Currently, I load the data from a page's view to the window. Instead of loading it directly to the dataContext of the window, I want to load it…
TimvM
  • 1
  • 2
-1
votes
1 answer

implement query pattern in C# code without using data context

I am using linq to sql framework in my C# code. I would like to implement query pattern for a scenario ( check if a given organisation is valid). how can this be done without using data context. I do not want to use or create a data context for the…
V. B Chan
  • 7
  • 4
-1
votes
2 answers

View model doesn't get updated to DataContext

I have a working program where the view model feed the data to the view. This is done in the constructor and also in a Refresh() method, as shown below. I usually put a private property referring to the view model because I want to omit casting when…
Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
1 2 3
98
99