0
votes

I have MVVM architecture defined in my application. All of the datacontext are correctly initialized. Consider the binding situation for the ComboBox:

<Grid>
 <Grid.Resources>
  <DataTemplate x:Key="MyDataTemplate">
   <StackPanel Orientation="Horizontal">
    <Border Padding="5">
     <TextBlock Text="{}"/>      <===============================
    </Border>
   </StackPanel>
  </DataTemplate>
 </Grid.Resources>
 <ComboBox Itemsource=EmployeeNames ItemTemplate=MyDataTemplate/>
</Grid>

The ComboBox is bound to a ObservableCollection of strings names "EmployeeNames".

What should be the databinding expression in the Textbox defined in the datatemplate so as to display the string(which represents the employee) ?

1

1 Answers

0
votes

{Binding} would bind to the current datacontext. :) So, answer is

<TextBlock Text="{Binding}"/>