For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
Missed that and it looked like there was some reasonable hacks to the standard DG. I have used Gerry's suggestion in the past, inserting total rows manually, it may not be grouping but you do get the sub totals.
Never underestimate the power of human stupidity
The subject really say it all, even if it sounds over-complicated. Please hang on.
I have a DataGrid. There are several columns in the DataGrid.
One of the columns contains a ListView. The listView holds several rows.
Each row contains a TextBlock and a Button.
The TextBlock's Text property contains a name, which I want to pass to my ViewModel.
I have managed to create a small example of this which should be just to "copy-paste-run".
Since it is "a lot" of code I have made a public gist to store it in. Link to source in GIT Gist[^]
* I use Visual Studio 2015 and compiling to NET 4.5.2.
* I also use Fody.PropertyChanged, then I'm not needed to manually type all stuff required for the INotifyPropertyChanged interface.
* Create a new WPF application and call it: WpfTest.
* Save the project.
* Install the Fody.Propertychanged in the NuGet Package Manager.
* Create the FodyWeavers.xml file.
* Paste all code from the Gist.
If the compiler says: "Fody: Could not find a weaver named 'PropertyChanged'. ..."
Remove the <PropertyChanged /> from the FodyWeaver.xml file and try again. That line is not neccessary for this and I don't understand why it sometimes fail when compiling.
This is what I want
If you click any of the buttons in the DataGrid I want the associated name on the same row in the ListView to be bound to the SelectedName property in the ViewModel.
I have no clue how to do the binding of the selected Textblock's Text property to the ViewModel in the View's xaml code.
For example: Press the button to the right of NameA. I then want my ViewModels SelectedName to be "NameA".
Add a click handler / delegate that "stuffs" the "selection"; i.e. "code behind". (It's PLUMBING).
And you don't need all that "property changed stuff". If you know you are refreshing all controls on a container, you can call propertychanged with "no name" (on the container) and refresh all with one statement. You need a really "slow" machine for individual "property changed" events to make a difference.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
I copied your code into a project and ran it successfully. The only thing that's different in my version is that I have a different image (obviously). Check that the image is set to a Build Action of Resource and that Copy To Output Directory is set to Do Not Copy. My successful code:
For those familiar with them, TVPs are a great way to reduce the number of calls to the database and improve performance. I use them to great effect in the MVC web app using the general technique below. In the stored procedure I use a cursor to iterate through the rows and do all the db stuff in one whack.
I copied the same routines to a WPF app I'm doing, however, and it flames out calling the proc. I've since deleted it and gone the multiple calls route so I don't remember the precise error message but in general it was barking about not liking the parameters.
I'm on the same box, same version of VS, etc. and literally copied and pasted my routines. Works in MVC, no joy in WPF.
Have any of you successfully used table value parameters in a WPF app, and if so, is there a trick I'm missing?
ADO.NET is ADO.NET; there's no difference whether you're calling it from ASP.NET, WPF, or a console application.
If it works in your ASP.NET application, but not in your WPF application, then there's a difference in the code which you haven't shown. For example, verify that Command is a SqlCommand instance, and not some other type.
Appreciate the feedback. Yeah, that was my take on it as well - ADO.NET should be ADO.NET. However, after a few decades of dealing with MS technologies, I never take that as gospel.
When I get some time I'm going to try it again as the performance difference is significant, but I eyeballed the code pretty intensely and am as sure as I ever am about such things that it was the same in both environments. I hope to be wrong about that because otherwise I'm out of ideas.
That's a nice approach. The DataTable was from an example I found on TVPs. I was focused on making the db interaction worked and never thought to convert it to something more elegant. Deadlines and all that.
I'm going to take another swing at this today. Hopefully I just fat fingered something when I cloned the MVC code I was using. Appreciate all the help.
Well, apparently the fingers are indeed fat. Tried again this morning and it worked without a fuss.
Still using DataTable approach at this point. MS says SqlDataRecord is resource abusive and recommends not creating a new one but reusing a single instance. That aside, are there any benefits to the enumerable approach over populating a data table?