Click here to Skip to main content
15,885,216 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Eddy Vluggen16-Oct-21 3:13
professionalEddy Vluggen16-Oct-21 3:13 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Gerry Schmitz16-Oct-21 9:46
mveGerry Schmitz16-Oct-21 9:46 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? --- Solved Pin
Member 1539432817-Oct-21 4:44
Member 1539432817-Oct-21 4:44 
GeneralRe: How do I create xy plots with WPF APP (.NET Framework)? Pin
Gerry Schmitz17-Oct-21 11:30
mveGerry Schmitz17-Oct-21 11:30 
Question(xaml, wpf) ScrollViewer Binding confusion (beginner) Pin
Maximilien7-Oct-21 8:46
Maximilien7-Oct-21 8:46 
AnswerRe: (xaml, wpf) ScrollViewer Binding confusion (beginner) Pin
Richard Deeming7-Oct-21 21:47
mveRichard Deeming7-Oct-21 21:47 
AnswerRe: (xaml, wpf) ScrollViewer Binding confusion (beginner) Pin
Gerry Schmitz8-Oct-21 9:57
mveGerry Schmitz8-Oct-21 9:57 
QuestionCurrency Entry Issue Pin
Kevin Marois7-Oct-21 7:23
professionalKevin Marois7-Oct-21 7:23 
AnswerRe: Currency Entry Issue Pin
Richard Deeming7-Oct-21 21:44
mveRichard Deeming7-Oct-21 21:44 
GeneralRe: Currency Entry Issue Pin
Kevin Marois8-Oct-21 6:03
professionalKevin Marois8-Oct-21 6:03 
QuestionQuick MVVM Design Question Pin
Kevin Marois5-Oct-21 7:34
professionalKevin Marois5-Oct-21 7:34 
AnswerRe: Quick MVVM Design Question Pin
Mycroft Holmes5-Oct-21 13:39
professionalMycroft Holmes5-Oct-21 13:39 
AnswerRe: Quick MVVM Design Question Pin
Pete O'Hanlon5-Oct-21 20:26
mvePete O'Hanlon5-Oct-21 20:26 
GeneralRe: Quick MVVM Design Question Pin
Richard Deeming5-Oct-21 21:34
mveRichard Deeming5-Oct-21 21:34 
GeneralRe: Quick MVVM Design Question Pin
Gerry Schmitz6-Oct-21 9:52
mveGerry Schmitz6-Oct-21 9:52 
AnswerRe: Quick MVVM Design Question Pin
#realJSOP9-Nov-21 23:37
mve#realJSOP9-Nov-21 23:37 
QuestionPage/Frame Pin
michaelbarb23-Sep-21 10:12
michaelbarb23-Sep-21 10:12 
AnswerRe: Page/Frame Pin
Gerry Schmitz24-Sep-21 12:48
mveGerry Schmitz24-Sep-21 12:48 
GeneralRe: Page/Frame Pin
michaelbarb24-Sep-21 13:24
michaelbarb24-Sep-21 13:24 
QuestionStuck with Weird Exceptions Pin
Kevin Marois7-Sep-21 13:51
professionalKevin Marois7-Sep-21 13:51 
I have a Purchase Order Creation window that has dialogs to allow the user to add items to the PO. The main view model is AddEditPurchaseOrderViewModel. There are different types of items such as Equipment, Lumber, Hardware, etc, that can be added and each has its own View and VM.

In each window the user must select the item they want (Equipment, Hardware, etc) and any number of Sequence Sheets. For each Sequence Sheet selected a new line item created an added to the Purchase Order. So, if the user selects Lumber for 3 Sequence Sheets, then 3 Lumber line items are added to the PO. To create the line items I am cloning the initial line item, changing a few properties on it, and adding it to the PO.

Here's a pic of what I'm working on.

All of a sudden now, my Clone class is throwing bizzare errors. It's telling me that the dialog's viewmodel is not serializable. It doesn't need to be - the entity I get from the VM's is what's being cloned.

Here's my AddPOItem Method
private void AddPOItemExecuted()
{
    _PurchaseOrderDialogBase vm = null;

    // Create a new default PO item
    var poItem = new PurchaseOrderItemEntity
    {
        PurchaseOrderHeaderId = PurchaseOrderHeader.Id,
        JobId = PurchaseOrderHeader.JobId,
        PurchaseOrderKind = PurchaseOrderHeader.PurchaseOrderKind
    };

    // Argument class
    var args = new AddEditPOItemArgsModel
    {
        LocationId = SelectedLocation.Id,
        POItem = poItem,
        SequenceSheets = _sequenceSheets,
        POType = PurchaseOrderHeader.PurchaseOrderType
    };

    switch (PurchaseOrderHeader.PurchaseOrderType)
    {
        // Add Equipment to the PO
        case Entities.Enums.PurchaseOrderType.Equipment:
            if (SelectedVendor.Id == AppCore.DNACompany.Id ||
                SelectedVendor.Id == AppCore.ParagonCompany.Id)
            {
                vm = new AddEditEquipmentFromInventoryViewModel(args, "Add Equipment Item");
            }
            else
            {
                vm = new AddEditPOItemViewModel(args, "Add Equipment Item", SelectedVendor.Id);
            }
            break;

        // Add Lumber to the PO
        case Entities.Enums.PurchaseOrderType.Lumber:
            if (SelectedVendor.Id == AppCore.DNACompany.Id ||
                SelectedVendor.Id == AppCore.ParagonCompany.Id)
            {
                vm = new AddEditLumberFromInventoryViewModel(args, "Add Lumber Item");
            }
            else
            {
                vm = new AddEditLumberPOItemViewModel(args, "Add Lumber Item");
            }
            break;

        // OTHER CASE STATEMENTS OMMITED
    }

    if (vm != null)
    {
        DialogResultEx dialogResult = DialogService.ShowDialog(vm, typeof(MainWindowView));

        if ((bool)dialogResult.DialogResult)
        {
            // For Equipment and Tools, only add one line item
            if (PurchaseOrderHeader.PurchaseOrderType == Entities.Enums.PurchaseOrderType.Equipment ||
                PurchaseOrderHeader.PurchaseOrderType == Entities.Enums.PurchaseOrderType.Tools)
            {
                poItem.EntityState = EntityState.New;
                PurchaseOrderHeader.PurchaseOrderItems.Add(poItem);
            }
            else
            {
                // For all other types, add one line item for each selected Lot
                var selectedSheets = vm.SequenceSheetInfos.Where(x => x.IsSelected).ToList();
                foreach (var selectedSheet in selectedSheets)
                {
                    // Clone the line item
                    var newItem = poItem.Clone();    //<============= THROWS HERE

                    // Adjust properties
                    newItem.JobSequenceSheetId = selectedSheet.JobSequenceSheetId;
                    newItem.EntityState = EntityState.New;
                    newItem.PlanElevation = selectedSheet.JobLotInfo;

                    // Add the Line Item to the PO
                    PurchaseOrderHeader.PurchaseOrderItems.Add(newItem);
                }
            }
        }
    }
}
and my Clone method
public static T Clone<T>(this T source)
{
    if (!typeof(T).IsSerializable)
    {
        throw new ArgumentException("The type must be serializable.", nameof(source));
    }

    if (ReferenceEquals(source, null))
    {
        return default;
    }

    using (Stream stream = new MemoryStream())
    {
        IFormatter formatter = new BinaryFormatter();
        formatter.Serialize(stream, source);
        stream.Seek(0, SeekOrigin.Begin);
        return (T)formatter.Deserialize(stream);
    }
}

And here's a pic of the error. Not that the type passed in is PurchaseOrderItemEntity, which IS serializable, yet the exception tells me the AddEditPOItemViewModel is not serializable. Th is doesn't make any sense. I get this regardless of which dialog I opened and the message shows that VM's name.

Anyone have any idea what's going on?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

AnswerRe: Stuck with Weird Exceptions Pin
Richard Deeming7-Sep-21 21:28
mveRichard Deeming7-Sep-21 21:28 
GeneralRe: Stuck with Weird Exceptions Pin
Kevin Marois8-Sep-21 4:58
professionalKevin Marois8-Sep-21 4:58 
QuestionDisable ComboBox Hyperlinks Pin
Kevin Marois19-Aug-21 12:43
professionalKevin Marois19-Aug-21 12:43 
AnswerRe: Disable ComboBox Hyperlinks Pin
Richard Deeming19-Aug-21 21:35
mveRichard Deeming19-Aug-21 21:35 
GeneralRe: Disable ComboBox Hyperlinks Pin
Kevin Marois20-Aug-21 4:36
professionalKevin Marois20-Aug-21 4:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.