Editing Data in a Child Window with RIA and Silverlight 4

Can I edit data in the SilverLight Child window when using RIA and Silverlight 4? This seems like a fairly simple question, but I have not been able to get any combination of scripts to work.

To put it simply, I am viewing data in a grid that has been populated via a DomainDataSource. Rather than editing the data in one screen (this is the template all Microsoft samples seem to use), I want to open a child window, edit the data, and return. Of course, this is a general design pattern.

If anyone knows a sample that uses this template, a link would be much appreciated.

Thanks, Rick Arthur

+2


a source to share


2 answers


This is a Microsoft sample that uses ChildWindow . It uses RIA services, but not MVVM.

This is not a problem I am having when objects are bound to my context before I want them to be , but does what you are looking for other than that.



Here is the relevant code to save the ZIP download:

private void addNewEmployee_Click(object sender, RoutedEventArgs e)
    {
        EmployeeRegistrationWindow addEmp = new EmployeeRegistrationWindow();
        addEmp.Closed += new EventHandler(addEmp_Closed);
        addEmp.Show();
    }

public partial class EmployeeRegistrationWindow : ChildWindow
    {
        public EmployeeRegistrationWindow()
        {
            InitializeComponent();
            NewEmployee = new Employee();
            addEmployeeDataForm.CurrentItem = NewEmployee;
            addEmployeeDataForm.BeginEdit();    
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            addEmployeeDataForm.CommitEdit();
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            NewEmployee = null;
            addEmployeeDataForm.CancelEdit();
            this.DialogResult = false;
        }

        public Employee NewEmployee { get; set; }
    }

      

0


a source


The MVVM light Toolkit found here has messeging between view modes for more details above the site. Please write if you need an example.



0


a source







All Articles