WPF Application master detail

Markus Freitag 3,786 Reputation points
2020-07-09T06:33:45.65+00:00

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

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,772 questions
0 comments No comments
{count} votes

11 answers

Sort by: Most helpful
  1. Markus Freitag 3,786 Reputation points
    2020-07-09T11:21:39.347+00:00

    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

    0 comments No comments

  2. Markus Freitag 3,786 Reputation points
    2020-07-09T12:47:35.397+00:00

    Hi Peter,

    looks really good. The code 11711--1.pngis manageable.

    11721--thegoal.png

    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

    0 comments No comments

  3. 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
    11723-cwpf-1.jpg
    11724-cwpf-2-ordernumber-materialnumber-primary.jpg


  4. Markus Freitag 3,786 Reputation points
    2020-07-10T13:38:35.073+00:00

    11745-probleme.pdf11806-cwpf-size-clear.jpg> 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 PDF

    Regards Markus


  5. 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 number

    how-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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.