Bind TextBlock Text to SelectedItem property of ListBox

image_pdfimage_print


   
   

<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:g="clr-namespace:System.Globalization;assembly=mscorlib">

    <ListBox Name="lstbox"
             HorizontalAlignment="Center"
             Margin="24"
             ItemsSource="{Binding 
                            Source={x:Static g:DateTimeFormatInfo.CurrentInfo},
                            Path=DayNames,
                            Mode=OneTime}" />

    <TextBlock HorizontalAlignment="Center"
               Text="{Binding ElementName=lstbox, 
                                    Path=SelectedItem, Mode=OneWay}" />
</StackPanel>