Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom UserControl "IsEnabled" data binding not working
    text
    copied!<p>I have a kinda awful problem with my WPF application right now...</p> <p>I have a custom UserControl used to edit details of a component. It should start by being not enabled, and become enabled as soon as the user chose a component to edit.</p> <p>The problem is: the IsEnabled property does not even change.</p> <p>Here is my code:</p> <pre><code>&lt;my:UcComponentEditor Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsEnabled="{Binding EditorEnabled}" DataContext="{Binding VmComponent}" /&gt; </code></pre> <p>EditorEnabled is a property in my ViewModel (VmComponent), and is by default false, becomes true when the user chose a component or created one</p> <p>Just for the record, in my ViewModel:</p> <pre><code>private Boolean _editorEnabled = false; public Boolean EditorEnabled { get { return _editorEnabled; } set { _editorEnabled = value; OnPropertyChanged("EditorEnabled"); } } </code></pre> <p>When I try to launch my app, the UserControl is starting... enabled. I added breakpoints everywhere, the EditorEnabled is false from the beginning.</p> <p>I also did a horribly stupid thing to try to figure out what's happening: I created a converter (so useful -- converting a boolean to boolean -- eh), put a breakpoint on it, and... The code is never reached.</p> <pre><code>&lt;my:UcComponentEditor Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsEnabled="{Binding EditorEnabled, Converter={StaticResource BoolConverter}}" DataContext="{Binding VmComponent}" /&gt; </code></pre> <p>That probably means that the property isEnabled is never set, since the converter is never reached.</p> <p>Do you see any kind of problem there? I started working in WPF about one week ago and therefore I may have missed something essential...</p> <p>Thank you very much for your time :-)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload