Tech Off Post

Single Post Permalink

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

    @santrajas: By putting the property name in the XAML, you set everything up beforehand. The actual binding doesn't take place until you set the itemssource/datacontext of the ComboBox in the code-behind.

    While you can do it all in code, as you're finding out it's pretty complex and really not the way Silverlight was designed to be used. Is this a strict requirement?

    <DataTemplate>
    <TextBlock Text="{Binding MyTextPropertyName}" />
    </DataTemplate>

    Sub BindStuff()
    myComboBox.ItemsSource = myDataSource
    End Sub