WPF ComboBox - binding to a ReadOnlyList

WPF ComboBox - binding to a ReadOnlyList

Old forum URL: forums.lhotka.net/forums/t/4987.aspx


Goblin posted on Wednesday, June 18, 2008

I'm pretty new to CSLA, so may be an easy question.

What I want to do is provide the user with a combobox bound to a list (VatViews) when selecting a VatView for a given Account.

I can see the binding works, because the object changes behind the scenes, when the user picks a value in the ComboBox. What doesn't work is the initial DataBind from a loaded account. The object has the correct value in the property, but the combobox defaults to an empty value.

I'm guessing it is the good ol'e equality 'problem' in WPF that is causing it, but does anyone have a solution?

Code snippets:

UI-Code:

ComboBox _combo = new ComboBox();
Binding _binding = new Binding();
_binding.Source = VatViews.Get(...);
_combo.SetBinding(ComboBox.ItemSource,_binding);

Account _account = Account.New();
Binding _accountBinding = new Binding("VatInformation");
_accountBinding.Source = _account;
_combo.SetBinding(ComboBox.SelectedValue,_accountBinding);

Domain code:

public class Account : BusinessBase<Account>
{
    ...
    public VatView VatInformation
    {
       get { return GetProperty<VatView>(VatProperty);}
       set { SetProperty<VatView>(VatProperty,value); }
    }
    ...
}


public class VatView : ReadOnlyBase<VatView>{}

public class VatViews : ReadOnlyListBase<VatViews,VatView>{}

Copyright (c) Marimer LLC