mardi 20 février 2018

WPF showing a user control in dialog using reflection

Currently, i have the following code inside a Switch / Case. This codes works fine for me, but I looking for a solution on how I can do this using reflection. Otherwise, I have to repeat the following code 70 times.

                    var popupViewModel = new NetworkNameDescriptorViewModel(_eventAggregator)
                    {
                        DescriptorContext = new DescriptorModel {
                          Hex = obj.Hex,
                          Tag = obj.Tag,
                          Length = obj.Length,
                          Name = obj.Name
                        }
                    };
                     var popupView =_container.Resolve<NetworkNameDescriptor.NetworkNameDescriptor>();
                    popupView.DataContext = popupViewModel;

                    Window window = new Window()
                    {
                        Title = "Network name descriptor",
                        Content = popupView
                    };
                    window.Show();





Aucun commentaire:

Enregistrer un commentaire