One way to skin this cat would be by converting the string (in the listbox) into a bool to pass into the IsEnabledProperty...
First, create a class that implements the IValueConverter interface, like:
public class StringToBoolConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null)
return false;
string keyword = value.ToString();
if (keyword.Equals(parameter.ToString(), StringComparison.CurrentCultureIgnoreCase))
return true;
return false;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
Notice how you don't need to implement the ConvertBack method? That's because you only need to turn strings into bools, not vice-versa...
So you can declare an instance of your converter in the xaml, like
<Window
...
xmlns:local="clr-namespace:WpfApplication1">
<Window.Resources>
<local:StringToBoolConverter x:Key="stringToBoolConverter" />
</Window.Resources>
And finally, you can bind the TextBox to the ListBox's SelectedValue, like:
<TextBox Grid.Row="0" Width="90" Height="30"
IsEnabled="{Binding ElementName=lbSource, Path=SelectedValue, Converter={StaticResource stringToBoolConverter}, ConverterParameter=ValueForEnabled}">
</TextBox>
Note: This will only work if the ListBox contains strings, and you can be sure that the SelectedValue property is a string...