ComboBox binding

1 posts, 0 answers
  1. Paul
    Paul avatar
    1 posts
    Member since:
    Apr 2013

    Posted 08 Apr 2013 Link to this post

    Hi,

    I have a problem regarding the comportment my ComboBox.
    First I use a combobox to display all elements in a IEnumarale<Element>.
    Then, with a button wich open a popup, the user can add an alement to that list.
    The problem is that when the user validate his choice and close the popup, the element is not automatly added to the ComboBox without doing a refresh of the page.

    The combobox is coded as follows :

    <telerik:RadComboBox x:Name="MyElements"
                            SelectionChanged="MyElements_OnSelectionChanged"
                            ItemTemplate="{StaticResource ComboBoxElementsTemplate}"
                            ItemsSource="{Binding ListElements}"/>


    The constructor of the list is :

    public IEnumerable<Element> ListElements
    {
        get { return _listElements; }
     
        set
        {
            _listElements= value;
            RaisePropertyChange("ListElements");
        }
    }


    And the code behind of the button to validate the user choice in the popup :

        private ObservableCollection<HistoriqueElement> elementList = null;

       
    private void SelectClick(object sender, RoutedEventArgs e)
           {
               var element= _GridList.SelectedItem as HistoriquePasserelle;
               if (_GridList.SelectedItem != null)
               {
                   var installation = this.DataContext as Installation;
                   if (installation != null && element!= null)
                   {
                       element.DateFin = DateTime.Now;
                       HistoriqueElement newElement= new HistoriqueElement()
                       {
                           Installation = installation,
                           ContactAction = GlobalActeurs.Current.CurrentContact,
                           Date = DateTime.Now,
                           Element = element.Element,
                           StatutElement = element.StatutElement ,
                           Owner= element.Owner,
                       };
                       elementList.Remove(element);
                   }
                   MainPage.ClosePopup();
               }
           }


    When the user choose a new element in the list display in the popup and validate his choice, he returns to the main page, but his choice is not automatically added to the combobox.

    I can post you any parts of the code.
    Thank you in advance.


Back to Top