image

image

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Learning about binding..." Width="500" Height="260">
    <StackPanel Orientation="Horizontal">
        <StackPanel>
            <TextBlock  Height="24" Text="Font sizes:" Margin="14,14,14,14" FontWeight="Bold"
        TextWrapping="Wrap"/>
            <ListBox x:Name="lstFontSize" Width="120" Height="128" HorizontalAlignment="Left"  Margin="14,0,14,10">
                <ListBoxItem Content="12"/>
                <ListBoxItem Content="14"/>
                <ListBoxItem Content="18"/>
                <ListBoxItem Content="22"/>
                <ListBoxItem Content="28"/>
                <ListBoxItem Content="36"/>
            </ListBox>

        </StackPanel>
        <StackPanel>
            <TextBlock Height="24" Text="Font types:" Margin="14,14,14,14" FontWeight="Bold"
        TextWrapping="Wrap"/>
            <ListBox x:Name="lstFontType" Width="120" Height="128" HorizontalAlignment="Left" Margin="14,0,14,10">
                <ListBoxItem Content="Verdana"/>
                <ListBoxItem Content="Courier New"/>
                <ListBoxItem Content="Calibri"/>
                <ListBoxItem Content="Arial Narrow"/>
                <ListBoxItem Content="Bernard MT Condensed"/>
                <ListBoxItem Content="Forte"/>
                <ListBoxItem Content="Broadway"/>
            </ListBox>
        </StackPanel>
        <StackPanel>
            <TextBlock Height="24" Width="140" Margin="14,14,14,14" HorizontalAlignment="Center" FontWeight="Bold" Text="You selected size of:" />
            <TextBlock 
                x:Name="tbSelectedFontSize" 
                HorizontalAlignment="Center" Margin="14,14,14,14"
                Text="{Binding ElementName=lstFontSize, Path=SelectedItem.Content, Mode=OneWay}" 
                FontFamily="{Binding ElementName=lstFontType, Path=SelectedItem.Content, Mode=OneWay}"
                FontSize="{Binding ElementName=lstFontSize, Path=SelectedItem.Content, Mode=OneWay}"/>

        </StackPanel>
                
    </StackPanel>

</Window>

It is all about binding. There is no code here. It is all done through binding. Notice that it is one-way binding.