locked
How do I bind the ModelItem collection to combobox in XAML RRS feed

  • Question

  • Hi,

    I need to create an custom activity with a combo box that need to display all the activity name within the same parent.

    Below are the code snippets that failed to list out the activities name. Anyone has any ideas to make this work?

    <ComboBox Name="ActivityList" 
      ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type sas:Sequence}},Path=ModelItem.Activities}"
      DisplayMemberPath="DisplayName"  
      SelectedValuePath="DisplayName"
     />
    

    thanks.

    Friday, October 8, 2010 7:17 AM

Answers

  • Try

    <ComboBox ItemsSource="{Binding Path=ModelItem.Parent, Mode=OneWay}" DisplayMemberPath="DisplayName" SelectedValuePath="DisplayName" SelectedIndex="0" />

    • Marked as answer by Andrew_Zhu Friday, October 15, 2010 6:38 AM
    Saturday, October 9, 2010 9:23 AM

All replies

  • Try

    <ComboBox ItemsSource="{Binding Path=ModelItem.Parent, Mode=OneWay}" DisplayMemberPath="DisplayName" SelectedValuePath="DisplayName" SelectedIndex="0" />

    • Marked as answer by Andrew_Zhu Friday, October 15, 2010 6:38 AM
    Saturday, October 9, 2010 9:23 AM
  • Try

    <ComboBox ItemsSource="{Binding Path=ModelItem.Parent, Mode=OneWay}" DisplayMemberPath="DisplayName" SelectedValuePath="DisplayName" SelectedIndex="0" />


    Thanks Hong Wang.

    It works OK now, but if the is no activities on the items source or the items source referring to another sequence that might not have any activities attached with it, I will get an ArgumentNullException: Value cannot be null... How can I solve this proble?

     

    Monday, October 11, 2010 8:47 AM