datacontext

In LINQ-SQL, wrap the DataContext is an using statement - pros cons

岁酱吖の 提交于 2019-12-03 08:29:29
问题 Can someone pitch in their opinion about pros/cons between wrapping the DataContext in an using statement or not in LINQ-SQL in terms of factors as performance, memory usage, ease of coding, right thing to do etc. Update : In one particular application, I experienced that, without wrapping the DataContext in using block, the amount of memory usage kept on increasing as the live objects were not released for GC. As in, in below example, if I hold the reference to List of q object and access

WPF data context for design time and run time

混江龙づ霸主 提交于 2019-12-03 03:58:25
I'm learning WPF, MVVM Light and the ViewModelLocator pattern and running into difficulties with my main window's data context. public class ViewModelLocator { public ViewModelLocator() { var mainModel = new MainModel(); Main = new MainViewModel(mainModel); } public MainViewModel Main { get; private set; } public static ViewModelLocator Instance { get { return Application.Current.Resources["Locator"] as ViewModelLocator; } } } and in my app.xaml: <Application.Resources> <viewModels:ViewModelLocator x:Key="Locator" /> </Application.Resources> When I set the data context in my main window using:

WPF ListBox Commands within ListBoxItem MVVM Command Binding

拜拜、爱过 提交于 2019-12-02 16:13:04
问题 I have been trying to find a way to have command buttons within my ListBoxItem's of a ListBox control. I use MVVM and Command Binding to the DataContext via ICommand interface . I am unable to find a way to bind to the Views DataContext from within the ListBox ItemsSource . I continue to get a Command "Not Found" error . Can anyone help me understand how to accomplish this. I believe that it has something to do with the command binding path, but I am unsure. Any help or direction would be

Enabling Service Broker in SQL Server 2008

独自空忆成欢 提交于 2019-12-02 15:24:42
I am integrating SqlCacheDependency to use in my LinqToSQL datacontext. I am using an extension class for Linq querys found here - http://code.msdn.microsoft.com/linqtosqlcache I have wired up the code and when I open the page I get this exception - "The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported. Please enable the Service Broker for this database if you wish to use notifications." its coming from this event in the global.asax protected void Application_Start() { RegisterRoutes(RouteTable.Routes); //In Application

Usercontrol using wrong Datacontext

谁说胖子不能爱 提交于 2019-12-02 15:21:51
问题 I have a UserControl that is used in a parent control in this way: <Views:TranslationTextInput Translation="{Binding SelectedEntity.Name}"/> The parent control DataContext is a ViewModel containing the SelectedEntity Property. In my child UserControl I define a new ViewModel as the DataContext: <UserControl.DataContext> <vm:TranslationTextInputViewModel x:Name="vm"></vm:TranslationTextInputViewModel> </UserControl.DataContext> In the code behind I have: public static readonly

WPF ListBox Commands within ListBoxItem MVVM Command Binding

橙三吉。 提交于 2019-12-02 10:59:10
I have been trying to find a way to have command buttons within my ListBoxItem's of a ListBox control. I use MVVM and Command Binding to the DataContext via ICommand interface . I am unable to find a way to bind to the Views DataContext from within the ListBox ItemsSource . I continue to get a Command "Not Found" error . Can anyone help me understand how to accomplish this. I believe that it has something to do with the command binding path, but I am unsure. Any help or direction would be great. The DataContext of items in a ListBox will be the item they represent. So if your ItemsSource is

Conditional Resources Creation WPF XAML Design / Run time

自古美人都是妖i 提交于 2019-12-02 09:03:15
问题 Following a first question on WPF Cascading Binding, I remarked that I had more Resources than desired defined in both the MainWindow and the UserControls : This is well seen in Snoop the MainWindow XAML has an "instance" of a MainWindow ViewModel that paints the 2 usercontrol in green and blue additionnaly there are 2 instances of usercontrol viewmodels for each of the 2 UserControls that would paint the inner circle in red My first Intention in the Usercontrol was to be able to see " live "

Entity framework data context not in sync with database?

大城市里の小女人 提交于 2019-12-02 08:14:20
So, here is the situation - I insert an item in the database calling the AddtoObject() and then call SaveChanges(). Then, I call a stored procedure to update the currently inserted record. Then, I call the Save changes() again. The database when I query it has the correct updated value, but the entity framework context does not have the updated values..the first time..whenever I refresh the page it gets the value..but the first time it never gets the updated values. So has anyone faced a similar issue anytime ? What am I doing wrong here ? The problem is that the EF does not know what your

Conditional Resources Creation WPF XAML Design / Run time

拈花ヽ惹草 提交于 2019-12-02 05:07:47
Following a first question on WPF Cascading Binding , I remarked that I had more Resources than desired defined in both the MainWindow and the UserControls : This is well seen in Snoop the MainWindow XAML has an "instance" of a MainWindow ViewModel that paints the 2 usercontrol in green and blue additionnaly there are 2 instances of usercontrol viewmodels for each of the 2 UserControls that would paint the inner circle in red My first Intention in the Usercontrol was to be able to see " live " how my control would look like ( I painted it red to distinguish this "model" from the green and blue

Usercontrol using wrong Datacontext

筅森魡賤 提交于 2019-12-02 03:17:53
I have a UserControl that is used in a parent control in this way: <Views:TranslationTextInput Translation="{Binding SelectedEntity.Name}"/> The parent control DataContext is a ViewModel containing the SelectedEntity Property. In my child UserControl I define a new ViewModel as the DataContext: <UserControl.DataContext> <vm:TranslationTextInputViewModel x:Name="vm"></vm:TranslationTextInputViewModel> </UserControl.DataContext> In the code behind I have: public static readonly DependencyProperty TranslationProperty = DependencyProperty.Register("Translation", typeof(Translation),typeof