I'm trying to populate ComboBox. I'm able to add items from the default consctructor but not from the parameterised constructor.
public Dashboard()
{
this.InitializeComponent();
MyCombobox1.Items.Add("item_constructor 1"); // this item is added successfully
}
public Dashboard(int count, string[] arr)
{
this.InitializeComponent();
local_arr = arr;
for (int i = 0;i<count;i++)
{
MyCombobox1.Items.Add(local_arr[i]); // not added..no error thrown
}
}
private async void button_Click(object sender, RoutedEventArgs e)
{
MyCombobox1.Items.Add("item_button_click"); // item added successfully
}
The XAML code for the ComboBox..
<ComboBox
Name="MyCombobox1"
x:FieldModifier="public"
Grid.Row="0"
Grid.Column="1"
Canvas.Left="-121"
Canvas.Top="150"
Margin="450,360,0,0"
Background="#F1F1F5"
FontSize="24"
Header=" Choose file"
PlaceholderText="select"
RenderTransformOrigin="0.575,1.825"
SelectionChanged="MyCombobox1_SelectionChanged"
>
</ComboBox>
I'm not able to understand the mistake. Thank you.