combo box default value

combo box default value

solvedplus
Contributor Contributor
850 Views
2 Replies
Message 1 of 3

combo box default value

solvedplus
Contributor
Contributor

Dears

good afternoon, i hope you all are fine
i have a working fine API plugin on Revit 2016

when i move it to Revit 2019, combo boxes not showing the default value and selectedindex="0" property not working at all, this was working fine on revit 2016 with the same code
i'm using WPF with MVVM methodes, visual studio 2015 & .NET Framework 4.7.2
kindly did any one face this problem, and how can i force my plugin to read the first value and show it in the combobox

thanks in advance

 

0 Likes
Accepted solutions (2)
851 Views
2 Replies
Replies (2)
Message 2 of 3

BIM.Frankliang
Collaborator
Collaborator
Accepted solution

Dear Friend,

 

         You could use below codes:

public ObservableCollection<string> DataList {get;set;}
private string _selectedData ;
public string SelectedData 
{
    get { return _selectedData ; }
    set
    {
        SetProperty(ref _selectedData , value, () => SelectedData );
    }
}
public ViewModel()
{
    DataList = new ObservableCollection<string>(list);
    SelectedData = DataList.FirstOrDefault();
}

 

Wish it could helpful for you 🙂

 

Best Regards

Frank Liang

0.png

0 Likes
Message 3 of 3

solvedplus
Contributor
Contributor
Accepted solution

its not working

he refused to assign it in the constrictor
but you some home gave the solution

i create anther list in the combo list property then before return the value , i have assigned the selected item

but its too weird , my code was working fine in old version of revit
what have changed in revit to change its behavior like that

revit ignores the selectedindex property of the combobox

any way many thanks for your response 

thanks

 

public IList<string> optionsList
{
     get
     {
           IList<string> temp = myList;
           SelectedOption = temp.FirstOrDefault();
           return temp;
     }
}

 

0 Likes