0

I bound my text box to property (only text box) and used converter which just return opposite bool value.

XAML

<TextBox Height="23" HorizontalAlignment="Left" Margin="13,41,0,0" Text="{Binding Path=CurrentProfile.profileName}"  IsEnabled="{Binding Path=CurrentProfile.isPredefined, Converter={StaticResource PredefinedToControlEnabled}}" VerticalAlignment="Top" Width="247" Grid.ColumnSpan="2" TabIndex="1" />

Converter

public class PredefinedToControlEnabled: IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        var isPredefined = (bool)value;
        return !isPredefined;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

When the property value isPredefined is true, the IsEnabled property of TextBox is set correctly to false. When the isPredefined is false, the converter returns false and all controls on GUI sets IsEnabled property to false, what means that application is not useable anymore (it works in background naturally). Why it is happening?

How does it look like:

enter image description here

h__
  • 761
  • 3
  • 12
  • 41

1 Answers1

0

Found,

VS automagically add line to Window properties

IsEnabled="{Binding Path=CurrentProfile.isPredefined}"

but the question still is, how?

h__
  • 761
  • 3
  • 12
  • 41
  • did you try to add `UpdateSourceTrigger=PropertyChanged` to your IsEnabled-Property? `IsEnabled="{Binding Path=CurrentProfile.isPredefined, Converter={StaticResource PredefinedToControlEnabled}, UpdateSourceTrigger=PropertyChanged}"` – phil Jan 14 '14 at 09:45
  • Yes, fix found. Property were overwritten by binding to IsPredefined, what works in half of cases. Then the general settings for window was taken. – h__ Jan 14 '14 at 09:55