使用 RIA 服务和 Silverlight 4 编辑子窗口中的数据

发布于 2024-08-29 17:01:30 字数 268 浏览 1 评论 0原文

使用 RIA 服务和 Silverlight 4 时是否可以在 SilverLight 子窗口中编辑数据?这听起来是一个足够简单的问题,但我无法让任何场景组合发挥作用。

简而言之,我正在查看通过 DomainDataSource 填充的网格中的数据。我不想在同一屏幕上编辑数据(这是所有 Microsoft 示例似乎都使用的模式),而是想打开一个子窗口,编辑数据并返回。当然,这是一种常见的设计模式。

如果有人知道使用这种模式的示例,那么我们将不胜感激。

谢谢, 里克·阿瑟

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 in 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

方觉久 2024-09-05 17:01:30

这是使用 ChildWindow 的 Microsoft 示例。它使用 RIA 服务,但不使用 MVVM。

它不能解决我遇到的问题 实体在我希望它们之前就附加到我的上下文,但除此之外还可以执行您正在寻找的操作。

以下是相关代码,可帮助您节省下载 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; }
    }

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; }
    }
妞丶爷亲个 2024-09-05 17:01:30

此处发现的 MVVM light Toolkit 具有视图模型之间的消息传递,以获取更多信息,请检查上面的站点。如果您需要示例,请写信。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文