raul hdez

raul hdez

  • NA
  • 1
  • 1.7k

Call parent component from children user control

Sep 3 2014 8:53 AM
Hello, I am trying to call a combobox located in a usercontrol from another usercontrol.

Parent user control:

<ComboBox x:Name="cmbA"   Width="100" SelectedIndex="0">
                </ComboBox>

<DataGrid>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <local:ucCM  />
                               </DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
   
</DataGrid>

Child user control (ucCM.xaml):

I have tried with this code, but it isn't working because "this.Parent" returns null.

ComboBox cmbA = (ComboBox)((this.Parent) as UserControl).FindName("cmbA");



Answers (1)