0

子オブジェクトの多対多およびバインドリストをサポートするようにDataFormを曲げようとしています。オブジェクトの表示を制御し、onchangeイベントにアクセスできるようになりました。

例えば:

OfferEditorForm.AutoGeneratingField += new EventHandler<DataFormAutoGeneratingFieldEventArgs>(OfferEditorFormGeneratingField);

そして、これが私の小さなオーバーライドです:

if (e.PropertyName == "Client")
        {
            var stack = new StackPanel();
            var dataField = new DataField { Content = stack, Label = "Client:" };
            var binding = new Binding("CustomerClients") { Source = _viewModel };
            var combo = new ComboBox
            {
                DisplayMemberPath = "Name",
                Name = "OfferEditForm_Client",
                SelectedItem = _viewModel.CustomerLoyaltyProgramOffer.Client
            };

            combo.SetBinding(ComboBox.ItemsSourceProperty, binding);
            combo.SelectionChanged += new SelectionChangedEventHandler(CustomerClients_SelectionChanged);
            stack.Children.Add(combo);
            dataField.Content.UpdateLayout();
            e.Field = dataField;
        }

SelectedChangedイベントを取得し、ビューモデルで、フォームの現在のアイテムとして設定されているアイテムを更新しています。

void CustomerClients_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        FrameworkElement frameworkElement = sender as FrameworkElement;
        ComboBox comboBox = (ComboBox)frameworkElement.FindName("OfferEditForm_Client");
        if (comboBox != null)
        {
            _viewModel.CustomerLoyaltyProgramOffer.Client = (CustomerClient)comboBox.SelectedItem;
            _viewModel.CustomerLoyaltyProgramOffer.CouponImage = "OMG!";
        }
    }

変更を送信すると、この例では、CouponImageがドメインサービスのUpdateメソッドに送信されますが、クライアントはまだNULLです。

CustomerLoyaltyProgramOfferは、通知プロパティの変更を発生させないようです。

これは子オブジェクトの問題ですか?私はこれについてすべて間違っていますか?編集テンプレート全体を作成する必要がありますか?

4

1 に答える 1

0

Model.designer.csのCustomerLoyaltyProgramOfferクラスのClientプロパティに[Association]属性を設定する必要があります

詳細については、次の2つのリンクを参照してください。

http://tech.rofas.net/post/Working-with-associated-POCO-objects-in-WCF-RIA-Services.aspx http://blogs.msdn.com/digital_ruminations/archive/2009/11/18 /composition-support-in-ria-services.aspx

于 2010-02-02T20:26:26.520 に答える