Tech Off Post

Single Post Permalink

View Thread: Dynamic Binding for TextBlock inside of DataTemplate in ComboBox
  • User profile image
    santrajas

    I am trying to Bind the TextBlock inside DataTemplate of ComboBox through Code. 

    XAML Code : 

    <ComboBox Name="cmbRefDoctor">
            <my:HComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock x:Name="txtRefDoctorName" />
                    </DataTemplate>
            </my:HComboBox.ItemTemplate>
    </ComboBox>

    Binding for the TextBlock "txtRefDoctorName" should be made in the code and not in the XAML. I am able to bind all the other controls which are not in DataTemplate but I am not able to solve this problem. 

    Can you please suggest a solution.