This is a migrated thread and some comments may be shown as answers.

ComboBox binding

0 Answers 76 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 08 Apr 2013, 06:58 AM
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.


No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
Paul
Top achievements
Rank 1
Share this question
or