Hi Peter,
thanks.
Can you publish the whole project with RelayCommand? Or on your site for download.
How did you solve the material list?
Regards Markus
WPF Application master detail
Hello together,
I want to add a order number, then add a material number with quantity.
Master, Detail with C#
OrderNumber = ………
Fill the list OrderNumbers
On right site I need a MaterialList
Input: Material = …….. Quantity = ……
Add, Edit, Delete Button
Fille the list with MaterialNumbers and Quantity
Save it as XML.
Should be possible to reload it.
I'm looking for a good sample code.
Thanks in advance for your help!
Regards Markus
11 answers
Sort by: Most helpful
-
Markus Freitag 3,786 Reputation points
2020-07-09T11:21:39.347+00:00 -
Markus Freitag 3,786 Reputation points
2020-07-09T12:47:35.397+00:00 Hi Peter,
looks really good. The code is manageable.
This is a touch screen application.
The list must be a little larger. It must be possible to enter the OrderNumber specifically.I like the deletion of a line with a button. From @DaisyTian-MSFT
Can you please help me again with your experience?
Thank you in advance.
Regards Markus -
Markus Freitag 3,786 Reputation points
2020-07-10T06:23:55.517+00:00 Hi Peter,
nearly perfect!
When I start, I don't press load, otherwise crash.
OrderNumber, material numbers are PrimaryKey. The same entries should not be possible. MessageBox, if the same.
Insert a delete button for each line.
If I select a line that should be shown above, it should be possible to delete or edit. Then we need an additional update button.
Touchscreen everything a bit bigger, ARIAL 16. Will the DatagridView also automatically get bigger?Thanks in advance.
Regards Markus
-
Markus Freitag 3,786 Reputation points
2020-07-10T13:38:35.073+00:00 11745-probleme.pdf> Blockquote
how-to-implement-validation-logic-on-custom-objects
public class Order { public int OrderNumber { get; set; } public string OrderName { get; set; } public ObservableCollection<Material> Materials { get; } = new ObservableCollection<Material>(); } public class Material { public int MaterialNumber { get; set; } public decimal Quantity { get; set; } public string Comment { get; set; } }
*>"OrderNumber, material numbers are PrimaryKey. The same entries should not be possible. MessageBox, if the same."
Y
ou can use IDataError in Order class to prevent duplicate numbers. If you will use application on more then one clients with database you must use additional features.*
Only the list knows whether the number already exists, not the order or material class
if (!File.Exists(filePath)) col1 = new ObservableCollection<Order>();
Should I derive this and add the interface IDataErrorInfo?
The exchange of the template or the insertion of the delete button is not clear to me. Can you please help again?
I have summarized in the PDF what is clear and what is not.Binding:
When I select a line I have to read the Order object, then bind it to the TextBox, right? How?DeleteButton each row:
If that would still work with the delete button, it would be nice, not a must.11776-datagrid-and-buttons.pdf
I would have to merge the two examples.
I have no experience of what it depends on. I can't edit @DaisyTian-MSFT at either, crash. See PDFRegards Markus
-
Markus Freitag 3,786 Reputation points
2020-07-10T19:03:27.503+00:00 Hi Peter,
You have good approaches.
An order number is unique, material number also
Now the implementation is simply missing.
In the Microsoft example a class Person is illustrated. I need to check a list to see if it contains the order numberhow-to-implement-validation-logic-on-custom-objects
Everything done right, I need MVVM, the ViewModel is perfect. Separation UI to model.
The bottom in the DataGridColumnTemplate is not absolutely necessary now. It would be nice to have it.
The important thing would simply still be.
Unique order number, same input, error message.
Unique material number, same input, error message.When I select a row, the values should be displayed above. Perfect would be a button to apply changes.
I do not need a database, the storage as you suggested is sufficient and good.
I can only say that it would be nice if you could publish something else and say thanks in advance.
Best regards Markus.