datacontext

Converting from normal list data to a database in wpf xaml

僤鯓⒐⒋嵵緔 提交于 2019-12-11 14:15:07
问题 So I have been trying to fix many errors in my system for a while and I'm pretty close to being done. One of these errors resulted in me creating a simple list that is the equivalent of my database fields. As we all know, this is is stupid for a lot of data - and now I've finished with test data, it's time to implement a database connection. So below are the code files that I am using and descriptions with them: DBDisplayViewModel.cs public class DBDisplayViewModel { public ICollectionView

Entity Framework 4.1 Code First with N-Tier saving double

隐身守侯 提交于 2019-12-11 12:11:54
问题 I have a WCF project with a entities with lots of children. I have a business layer and a data access layer, in the data access layer I have repositories that retrieve and save to my database. My understanding of EF is that you create and destroy the DataContext as and when you need it. As an example, lets say I have the a Person entity, and a Book entity (this is not my application, but just to try and illustrate the problem). Assume Person looks as follows. Person string Name vitual

ContextMenu on TreeView-Element in MVVM-style

帅比萌擦擦* 提交于 2019-12-11 11:08:00
问题 I have the "simple" task to have a ContextMenu on a TreeView(Element) that is done in MVVM-way. When searching the web I found some solutions that I could bring to work with buttons etc. but not with the TreeView. I think the problem is with setting the ItemsSource-Property of TreeView that gives every single item an own DataContext. Here's my little Test-App where you can see the principle working for button but not for the TreeView-Elements: MainWindow.xaml: <Window x:Class="ContextMenu

Saving changes very slow via Datacontext

岁酱吖の 提交于 2019-12-11 09:33:09
问题 I am working on MVC3 .NET Project with Entity framework and SQL Azure Database. When i try to save multiple records at once in a table it takes several minutes to finish the operation! I use the same Datacontext for adding Object and saving changes also i've tried to use multiple Datacontexts but the results are the same. 回答1: In addition, please check out the following documents: Entity Framework performance considerations: http://msdn.microsoft.com/en-us/library/cc853327.aspx SQL Azure

How to set the data context of a grid in a WPF page to an other WPF window

心不动则不痛 提交于 2019-12-11 09:28:55
问题 I am a newbie to WPF.I have a WPF window and in the same project I have a WPF page.The page contains the keyboard layout to be loaded into the window.The window has a frame whose source is set to the page.Now all the buttons in page are WPF custom controls.These controls have two dependency properties like IsCapsOn and IsShiftOn. These dependency properties when changed changes the text on buttons("a" becomes "A" indicating that caps is pressed). The above dependency properties are binded to

Sorting in window datacontext in WPF

旧街凉风 提交于 2019-12-11 09:26:28
问题 Another question related to this one. I have a List<SortableObjects> that is the DataContext of my MainWindow. I use that list to populate a ListBox and a ComboBox . When I sort the items, both the ComboBox and the ListView get updated all right. But now I need the ComboBox to be sorted in a different way than the ListView . I. E. If the object were a Person, in the ComboBox , I'd need to sort them by LastName, but in the ListView , by birthday. How can I achieve this? Thanks! 回答1: Use

“Property 'Path' does not have a value”

陌路散爱 提交于 2019-12-11 08:26:25
问题 I'm using the following xaml to fill the dataContext: DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}" The application works fine, but Cider complains that I must set the Path property. I'm interested in the entire object, and not a specific property though. I hope there's a way to get the designer support back!! 回答1: Have a look at section 2.3.8.7 here (you'll need to scroll down a bit): Visual Studio 2008 Service Pack 1 (SP1) Readme Try changing your tag to

How do I extract ETAG from a WCF Dataservices response?

◇◆丶佛笑我妖孽 提交于 2019-12-11 07:58:16
问题 I've been trying to get an answer to this question for quite some time. Since the WCF Dataservice isn't thread safe, and often it needs to be recreated, once I query my datastore for a record, how do I extract the ETAG from that response so I can use it when I reconstruct my datacontext? 回答1: That depends on which language/library you're using on the client and which format you're using on the wire (ATOM vs JSON). The ETag is stored in the payload and in case of a single entity payload also

Force the Opening of the DataContext's Connection (LINQ)

邮差的信 提交于 2019-12-11 07:30:48
问题 When you create a datacontext, its connection is closed until you retrieve objects and it stays open when you retrieve objects in case you use deferred operators or late binding. Is it possible (in an extension method of the datacontext of not) to force the datacontext to open its Connection without querying LINQ with LINQ or doing a fake query to the database with ExecuteQuery, ExecuteCommand, etc? Thanks 回答1: You can use the DataContext.Connection property to retrieve the connection, and

WPF datacontext parent / child usercontrols

人走茶凉 提交于 2019-12-11 07:17:19
问题 I have a WPF application that is made up of a window containing a usercontrol which, in turn, contains another child usercontrol. I have a dependencyProperty for a SelectedName in my second usercontrol's viewmodel. I want the parent control to be able to either access this property and display the SelectedName in a textblock in the parent control. I'm a bit stuck as to how to do this. There seem to be 2 ways I could go (if I understand this correctly) 1. Add an event on the child control and