datacontext

How to set the DataContext for a View created in DataTemplate from ViewModel

半世苍凉 提交于 2019-12-21 17:49:07
问题 There are questions on this already, but they don't answer my question. For example: <ContentControl.Resources> <DataTemplate DataType="{x:Type Databinding:RedScreenViewModel}" > <Databinding:RedScreen DataContext="{Binding}"/> </DataTemplate> <DataTemplate DataType="{x:Type Databinding:BlueScreenViewModel}"> <Databinding:BlueScreen DataContext="{Binding}" /> </DataTemplate> </ContentControl.Resources> As you can see I am attempting to set the DataContext for the created View hoping that it

Can't access related data after disposal of DataContext in Linq to SQL

非 Y 不嫁゛ 提交于 2019-12-21 17:12:46
问题 Restated my Question, old Text Below As I am still hoping for an answer I would like to restate my question. Image I have a GUI with two lists, one that shows a List of all entries to a database tblOrders and another one that shows the items in each order. I can use Linq2sql or EF to get all orders from the database, like so: using (DataClasses1DataContext DataContext = new DataClasses1DataContext()) ListOfOrders = DataContext.tblOrder.ToList(); I can display these order in a list or

Ninject and DataContext disposal

为君一笑 提交于 2019-12-21 06:55:13
问题 I'm using Ninject to retrieve my DataContext from the kernel and I was wondering if Ninject automatically disposes the DataContext, or how he handles the dispose() behaviour. From own experiences I know disposing the datacontext is pretty important and that whenever you create a direct object of the DataContext (as in: new DataContext()) you should use a using() block. My question thus is: When im retrieving my DataContext from the kernel, should I still have to use a using() block? Or does

Ninject and DataContext disposal

℡╲_俬逩灬. 提交于 2019-12-21 06:53:18
问题 I'm using Ninject to retrieve my DataContext from the kernel and I was wondering if Ninject automatically disposes the DataContext, or how he handles the dispose() behaviour. From own experiences I know disposing the datacontext is pretty important and that whenever you create a direct object of the DataContext (as in: new DataContext()) you should use a using() block. My question thus is: When im retrieving my DataContext from the kernel, should I still have to use a using() block? Or does

Multiple/Single *.edmx files per database

Deadly 提交于 2019-12-21 04:54:15
问题 I have a project that interacts with a database through ADO.net Data Services. The database is large ( almost 150 tables with dependencies ). The project started a few years ago and there were DataSets used then; now we're moving towards entity model relationships. The model is growing since we are adding more tables we need to work with. Is this a right way to manage all that?. Meaning should I have a SINGLE database model file to have single data context? What are drawbacks and how do you

Saving FrameworkElement with its DataContext to image file does no succeed

て烟熏妆下的殇ゞ 提交于 2019-12-21 04:48:18
问题 I have a simple UserControl called UserControl1 that contains a TextBlock: <UserControl x:Class="WpfApplication2.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"> <Grid> <TextBlock Text="{Binding}"/> </Grid> </UserControl

Enabling Service Broker in SQL Server 2008

夙愿已清 提交于 2019-12-20 08:24:54
问题 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

WPF Show data from multiple DataContexts in ToolTip of ItemsControl

不问归期 提交于 2019-12-19 17:42:45
问题 I am trying to display a tooltip for an item generated by an ItemsControl that needs to pull data from conceptually unrelated sources. For example, say I have an Item class as follows: public class Item { public string ItemDescription { get; set; } public string ItemName { get; set; } } I can display the Item within an ItemsControl with a tooltip as follows: <ItemsControl x:Name="itemsControl" ItemsSource="{Binding Items}"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding

WPF Show data from multiple DataContexts in ToolTip of ItemsControl

ぃ、小莉子 提交于 2019-12-19 17:42:15
问题 I am trying to display a tooltip for an item generated by an ItemsControl that needs to pull data from conceptually unrelated sources. For example, say I have an Item class as follows: public class Item { public string ItemDescription { get; set; } public string ItemName { get; set; } } I can display the Item within an ItemsControl with a tooltip as follows: <ItemsControl x:Name="itemsControl" ItemsSource="{Binding Items}"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding

KeyedCollection and d:DataContext Design Error

别说谁变了你拦得住时间么 提交于 2019-12-18 17:37:15
问题 See the update below for VS2013. When using a class as a d:DesignInstance that exposes a KeyedCollection<TKey, TItem> , the XAML designer complains with the following warning: The number of generic arguments provided doesn't equal the arity of the generic type definition. Parameter name: instantiation The problem can be reproduced with the following simple program: <Window x:Class="Test.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas