I have some terrible problem with my WPF application right now ...
I have a custom UserControl used to edit component details. It should begin with what is not turned on and becomes turned on as soon as the user selects a component for editing.
The problem is that the IsEnabled property does not even change.
Here is my code:
<my:UcComponentEditor Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsEnabled="{Binding EditorEnabled}" DataContext="{Binding VmComponent}" />
EditorEnabled is a property in my ViewModel (VmComponent) and defaults to false, becomes true when the user selects a component or creates it
For write only in my ViewModel:
private Boolean _editorEnabled = false; public Boolean EditorEnabled { get { return _editorEnabled; } set { _editorEnabled = value; OnPropertyChanged("EditorEnabled"); } }
When I try to start the application, UserControl is activated .... I have added breakpoints everywhere, EditorEnabled is false from the very beginning.
I also did a terribly stupid thing to try to figure out what was going on: I created a converter (so useful - converting the logical to boolean - eh), set a breakpoint on it and ... The code never reached.
<my:UcComponentEditor Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsEnabled="{Binding EditorEnabled, Converter={StaticResource BoolConverter}}" DataContext="{Binding VmComponent}" />
This probably means that the isEnabled property is never set since the converter was never reached.
Do you see any problem there? I started working in WPF about a week ago, and so I might have missed something important ...
Thank you very much for your time :-)