Binding a combobox in XAML to a childwindow property

Posted by AlexB on Stack Overflow See other posts from Stack Overflow or by AlexB
Published on 2010-05-07T20:26:08Z Indexed on 2010/05/07 20:28 UTC
Read the original article Hit count: 261

Filed under:
|
|

Hi,

I want to display a child window that contains a combobox with several values coming from one of the child window's property:

public partial class MyChildWindow : ChildWindow
{
    private ObservableCollection<MyClass> _collectionToBind = // initialize and add items to collection to make sure it s not empty...

    public ObservableCollection<MyClass> CollectionToBind
    {
        get { return _collectionToBind; }
        set { _collectionToBind = value; }
    }
}

How do I bind in XAML my combobox to the ComboBoxContent collection (both are in the same class)? I've tried several things such as:
<ComboBox x:Name="linkCombo" ItemsSource="{Binding Path=CollectionToBind }" DisplayMemberPath="Description">

I've only been able to bind it in the code behind file and would like to learn the XAML way to do it.

Thank you!

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about xaml