Amresh S

Amresh S

  • NA
  • 437
  • 17.2k

How to add a combobox dynamically

Oct 20 2016 8:55 AM
Hi All,
I'm trying to add a combobox dynamically in bettween the two combox box. Depending upon the boolean value, the visibility is set. But, the problem is it should'nt consume the hidden space in between the other two comboboxes. Further, I'm using the Grid layout, in which by row definition I place the comboboxes in it's respective cells.
 
Please refer to my below XAML code:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="*"/>
<Grid.RowDefinitions/> 
<Combobox Grid.Row="0" Name="cmBox_Main" ItemSource="{Binding myData}"/>
<Combobox Grid.Row="1" Name="cmbBox_Sub" Visibility="Collapsed"/>
<TextBox Grid.Row="2" FontSize=14 FontWeight="Normal"/>
<Grid/> 
 
Note: By default, the 2nd combo box is collapsed/hidden from the view. Upon selection from the 1st combobox, it is validated in the code behind and the visibility is set. But, it should not consume space when no such selection is made from the 1st combo box.
 
Eventhough, I had collapsed it's visibility it occupies the space and appears as a blank area, which is not desireable.
 
Please share your ideas to achieve this requirement.
 
Thanks in advance.
 
Regards,
Amresh S. 

Answers (3)