开发者

Editing Data in Child Window with RIA Services and Silverlight 4

Is it possible to edit data in a SilverLight Child window when using RIA Services and Silverlight 4? It sounds like a simple enough question, but I have not been able to get any combination of scenarios to work.

Simply put, I am viewing data i开发者_如何学运维n a grid that was populated through a DomainDataSource. Instead of editing the data on the same screen (this is the pattern that ALL of the Microsoft samples seem to use), I want to open a child window, edit the data and return. Surely this is a common design pattern.

If anyone knows of a sample out there that uses this pattern, a link would be much appreciated.

Thanks, Rick Arthur


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

It doesn't fix a problem I'm having where entities get attached to my context before I want them to be, but does what you're looking for other than that.

Here's the relevant code to save you downloading the zip:

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; }
    }


The MVVM light Toolkit found here has messeging between viewmodels for more information check above site. Please write if u need an example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜