datacontext

Insert valve from listview to Sql (using linq to sql)

混江龙づ霸主 提交于 2019-12-25 02:26:10
问题 i have three different Listview which is Item,quantity and price. All the items for the listview will be added from a textbox. I would like to know how can i store the listview items into my SQl database. Here is the code i use to add item into the listview. private void SalesAddItemBtn_Click(object sender, RoutedEventArgs e) { ListProductName.Items.Add(ComSalesProduct.Text); ListProductQuantity.Items.Add(txtSalesQuantity.Text); ListProductCost.Items.Add("RM " + txtSalesCost.Text+".00"); }

UserControl DataContext Binding

自作多情 提交于 2019-12-24 23:06:08
问题 I have three projects in my solution: My main WPF Application which contains a MainWindow + MainViewModel UserControl Library with a UserControl ( ConfigEditorView ) UIProcess class with the ViewModel for the UserControl ( ConfigEditorViewModel ) In my MainWindow I want to use the UserControl with the ViewModel of UIProcess. First I set the UserControl in my MainWindow : <TabItem Header="Editor"> <Grid> <cel:ConfigEditorView DataContext="{Binding ConfEditModel, NotifyOnSourceUpdated=True,

How do I use an explicitly implemented interface property and wpf visiblity together properly?

走远了吗. 提交于 2019-12-24 08:49:43
问题 I have the following situation: I have a few ViewModel objects, some of which implement an interface ISomeInterface , some don't. The interfaces exposes a property called SomeEnumeration ( IEnumerable<T> ). For example: public sealed class ViewModelA : ViewModelBase, ISomeInterface { // ... IEnumerable<Foo> ISomeInterface.SomeEnumeration { get { ...; } } } public sealed class ViewModelB : ViewModelBase { // ... } My XAML, so far, has been designed in a way that both of the ViewModels happen

Select an item two or more times

不羁岁月 提交于 2019-12-24 07:46:56
问题 I have a Listbox with its DataContext. When I select an item, I can't select the same again. This is not a problem when there are many objects, but sometimes, a post-service return me a list with only one element, and if the user select the element and he wants select it again, he will not can do it. Anyone knows how to resolve this problem Anyway, thanks! 回答1: Try this, it works for me.. :) public void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { ListBox listBox = sender

DataContext Refresh and PropertyChanging & PropertyChanged Events

主宰稳场 提交于 2019-12-24 05:47:12
问题 I'm in a situation where I am being informed from an outside source that a particular entity has been altered outside my current datacontext. I'm able to find the entity and call refresh like so MyDataContext.Refresh(RefreshMode.OverwriteCurrentValues, myEntity); and the properties which have been altered on the entity are updated correctly. However neither of the INotifyPropertyChanging INotifyPropertyChanged appear to be raised when the refresh occurs and this leaves my UI displaying

Can't access datacontext in multivalueconverter

我怕爱的太早我们不能终老 提交于 2019-12-24 04:55:07
问题 I have a usercontrol which I need to set a specific DataContext on. The usercontrol uses multivalueconverters. However, the binding in multivalueconverter fails to use the datacontext. It works fine for regular value converters. Anyone know what is going on? To clarify, below code is not similar to my real code, it's just a sample reproducing my issue. FOr example, my multivalueconverters take more than one argument. XAML: <Window x:Class="MultConvTest.Window1" xmlns="http://schemas.microsoft

Switch `ConnectionStrings` between local and remote with Linq to SQL

霸气de小男生 提交于 2019-12-24 02:35:12
问题 First, by Remote I mean a central dedicated SQL Server on our Network. By Local I mean a local SQL Express install. My situation is in house only. No cloud services, external sites, etc. My app allows the user to work disconnected but in order to minimize traffic and a few other issues as well I would like to allow them to connect straight to the central server either automatically whenever it is available and/or when they set a setting choosing Central Server. Are setup is quite simple. A

Populate datagrid using Datacontext in C# WPF

心已入冬 提交于 2019-12-24 02:04:19
问题 I'm trying to get data from file. The file first has three lines of text that describes the file, then there is a header for the data below. I've managed to extract that. What I'm having problems is getting the data below the header line. The data below the header line can look like "1 2 3 4 5 6 7 8 9 abc". DataGrid dataGrid1 = new DataGrid(); masterGrid.Children.Add(dataGrid1); using (TextReader tr = new StreamReader(@filename)) { int lineCount = 1; while (tr.Peek() >= 0) { string line = tr

Using Hashtable as DataContext (for WPF/XAML Binding)

风流意气都作罢 提交于 2019-12-23 17:53:16
问题 In code I have a Hashtable named MyHashtable . This Hashtable contains an element with key= "Value" , value= 3 . I'm currently trying to bind this value to a textbox. This is my XAML code: <TextBlock Margin="4" Text="{Binding MyHashtable[Value]}" /> <TextBlock Margin="4" DataContext="{Binding MyHashtable}" Text="{Binding [Value]}" /> Q: Why does the second binding not work, while the first binding works just great? For the second binding I have tried other bindings for the text, such as:

EF Fault when retrieving data: wrong table name in SQL

随声附和 提交于 2019-12-23 15:53:48
问题 I have a simple edmx with 2 tables. The tables are related by a single Navigation Property . (1 to many). When I run my code I get an Exception: "Invalid Object Name dbo.Enquiries" There is no dbo.Enquiries in the database (it is actually called dbo.Enquiry ), so the error itself is self explanatory. But where is it finding that Name, and how do I fix it? Edited to show code as requested. var foo = (from d in context.Dealerships join e in context.Enquiry on d.Id equals e.DealershipId where (d