Mega Code Archive

 
Categories / C# / WPF
 

Bind TextBlock Text to SelectedItem property of ListBox

<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>