WPF: Simple combobox data binding

This entry is part 25 of 54 in the series Learn WPF

Here we will just work out a simple way to display a selected item in a combo box using data binding method.

This is all done with XAML without using code behind.

<Window x:Class="ComboBox2.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <StackPanel Margin="20,20,20,20">
        <ComboBox Name="cbox" Text="My Cities" IsEditable="True" IsReadOnly="True">
        <TextBlock Text="{Binding ElementName=cbox, Path=SelectedItem.Content}" Width="200" Height="30" HorizontalAlignment="Center" Margin="10,100,50,50"></TextBlock>






Series Navigation<< WPF: Binding to a single object
WPF: XAML ComboBox >>

Leave a comment

Leave a Reply